Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
  • 1.  Unhandled exception !!!!!!!!!!!!!!!

    Posted Sat April 06, 2013 11:10 AM

    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


  • 2.  Re: Unhandled exception !!!!!!!!!!!!!!!

    Posted Sat April 06, 2013 02:47 PM

    Originally posted by: SystemAdmin


    it's good, it was a problem of dimension matrices

    i solved it ^^
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Unhandled exception !!!!!!!!!!!!!!!

    Posted Tue July 09, 2013 05:39 AM

    Originally posted by: HesamShams


    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


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Unhandled exception !!!!!!!!!!!!!!!

    Posted Tue July 09, 2013 03:56 PM

    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.


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Unhandled exception !!!!!!!!!!!!!!!

    Posted Wed July 10, 2013 02:36 AM

    Originally posted by: HesamShams


    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);


    #CPLEXOptimizers
    #DecisionOptimization