Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  multi dimensional array in cplex c++ concert tech

    Posted 01/26/16 12:28 AM

    Originally posted by: Girish Dey


    Hi...

     I am trying to create a boolean matrix in c++ concert technology. I have defined 
    typedef IloArray<IloBoolArray> BoolMatrix;
    after that I declared it:
    BoolMatrix Assigned(env);
    but while trying input data by file >> Assigned, it is showing error (no operator ">>" matches these operands). Please help me to come out of this error.


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: multi dimensional array in cplex c++ concert tech

    Posted 01/27/16 06:38 AM

    You can use the undocumented macro ILOARRAY_INPUT_OPERATOR to allow this sort of input (note that bools are provided as "0" and "1", not "false" and "true"):

    #include <sstream>
    #include <iostream>
    #include <ilcplex/ilocplex.h>
    
    ILOARRAY_INPUT_OPERATOR(IloBoolArray, IloArray<IloBoolArray>)
    
    int
    main(void)
    {
       std::stringstream ints("[1,2,3,4,5]");
       std::stringstream ints2D("[[1,2,3,4,5],[6,7,8,9]]");
       std::stringstream bools("[1,1,0,1,0]");
       std::stringstream bools2D("[[1,1,0,1,0],[0,1,0]]");
    
       IloEnv env;
       IloIntArray intArray(env);
       ints >> intArray;
       std::cout << intArray << std::endl;
    
       IloArray<IloIntArray> intArray2D(env);
       ints2D >> intArray2D;
       std::cout << intArray2D << std::endl;
    
       IloBoolArray boolArray(env);
       bools >> boolArray;
       std::cout << boolArray << std::endl;
    
       IloArray<IloBoolArray> boolArray2D(env);
       bools2D >> boolArray2D;
       std::cout << boolArray2D << std::endl;
    
       env.end();
       return 0;
    }
    

     


    #CPLEXOptimizers
    #DecisionOptimization