Originally posted by: SystemAdmin
>
> Hi Paul,
>
> Many thanks for your answer. I have been trying it out, and the problem I have is that I do not quite understand how the masterProblem and the subProblem "share" information, as they are separate instances. I would like some variables of the master to be parameters of the subProblem, and viceversa. Do I just have to pass them to an array at every iteration that acts as the parameter? Is there a better way to do this?
That's about it. After you solve the master problem, you extract whatever portion of the solution is relevant (as doubles, integers or maybe booleans, depending on the types of the master problem variables) and pass that to the subproblem as values for some of the subproblem parameters. Then solve the subproblem, extract whatever info you need, and pass it as parameter values to the master problem, etc., ad nauseum.
>
> In a similar set-up, I am not sure I understand how to add the same variable to two different models. Do I just have to create two different variables and pass the value from one model to the other if I want it as initial guess? For example, I encounter the following problem if trying to do it step by step (I have arrays)
>
> IloCplex base = new IloCplex();
> IloCplex integer = new IloCplex();
> IloNumVar
][[] ut = new IloIntVar[S][H][K]; // variable in both models
> for (int h = 0; h < H; h++) {
> for (int k = 0; k < K; k++) {
> for (int s = 0; s < S; s++) {
> ut[s][h][k] = integer.intVar(0, 1); // initialize "ut" for integer and add
> integer.add(ut[s][h][k]);
> ut[s][h][k] = base.intVar(0, 1); // **** with this line, solver seems to get lost for integer model;
> // without this line, solver crashes if solving base model
> // as base does not initialize "ut"...
> base.add(ut[s][h][k]);
> }
> }
> }
>
> As a solution, I created a model with all the common variables (base), exported it and imported it into the integer model ---if I just did IloCplex integer = base; then any modification in integer would apply to base. However I am not yet sure how they share the info in such case.
>
You cannot share model objects between two models using the Java API. On the other hand, I don't see much reason to do so. I'm not sure what info you're trying to share, so I can't be more specific.
/Paul
Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
#CPLEXOptimizers#DecisionOptimization