Originally posted by: SystemAdmin
[amirahr said:]
Hi all
I'm trying to add user cuts (named 'validprec') to my model. I've seen the example codes that deal with adding user cuts (iloadmipex4, iloadmipex5) and I emulated what was done in iloadmipex4 as it seemed less complicated. The difference was that I put everything in int main. Here's what I've done so far:
IloModel model(env);
IloConstraintArray validprec(env);
y = IloIntVarArray5(env, N); //decision variable to be used in validprec
for(i=0;i<N;i++)<br />{
y[i] = IloIntVarArray4(env, R);
for(r = 0 ; r < R ; r++)<br /> {
y[i][r] = IloIntVarArray3(env, N);
for( id = 0 ; id < N ; id++)<br /> {
y[i][r][id] = IloIntVarArray2(env, R);
for( rd = 0 ; rd < R ; rd++)<br /> {
y[i][r][id][rd] = IloIntVarArray(env, J, 0, 1);
}
}
}
}
for( i = 0 ; i < N-1 ; i++ )<br />{
for( id = i+1 ; id < N ; id++ )<br /> {
for( r = 0 ; r < R ; r++ )<br /> {
for( rd = 0 ; rd < R ; rd++ )<br /> {
for( j = 0 ; j < J ; j++ )<br /> {
for( jd = 0 ; jd < J ; jd++ )<br /> {
for( k=1 ; k < NoS[i] ; k++ )<br /> {
for( kd = 1 ; kd < NoS[id] ; kd++ )<br /> {
if( prec[jd][j] == 1 )
{
if( sigma[i][r][k] == j && sigma[id][rd][kd-1] == j )
{
if( sigma[i][r][k-1] == jd && sigma[id][rd][kd] == jd )
{
if( r%2 == 0 && rd%2 != 0 )
{
if( j > jd )
{
validprec.add
(y[i][r][id][rd][j] - y[i][r][id][rd][jd] <= 0);<br /> }
}
}
}
}
}
}
}
}
}
}
}
}
IloCplex cplex2(model);
cplex2.addCuts(validprec);
validprec.endElements();
validprec.end();
The code compiled all right but when I ran the .exe, I got this:
Concert error: invalid cut
Am I doing this wrong? Should there be an IloCplex::AddCuts() or an IloCplex::AddUserCuts() term in there somewhere? If yes, then what goes in the brackets? Or is there something wrong with my cuts?
In the runs prior to making validprec a cut, it was a constraint. Building, compiling and running the model with it as a constraint yielded no error messages, it solved to optimality. So then why are they invalid as cuts?
Thanks in advance.
Amirah
#CPLEXOptimizers#DecisionOptimization