title: Is it possible to creat an array of Cplex objects or IloModel?
body: <p>I am using Java to solve a series of problems with Cplex. My main goad is to optimise different stances of a model with modified variables and constraints ( and no, I can't modify the main model every time). </p>
  
  <p>My primary approach was to create an array of Cplex objects like this:</p>
  
  <pre><code>IloCplex[] model = new IloCplex[10];
  IloNumVar[][] X = new IloNumVar[10][5];
  for( int i=0;i&lt;10;i++){
     for(int j=0;j&lt;5;j++){
         x[i][j] = ; // something different each time,e.g. different lb&amp;ub
     }
     rng[i] = ;// something different each time on x[i]s
     model[i].add(x[i]);
     model[i].add(rng[i]);
  } // end of for loop
  // to separate the model from solving procedure, another IloCplex object has been created:
  IloCplex newModel = new IloCplex;
  for(int  i=0;i&lt;10;i++){
     newModel = model[i];
     newModel.addMinimize(cost(model[i], x[i]));
     newModel.solve()
     if(newModel.solve()){
         //print the answers
     }
     else{
         //print problem not solvable
     }
  </code></pre>
  
  <p>}// end of for loop</p>
  
  <p>Cost is a function getting model and variables and making a function out of it.</p>
  
  <p>So, the algorithm works for the first time (i=0), but, it seems during the solving procedure, it changes all the model[i]s although I tried to separate them. Hence, in next iteration, the problem can't be solve and I get this error: </p>
  
  <p>ilog.cplex.MultipleObjectiveException</p>
  
  <p>I have also tried to use IloEnv to separate the models, but that also didn't work (I asked it as a question in another post: <a href="https://stackoverflow.com/questions/48653753/iloenv-is-not-working">IloEnv is not working</a>). </p>
  
  <p>Anyone had a similar problem? Do you have a better approach? Any thought to solve the problems?</p>
  
  <p>Thanks in advance. </p>