2

I'm trying to create an optimization problem in the following form using lpSolveAPI.

max 10(x1 + x2) * S1 + 20(x1 + x2) * S2

sub.to. S1 + S2 <= 1 # These are binary variables.

2 * x1 + 3 * x2 <= 30

1 * x1 + 2 * x2 <= 10

x1 & x2 are integers.

My problem is how to create this multiplicative variable? All the examples I'm coming across variables are linearly assigned. As mentioned earlier I'm using lpSolveAPI from R.

4
  • 1
    You could tackle the cases S1=0,S2=1 and S1=1,S2=0 separately and take the solution with the larger result. Commented Dec 31, 2017 at 13:29
  • @AxelKemper: Thanks for the great suggestion! I didn't think about it. But one issue is if my S are say 50. Then I've to do 50 separate optimization, which will be bit difficult to do. And my S are actually more than 2. Commented Dec 31, 2017 at 13:32
  • 1
    Perhaps, you can make use of linearization. Commented Dec 31, 2017 at 13:44
  • @AxelKemper: Thanks for this suggestion! Will surely look into it. Commented Dec 31, 2017 at 13:56

1 Answer 1

2

It sounds like you have a sum like (10*x1 + 10*x2) * S1 + (20*x1 + 20*x2) * S2 + ... with binary S1, S2, ... and you are trying to maximize this term.

One way to do this would be to define variables V1, V2, ..., with one for each of the S1, S2, ... variables. You can then add the following constraints:

V1 <= 10*x1 + 10*x2
V1 <= M*S1
V2 <= 20*x1 + 20*x2
V2 <= M*S2
...

Here, M is a large positive constant. No matter the value of S1, the variable V1 must satisfy V1 <= 10*x1 + 10*x2. If S1=0, then we additionally have V1 <= 0. If S1=1, then we additionally have V1 <= M. However if M is large enough, then this will never be a binding constraint.

Now, we can replace the objective with:

max V1 + V2 + ...

Since we are maximizing, the V variables will take value 0 when their corresponding S variable is not set, and it will take the value you want in the objective otherwise.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.