I am coding a decomposition algorithm including scenario subproblems. I need to use model pointer to create subproblem optimization models. Then, it is needed to modify the objective function coefficient of each subproblem as the algorithm proceeds. I need to use pointers to avoid creating the subproblem models every time from scratch. How should I do that? Can I use this:

 IloModel** MaxProblemPtr= new(env) IloModel*[numberOfScenarios];

 IloObjective** MaxObjPtr= new(env) IloObjective*[numberOfScenarios];

Then, is it correct to keep pointers to the implementation instances for each scenario subproblem like the followings:

IloModel MaxProblem(env);

IloObjective MaxObj=IloAdd(MaxProblem, IloMaximize(env));

Thank you much,

asked 09 Oct '15, 12:02

ORSE's gravatar image

accept rate: 0%

If subproblems differ only in the objective function, you wouldn't need to keep an array of models and objective functions. Simply, define a single model for the subproblems and then update its objective function for each subproblem. To do so, you might remove the objective function of the subproblem model and add it again (see lines 571-587 of ilobendersatsp.cpp) or update the objective function using the setExpr() method (e.g., spObj.setExpr(newObjExpr);).

(09 Oct '15, 14:09) Ehsan ♦

Thank you for your reply. Due to sceanrios, subproblems differ also in their constraints. Also, each subproblem needs to be modified by changing the objective function coefficients during the main algorithm process.

(09 Oct '15, 14:19) ORSE

Do the subproblems differ in structure and/or coefficients?

(09 Oct '15, 16:13) Ehsan ♦

Yes, coefficient matrix of each scenario sub problem is different. After making model pointer for each subproblem, the only thing that will change for each subproblem is the objective coefficients.

(09 Oct '15, 17:17) ORSE

Have you tried keeping models of subproblems in an IloArray object, instead of using pointers?

(10 Oct '15, 10:19) Ehsan ♦
showing 5 of 6 show 1 more comments

Thank you everybody for your comments. The problem got solved by making the subproblems row wise. Also I needed only to make pointers of IloCplex class and then I was able to get the model and modify the objective function from that.


answered 10 Oct '15, 14:09

ORSE's gravatar image

accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

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



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



Asked: 09 Oct '15, 12:02

Seen: 1,034 times

Last updated: 10 Oct '15, 14:09

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