Originally posted by: Rym
I generate my model n times in loop for.
In the loop for (ittération) I would to make the sum between each countPV cell of the last ittération and the newest .
In main script, i can't mak the sum etween two arrays cell per cell.
My model:
{int} contPM;
int VMmin=1;
int VMmax=4;
int VM[i in V]=VMmin+rand(VMmax-VMmin+1);
string S[VMmin..VMmax]=["s","m","l","xl"];
string vms[i in V]=S[VM[i]];
{string} VMTypes={S[v] | v in VMmin..VMmax};
//PreProcess
....
//the model/problem definition
dvar boolean lumda[V][P];
dexpr int O = sum( i in V, j in P) lumda[i][j];
dexpr int OPPMVMS[vmtype in VMTypes][ptype in P]=sum( j in P, i in V:j==ptype&&vms[i]==vmtype) lumda[i][j];
maximize O;
//constraints
....
tuple PM
{
int npm;
string nvm;
}
{PM} indexes={<i,j> | i in P,j in VMTypes};
int countPV[ <i,j> in indexes]=OPPMVMS[j][i];
{int} countPM={j | i in V,j in P:lumda[i][j]==1 };
int pm= card(countPM);
main
{var res = new Array();
var min=10;
var max=30;
var mix=max-min+1;
for(var j=1;j<120;j=j+(min+(Opl.rand(mix))))
{
for (var i=1; i<=NbI;i++)
{
writeln("######Ittération number ", i,"#######");
var masterDef = thisOplModel.modelDefinition;
var masterCplex = cplex;
var masterData = thisOplModel.dataElements;
// Creating the master-model
var masterOpl = new IloOplModel(masterDef, masterCplex);
masterData.v=j;
masterOpl.addDataSource(masterData);
writeln("solving with ",j," vms");
masterOpl.generate();
if ( masterCplex.solve() )
{
I want to store in an array of same size that countVP the sum of each cell of countPV for the n ittérations:
res[i]=res[i]+masteOpl.countPV[i]
}
else
{}
}end n ittérations
for(var i in res)
//the average
res[i]=res[i]/Number of ittérations
}end second loop for
}
}
Thanks
#DecisionOptimization#OPLusingCPLEXOptimizer