Hello all,

I was coding a model in C++ and CPLEX and I was wondering what may be the best practice in the following situation:

I have a MIP formulation where multiple decisions can be made over multiple years. Such as: I have a decision X{0,0} is decision 0 in t 0, X{0,1} is decision 0 in t 1, X{1,1} is decision 1 in t 1, etc.

I know for certain that a particular decision in year one will be 0 (zero). is it better for me to:

  1. avoid declaring the variable anywhere (harder, I think)
  2. have a constraint that sets these variables to zero (i.e. model.add( VAR[i][j] == 0); (easier)

thanks,

asked 28 Aug '13, 15:56

sgrogan's gravatar image

sgrogan
2315
accept rate: 0%


Instead of adding this constraint, you might also just fix the variable by changing the bound(s). In any case, the preprocessing of CPLEX should take care of the issue and remove the variable.

You have already noticed that it is easier to implement the model this way. You could also argue that the code would be easier to read and adapt later.

Sometimes, "helper" variables are added to the problem that don't represent actual decisions but help with reporting of the solution. Here, too, convenience is chosen over performance.

link

answered 28 Aug '13, 16:43

rschwarz's gravatar image

rschwarz
366210
accept rate: 21%

You should consider two issues: computer time and analyst time.

If you only consider computer time, then you should not declare that variable at all. You should also check if there are other implications from that variable being 0. While the presolver in cplex is very good, it can't cover every single case, and can always use all the help it can get.

But if you consider analyst time as well, then the story changes. In particular, if that variable is 0 depending on data, then you probably want to declare it and set the bounds to zero in a separate step. That way you can reuse the model in more scenarios.

Another aspect to consider is whether you are declaring the variable unnecessarily because your entire formulation needs some attention. In a Modeling Language, declaring variables over sparse sets, using filters abundantly, using sets of sets, defining inputs in terms of realizations of the data, etc, is not only easy but also tends to produce clear maintainable models. In a C++ library like Concert, you usually have to work much harder to express complex rules and the code tends to become complex quickly. If that is what you are observing, you generally want to spend the extra time on your formulation even if the code becomes more complex. The time penalty of a weaker than necessary formulation is often much higher than that of problem generation even accounting for the interpreted vs compiled difference.

link

answered 28 Aug '13, 21:10

Leo's gravatar image

Leo
1.1k17
accept rate: 8%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×191
×30
×4

Asked: 28 Aug '13, 15:56

Seen: 2,162 times

Last updated: 28 Aug '13, 21:10

OR-Exchange! Your site for questions, answers, and announcements about operations research.