Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  How to deal with defining mixed integer programming?

    Posted 10/19/09 07:16 PM

    Originally posted by: SystemAdmin


    [nfan said:]

    I used following codes in C++ to define high dimensional integer and continuous variables. However, I always got the error
    "Segmentation fault".

    But when I change all variables into binary integer form, there is no such error.

    what is wrong with my definition of variables? I want to define x[i][j] to be binary and y[i][j][k] to be continuous variables.

    Thanks,

        [i]typedef IloArray<IloNumVarArray> IloNumArray2;
        typedef IloArray<IloNumArray2> IloNumArray3;

    typedef IloArray<IloBoolVarArray> IloBoolArray2;

    //define binary integers x[i][j] with dimension N*N
            IloBoolArray2 x(env,N+1);
    for(i=1;i<=N;i++){<br /> x[i]=IloBoolVarArray(env,K+1);}

    //define continuous variables y[i][j][k] with dimension N*N*K
    IloNumArray3 y(env,N+1);
    for(i=1;i<=N;i++){<br /> y[i]=IloNumArray2(env,N+1);
    for(j=1;j<=N;j++){<br /> y[i][j]=IloNumVarArray(env,K+1);}}[/i]
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: How to deal with defining mixed integer programming?

    Posted 10/19/09 08:06 PM

    Originally posted by: SystemAdmin


    [prubin said:]

    For future reference, please avoid using subscript i -- the forum software thinks an i inside square brackets means "commence italics".

    [quote author=nfan link=topic=1417.msg3991#msg3991 date=1255961765]
    I used following codes in C++ to define high dimensional integer and continuous variables. However, I always got the error
    "Segmentation fault".

    But when I change all variables into binary integer form, there is no such error.

    what is wrong with my definition of variables? I want to define x[h][j] to be binary and y[h][j][k] to be continuous variables.

    Thanks,

        [i]typedef IloArray<IloNumVarArray> IloNumArray2;
        typedef IloArray<IloNumArray2> IloNumArray3;

    typedef IloArray<IloBoolVarArray> IloBoolArray2;

    //define binary integers x[h][j] with dimension N*N
            IloBoolArray2 x(env,N+1);
    for(h=1;h<=N;h++){<br /> x[h]=IloBoolVarArray(env,K+1);}

    //define continuous variables y[h][j][k] with dimension N*N*K
    IloNumArray3 y(env,N+1);
    for(h=1;h<=N;h++){<br /> y[h]=IloNumArray2(env,N+1);
    for(j=1;j<=N;j++){<br /> y[h][j]=IloNumVarArray(env,K+1);}}[/i]


    Do you get the seg fault in this block of code, or when you go to use y?  I note that you are leaving y[0] and y[h][0] undefined; I wonder if the seg fault is actually the result of a null pointer being used later?

    /Paul
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: How to deal with defining mixed integer programming?

    Posted 10/19/09 08:18 PM

    Originally posted by: SystemAdmin


    [nfan said:]

    The errors appear when I use y. Although I add y[0] and y[h][0] to be defined, which I actually never used in the following, the errors still appear when I use y in the following.

    But when I change y to be binary, the error does not appear. I want y to be continuous not binary.

    Thanks a lot,
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: How to deal with defining mixed integer programming?

    Posted 10/19/09 11:09 PM

    Originally posted by: SystemAdmin


    [nfan said:]

    Thanks. Finally I fixed this error by the following:

    IloNumArray2 x(env,N+1);
    for(h=0;h<=N;h++){<br /> x[h]=IloNumVarArray(env,K+1,0,1,ILOINT);}

    //define the decision variables y[h][j][k]
    IloNumArray3 y(env,N+1);
    for(h=0;h<=N;h++){<br /> y[h]=IloNumArray2(env,N+1);
    for(j=0;j<=N;j++){<br /> y[h][j]=IloNumVarArray(env,K+1,0,IloInfinity,ILOFLOAT);}}
    #CPLEXOptimizers
    #DecisionOptimization