I'm wondering about the impact of soft constraints, since no one mentioned that in Soft constraints and hard constraints.

My team makes all the constraints soft in MILP, so that a feasible solution can always be found. Furthermore, this finding helps us to locate problematic constraints.

But that approach seems to cause lots of numerical issues, because some arbitrary large penalties are used. In my mind, we should only use soft constraints whenever its penalty makes sense in the real world. I need some arguments for hard constraints (mostly bounds on variables).

  • 3
    $\begingroup$ In my opinion, your are asking the wrong question. Whether or not to use soft constraints depends on the business need. What defines a feasible solution in your application? Is a solution still feasible if a soft constraint is violated? If not, then it should not have been a soft constraint. Do you need one or more of the constraints to be soft constraints because your problem is overly constrained and does not permit a solution that satisfies all constraints? Then you might need a soft-constraint. $\endgroup$ May 16, 2022 at 17:56
  • $\begingroup$ Thanks for the comment. I know my question does not make sense, but that's what my team did already. $\endgroup$
    – Edward
    May 17, 2022 at 12:31
  • $\begingroup$ Will try to have more soft constraints in the second run whenever infeasibility happens, as you suggested. Still, I need arguments for using hard constraints whenever possible in the first run. $\endgroup$
    – Edward
    May 17, 2022 at 12:39

2 Answers 2


From a paper on the branch-and-cut in MILP solvers:

Because cuts are often based on infeasibility, models with soft constraints that are always feasible can present unique challenges for deriving cuts.

This seems to explain why to solve a MILP with lots of soft constraints is difficult.

  • Klotz, E., & Newman, A. M. (2013). Practical guidelines for solving difficult mixed integer linear programs. Surveys in Operations Research and Management Science, 18(1-2), 18-32.

This is to a large extent an expanded version of Joris's comment.

Things that have to be a certain way, period, require hard constraints. Examples: "We cannot ship more stuff than we have" -> shipments <= inventory. "We have to meet demand" -> shipments >= demand.

Things that should be a certain way, but have prescribed (well defined, well understood) work-arounds when necessary, typically require hard constraints and a somewhat expanded model. Examples: "We can ship more stuff than we have, but it will require buying substitute products on the open market" -> shipments + external purchases <= inventory (plus perhaps a bound on external purchases). "Either we meet demand or we eat a penalty" -> shipments + shortfall >= demand (with an objective penalty for shortfall).

Things that start with "we ought to", "we would like to", "gee, it would be nice if" etc. may turn into soft constraints (containing slack/surplus variables that are rewarded/penalized in the objective function).

Personally, I would be suspicious of a model where the soft constraints outnumbered the hard ones.

  • 2
    $\begingroup$ Thanks for the answer. It helps me understand how to use soft constraints. However, it would be better if there is math- and/or computation-related explanation for why the hard constraint should be used whenever possible. $\endgroup$
    – Edward
    May 17, 2022 at 12:34

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.