Topic
  • 4 replies
  • Latest Post - ‏2013-07-10T06:35:37Z by HesamShams
SystemAdmin
SystemAdmin
7929 Posts

Pinned topic Unhandled exception !!!!!!!!!!!!!!!

‏2013-04-06T15:10:19Z |
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 ?
Updated on 2013-04-06T18:47:13Z at 2013-04-06T18:47:13Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    7929 Posts

    Re: Unhandled exception !!!!!!!!!!!!!!!

    ‏2013-04-06T18:47:13Z  
    it's good, it was a problem of dimension matrices

    i solved it ^^
  • HesamShams
    HesamShams
    2 Posts

    Re: Unhandled exception !!!!!!!!!!!!!!!

    ‏2013-07-09T09:38:57Z  
    it's good, it was a problem of dimension matrices

    i solved it ^^

    please tell us what did u do to solve the problem, i have the same problem and my code is running for small size problem and message this when the problem size increased.

    I want to message me in cmd instead of message in a pop-up window!

    thanks

  • DanielJunglas
    DanielJunglas
    2109 Posts

    Re: Unhandled exception !!!!!!!!!!!!!!!

    ‏2013-07-09T19:55:54Z  

    please tell us what did u do to solve the problem, i have the same problem and my code is running for small size problem and message this when the problem size increased.

    I want to message me in cmd instead of message in a pop-up window!

    thanks

    The first thing to do is to run the program through a debugger to pinpoint where exactly that access violation happens. This is likely to be not a problem with CPLEX but with your code. Something like dereferencing a NULL pointer or reading through an uninitialized pointer for example.

  • HesamShams
    HesamShams
    2 Posts

    Re: Unhandled exception !!!!!!!!!!!!!!!

    ‏2013-07-10T06:35:37Z  

    The first thing to do is to run the program through a debugger to pinpoint where exactly that access violation happens. This is likely to be not a problem with CPLEX but with your code. Something like dereferencing a NULL pointer or reading through an uninitialized pointer for example.

    thanks for reply, i'm quit sure the problem is because of the size of problem, first small sized solved by the code and this error pop up for large size problems. second the access violation happens in this part of programming code:

    IloCplex cplex(model);