Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Partially Initialized Array

    Posted 05/24/17 07:38 AM

    Originally posted by: Rohit_Sar


    Hi,

    So I'm writing an optimization code for Maximal Set Partitioning Problem in CPLEX Studio in OPlIDE. My code is as follows:

     execute PARAMS
    {

    cplex.nodefileind = 3;
    cplex.workmem = 15360; 
    //cplex.preind = 0; 
    cplex.epgap = 0.001; 

    }

    //Setting Constants and Bounds//

    int A_MAX = 29;//Number of Nodes//
    int N_MAX = 29179791;//Number of Sub-Graphs//
    int T = 10;//Threshold//
    int M = 10000000;//Big M//

    //Ranging Indices//

    range A = 1..A_MAX;//Set of Nodes//
    range N = 1..N_MAX;//Set of Sub-Graphs//

    //Creating Parameters//

    float D[A] = [10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10];//Demand in Node i//
    float S[A] = [10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10];//Supply in Node i//
    float X[N][A] = ...;//1 if Sub-Graph j contains Node i, 0 o/w //

    //Decision Variables//
    dvar boolean Y[N];

    maximize
       sum(j in N) Y[j];
            
            subject to
            {
            
             forall(i in A)
              {
              Constraint_1:
              sum(j in N)
                X[j][i]*Y[j] == 1;
             }            
             
             forall(j in N) 
              {
              Constraint_2:
              sum(i in A) (X[j][i])*(D[i]) - sum(i in A) X[j][i]*S[i] <= T + M*(1 - Y[j]); 
            }
                                     
             forall(j in N)
              {
              Constraint_3:
              sum(i in A) (X[j][i])*(D[i]) - sum(i in A)(X[j][i])*(S[i]) >= -T - M*(1 - Y[j]); 
            }                    
                 
          }         
                 
        execute{


      var ofile = new IloOplOutputFile("Results_Test.csv");
     
      ofile.writeln("Optimal objective value="+cplex.getObjValue());
      ofile.writeln("Optimal_variable_values");
      
      for(var j in thisOplModel.N) 
      {
      
      ofile.write("Y["+j+"]= "+thisOplModel.Y[j]+" ");
      ofile.writeln (" ");      
      
      }
      
      ofile.close();
      
    }  
     

    Array X holes binary ( 0 or 1) values and is a 29million X 29 matrix.

                    
    While running this warning is displayed:
    Array "X" partially initialized, expecting 29179791 items, found 4295775. 

     

    Please help.                 
                
                
              
              
              
              
              
              
       
            


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 2.  Re: Partially Initialized Array

    Posted 05/24/17 09:27 AM

    Hi,

    let me give you a small example to show you the meaning of that error.

    int X[1..2]=[1];

    execute
    {
    writeln(X);
    }

    subject to
    {
    }

    gives this warning


    Array "X" partially initialized, expecting 2 items, found 1.   

    whereas no wrning with

    int X[1..2]=[1,2];

    execute
    {
    writeln(X);
    }

    subject to
    {
    }

    regards

     

     

     


    #DecisionOptimization
    #OPLusingCPOptimizer