# Adding Variables or Modifying Existing Constraints During Callbacks with Cplex (C++)

 0 I am trying to implement an optimization algorithm using cplex C++ Concert Technology and I have two questions: 1) Is it possible to use a callback (e.g. a lazy constraint) to change an existing constraint of the problem? From what I understand this is not possible, but I am wondering if there is a work around. 2) Can I add new variables to the model with a callback? Encoding some constraints in my lazy constraint callback would be much more convenient if I could define helper variables. Similar as before, I think it is not possible, but perhaps there are some alternatives. In short, during the callback I can learn some information about the problem and based on this I would like to add some constraints. I have a constraint b = b1 + b2 + .... , but there are exponentially many bi plus I do not know all of them in advance. However, every time I compute a feasible solution I could add one of the bi to the sum that defines b. Clearly there can be a memory blowup here, but I am hoping that I will find a suitable solution before that happens. p.s. One solution that I have is that I can simply abort the current solving, add and modify the constraints, and then call solve() again. This is one possibility, but I assume there is a better way. Thank you in advance! asked 20 Oct '16, 13:42 Emir 15●7 accept rate: 0%

One Answer:
 3 1) It is not possible to change a constraint mid-solve, with one exception: you can tighten a constraint, by leaving it in place and piling the tighter version on top of it. For instance, if the original model contains $$a'x \le 20$$ and you decide you want $$a'x \le 10$$, just add the latter constraint (in a lazy constraint callback) and don't worry about the looser version. 2) No, you cannot add variables mid-solve. There are, however, frameworks for doing this (known as branch-and-price or branch-cut-and-price), some of which can use CPLEX as the solver engine. You might want to look at BCP or Symphony. answered 21 Oct '16, 19:49 Paul Rubin ♦♦ 14.6k●4●12 accept rate: 19% Thank you for the information. (22 Oct '16, 06:52) Emir
Your answer
 toggle preview community wiki

### 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
×8
×3

Asked: 20 Oct '16, 13:42

Seen: 1,146 times

Last updated: 22 Oct '16, 06:52

### Related questions

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