Get maximum value a scalar set that is conditioned on a variable set being non-zero
Awaiting user inputHi,
I appologize for the incoherent title. Here is a better explaination.
- I have a set of scalars (A) where A = [1.2, 0.9, -1.9]
- A set continuous variables (X) with lower and upper bounds of 0 <= X <= 10.
- The objective function is maximise a1x1 + a2x2+ a3x3
Requirement
I have a single continuous variable b with a_min<= b <= a_max.
I want this b variable to be equal to maximum a value where x is non-zero. So if the solution of the model is X = [10, 10, 0]. I want b = 1.2.
My own solution using gp.max_
For this,
- I defined a set of binary variables F = [f1, f2, f3] where f1=1, if x1>0,
- I defined a continous variable set FA = [fa1, fa2, fa3]. I added the constraint that equates fa1 = f1 * a1.
- I added the constraint b = gp.max_(fa1, fa2, fa3, ...) to find the maximum a value with non-zero x.
Issue & question
This solution works at the cost of higher complexity, and runtime. The original model is obviously larger and it would benefit from a simpler model where we do not rely on additional F and FA sets. My question is: is such a model possible? Can we calculate b without adding binary variables?
-
Hi,
Could you say something about the original, larger model? I've thought about your question for a while and believe the three additional model elements (your bullets) logically follow from the problem statement, so it won't be easy to reduce further.
But without additional constraints and given the objective function, I would say the outcome is always to set Xi=10 for ai>0 and Xi=0 for ai<0, with b being equal to the largest of all ai values (which can be calculated before solving the model). So the question is what additional complexity is in the model which would make this approach invalid.
Kind regards,
Ronald0
Please sign in to leave a comment.
Comments
1 comment