Originally posted by: SystemAdmin
Hi,
I am new to CPLEX concert and dunno how to add multiple constraints to a model. Below is the attached code with compiling errors:
IloEnv env; IloModel model(env,
"resalloc"); IloIntVarArray n[10]; IloIntVarArray fl[10];
for(
int i = 0; i < APP_NUM; i++)
{ n[i] = IloIntVarArray(env); fl[i] = IloIntVarArray(env); n[i].setSize(20); fl[i].setSize(20);
for(
int j = 0; j < 20; j++)
{ n[i].add(IloIntVar(env, 1, 3,
"number")); fl[i].add(IloIntVar(env, 1, 6,
"freq_level"));
}
} IloRangeArray range[10];
for(
int i = 0; i < 10; i++)
{
for(
int j = 0; j < 20; j++)
{ IloInt lower_bound = 1; IloInt upper_bound = 5; range[i].add(IloRange(env, lower_bound, (n[i][j] - 1)*6 + fl[i][j], upper_bound,
"range"));
}
} model.add(range); env.end();
simulation.cpp(68): warning C4244: 'argument' : conversion from 'IloInt' to 'IloNum', possible loss of data
1>simulation.cpp(68): warning C4244: 'argument' : conversion from 'IloInt' to 'IloNum', possible loss of data
1>simulation.cpp(72): error C2664: 'IloExtractable IloModel::add(const IloExtractable) const' : cannot convert parameter 1 from 'IloRangeArray
10' to 'const IloExtractable'
1> No constructor could take the source type, or constructor overload resolution was ambiguous
Can't I directly use "model.add(range);" to accomplish what I've wished?
Another question is "can I directly assign an int type variable in C++ to a IloInt variable?".
Thanks in advance;)
#CPLEXOptimizers#DecisionOptimization