Binary LP vs Integer LP

I wonder why there is a difference between the following linear programs. They are recorded in LP file format . I would guess that x=1

would be the optimal solution in both cases.

Program A:

min: x;
x >= 1;
bin x;

      

Output:

Value of objective function: 0

Actual values of the variables:
x                               0

      

Program B (simulates a binary constraint with an integer constraint and two additional constraints):

min: x;
x >= 1;
x <= 1;
x >= 0;
int x;

      

Output:

Value of objective function: 1.00000000

Actual values of the variables:
x                               1

      

+3


source to share


1 answer


Yes, this is a small quirk lpSove

related to single variable constraints.

In your task A, the "bin x" setting ends up overriding the "x> = 1" constraint. That is why 0 is the optimal solution.

From the documentation :

Note that for variable boundaries, you must not put labels in front of them. This is because lp_solve makes it an additional restriction. If you do not put a shortcut in front of single variables, then lp_solve does not need to create an extra line for variable boundaries, which will improve performance.

So it's better to write:

 x1 >= 1;

      

than

 r_x1: x1 >= 1;

      

Note that this is only for single variables, so myrow: x1 + x2> = 2;

also performs

x1 + x2 >= 2;

      



In your problem A, you have one variable constraint. When not explicitly specified, the "bin" declaration overrides this restriction. As you correctly noted, if you make the constraint explicit by naming it, then lpSolve will create a new line for x1, so enforcing the constraint and "bin" cannot override it.

min: x;
a: x >= 1.0;
bin x;

      

will provide you with:

Value of objective function: 1.00000000

Actual values of the variables:
x                               1

      

+1


source







All Articles