Originally posted by: SystemAdmin
hi everybody, I hope find help on this error also ^^
My program is :
#include
"ilcplex\ilocplex.h" #include <stdlib.h> #include <time.h > #include <stdio.h> #include <iostream> using namespace std ; typedef IloArray<IloNumVarArray> NumVarMatrix; ILOSTLBEGIN
int main(
int argc, char** argv)
{ srand(time(NULL)); IloEnv env;
try
{ IloInt nbjobs=5; IloInt nbmachines=2; IloInt j,k;
int tab[5][2]; cout <<
"la matrice des temps de traitement est " << endl ;
for (k=0;k<2;k++)
{
for (j=0;j<5;j++)
{ tab [j][k]=rand()%99; cout << tab[j][k] <<
" ";
} cout <<
" " <<
"\n" ;
} IloModel model(env);
// creation of variables NumVarMatrix x(env, nbjobs);
// création de [.,.,.,.,.] NumVarMatrix I(env, nbmachines-1); NumVarMatrix w(env, nbmachines-1);
// 1 : variable x
for (j = 0; j < nbjobs; j++)
{ x[j] = IloNumVarArray(env, nbjobs, 0,1, ILOINT);
}
// 2: variable I and W
for (j = 0; j < nbmachines-1; j++)
{ I[j] = IloNumVarArray (env,nbjobs-1,0,100000,ILOFLOAT); w[j] = IloNumVarArray (env,nbjobs-1,0,100000,ILOFLOAT) ;
}
//constraint 1 : IloExpr expr(env);
for (
int k=0;k<nbjobs;k++)
{
for (
int i = 0; i <nbjobs; i++)
{ expr +=x[i][k] ;
} model.add(expr == 1); expr.end();
}
//constraint 2 : IloExpr expr1(env);
for (
int i = 0; i <nbjobs; i++)
{ expr1 =x[i][0] ;
for (
int k=1;k<nbjobs;k++)
{ expr1 +=x[i][k] ;
} model.add(expr1 == 1); expr1.end();
}
// constraint 3 : IloExpr expr2(env);
for (
int k=0;k<nbjobs-1;k++)
{expr2 =I[1][k] ; model.add(expr2 == 0); expr2.end();
}
//constraint 4 : IloExpr expr3(env);
for (
int k=0;k<nbmachines-1;k++)
{ expr3 =w[k][1] ; model.add(expr3 == 0); expr3.end();
}
//constraint 5 : IloExpr expr4(env); IloExpr expr5(env); IloExpr expr6(env); IloExpr expr7(env);
for (
int j=0;j<nbmachines-1;j++)
{
for (
int k=0;k<nbjobs-1;k++)
{
for (
int i=0;i<nbjobs;i++)
{ expr4 +=x[i][k+1]*tab[i][j] ; expr6 += x[i][k]*tab[i][j+1];
} expr5 = expr4 + w[j][k+1]+I[j][k]; expr7=expr6+w[j][k]+I[j+1][k] ; model.add(expr5 == expr7); expr4.end(); expr5.end(); expr6.end(); expr7.end();
}
}
//objective function : IloExpr expr8(env);
for (
int i = 0; i <nbjobs; i++)
{
for (
int j=0;j<nbmachines-1;j++)
{ expr8 +=x[i][1]*tab[i][j] ;
}
} IloExpr expr9(env);
for (
int i=0;i<nbjobs-1;i++)
{ expr9 +=I[nbmachines][i];
} model.add(IloMinimize(env, expr8+expr9)); expr8.end(); expr9.end();
///////////////////////////////////////////////////////////////////////////////resolution : IloCplex cplex(model); cplex.solve (); cplex.getStatus ();
}
catch (IloException& e)
{ cerr <<
"Concert Exception: " << e << endl;
}
catch (...)
{ cerr <<
"Other Exception" << endl;
} env.end(); system (
"pause");
}
// END main
when i compile this program i have no error , but when i start debugging , i have this error :
Unhandled exception in 0x00e36e0f in flowshop de permutation.exe : 0xC0000005: Access violation during the reading of the location 0x00000004.
a screen shot is attached
someone can tell me where is the problem please ?
#CPLEXOptimizers#DecisionOptimization