Friday, May 23, 2008

Modeling question

>
> Suppose I want to maximise, say:
> a1 + a2 + a3 + b1 + b2 + b3 + c1 + c2 + c3 < 30
>
> ...but with the extra condition that I must have two items from each
> of the following sets (at least two members of each set must be
> greater than zero): {a1, a2, a3}, {b1, b2, b3}, {c1, c2, c3}
>
> Is there an easy way to ask lp_solve for this condition, please?
>



One way of achieving this is to add the constraints:


a(i) ≥ 0.001·p(i)
b(i) ≥ 0.001·q(i)
c(i) ≥ 0.001·r(i)
sum(i,p(i)) ≥ 2
sum(i,q(i)) ≥ 2
sum(i,r(i)) ≥ 2
p(i),q(i),r(i) binary variables


Note that we do not need to model the additional implications
p(i)=0 => a(i)=0

because we exploit the "at least" part of the condition. If we want exactly two nonzeroes for each group, this implication would need to be added.

No comments:

Post a Comment