0

Recently, I have been learning optimization, and my optimization problem, (minimization), is encoded in a MILP solver which tells me it's infeasible for my model. Hence, I introduced a few positive/negative slack variables. Now, I get a feasible solution, but the positive slack variables are way bigger than what I can accept. So, I gave penalties/weights to those variables (multiplied by large numbers), hoping that the MILP solver would reduce the variables, but that didn't work (I got the same solution) Is there any approach to follow, in general, when the slack is too large? Is there a better way to pick the slack variables, in general?

mattmilten
  • 6,242
  • 3
  • 35
  • 65
GermanShepherd
  • 151
  • 1
  • 13

2 Answers2

1
  1. Add both to the objective with a penalty coefficient.
  2. Or add some upper bounds to the slacks.
Erwin Kalvelagen
  • 15,677
  • 2
  • 14
  • 39
  • These have already been done. Could it be possible, that the choice of slack variables is not good enough? Is there some general strategy/guidelines by which you pick the variables ? I have only added slack variables (both negative and positive) for those variables in the unsatisfied constraints. – GermanShepherd Apr 28 '22 at 04:41
  • 1
    Large slacks may be needed to make the problem feasible or to make the objective better, or they may be the result of a bug in the model or the code. Difficult to say with my limited mind-reading skills. – Erwin Kalvelagen Apr 28 '22 at 05:09
  • How I give the penalty is like this: problem+=(lpSum(objective_function....) + 1000*lpsum(positive_slack_var[value] for value in set)+1000*lpsum(-negative_slack_var[value] for value in set)+... Are there any glaring mistakes? – GermanShepherd Apr 28 '22 at 06:45
1

A common pitfall for people new to mathematical programming/optimization is that variables are non-negative by default, that is, they always have an implied lower bound of 0. Your mathematical model may not specify this explicitly, so those variables might need to be declared as free (with a lower bound of -infinity).

In general, you should double-check your model (as LP file) and compare it to the mathematical formulation.

mattmilten
  • 6,242
  • 3
  • 35
  • 65
  • That's a great point! Thanks. Based on observation, for the positive_slack lowBound=0, upBound=None and for negative_slack lowBound=None, upBound=0. – GermanShepherd Apr 28 '22 at 06:52