I'm using jsLPSolver to solve an integer-programming problem.
I'm having trouble adjusting the model to contain incompatibility constraints. I've got the following model:
{
"optimize": "cost",
"opType": "min",
"constraints": {
"c1": { "min": 36000.0, "max": 36800.0 },
"c2": { "min": 12000.0, "max": 12800.0 },
"c3": { "equal": 1000.0 }
},
"variables": {
"p1": { "c1": 0, "c2": 0, "c3": 1, "cost": 437.47, },
"p2": { "c1": 0, "c2": 60.0, "c3": 1, "cost": 1964.49, },
"p3": { "c1": 34.0, "c2": 0, "c3": 1, "cost": 1428.98, },
"p4": { "c1": 46.0, "c2": 0, "c3": 1, "cost": 1973.11, }
},
"ints": { "p1": 1, "p2": 1, "p3": 1, "p4": 1 }
}
and the feasible result
{ bounded: true, feasible: true, p2: 200, p3: 66, p4: 734, result: 1935473.42 }
However, it exists a constraint that p3
and p4
could not be together in the solution, because they are incompatible.
Is it possible to define an incompatibility constraint to define that p3
and p4
is incompatible variables?
EDIT
I'm thinking about use a constraint like p3 + p4 = 0
:
{
"optimize": "cost",
"opType": "min",
"constraints": {
"c1": { "min": 36000.0, "max": 36800.0 },
"c2": { "min": 12000.0, "max": 12800.0 },
"c3": { "equal": 1000.0 },
"incompatible": { "equal": 0.0 }
},
"variables": {
"p1": { "c1": 0, "c2": 0, "c3": 1, "cost": 437.47, "incompatible": 0.0 },
"p2": { "c1": 0, "c2": 60.0, "c3": 1, "cost": 1964.49, "incompatible": 0.0 },
"p3": { "c1": 34.0, "c2": 0, "c3": 1, "cost": 1428.98, "incompatible": 1.0 },
"p4": { "c1": 46.0, "c2": 0, "c3": 1, "cost": 1973.11, "incompatible": 1.0 }
},
"ints": { "p1": 1, "p2": 1, "p3": 1, "p4": 1 }
}
but see what happens to the solution in this case:
{ bounded: true, feasible: false, p2: 200, p3: -3000, p4: 3000, result: 0 }
as seen on https://runkit.com/tetrimesquita/incompatible-contraint, which is correct but unfeasible.