Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Multidimensional Array

    Posted Wed June 14, 2017 04:08 AM

    Originally posted by: JodokusQuak


    Hello guys,
     

    short introdcution:

    - Implementation of an optimisation model

    - CPLEX implemented in C++

    - Apple XCode

    I've got some problems with the multidimensional parameters (arrays) I have to implement - see attached file. Right now they are all one-dimensional but some of them are actually multidimensional (2-4 dimensions). For example I've got the parameter for the travel time - t_travel[v][i][j] - which one i wanna to implement. I tried out:

     

        IloArray<IloArray<IloIntArray> > t_travel(env, V);                  

        for (int v = 0; v < V; v++){

            

            t_travel[v] = IloArray<IloIntArray> (env, I);

            

            for (int i = 0; i < I; i++){

                

                t_travel[v][i] = IloIntArray (env, I);

            }

        }

     

    But the error which occurs is "invalid use of incomplete type 'IloArray<IloIntArray>'. Does anybody know what to do? 

    And I think I will have more questions in the next few days/weeks for my implementation. Is it better if I start every time a new topic?


    Regards


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Multidimensional Array

    Posted Wed June 14, 2017 04:18 AM

    The following code compiles without any issue here:

    #include <ilcplex/ilocplex.h>
    
    int
    main(void)
    {
       IloInt V = 2;
       IloInt I = 3;
    
       IloEnv env;
       IloArray<IloArray<IloIntArray> > t_travel(env, V);                  
    
       for (int v = 0; v < V; v++){
          t_travel[v] = IloArray<IloIntArray> (env, I);
          for (int i = 0; i < I; i++){
             t_travel[v][i] = IloIntArray (env, I);
          }
       }
       return 0;
    }
    

    Can you please provide a full example code (as small as possible) that reproduces the error. Also, are you sure that the error message you reported is the first error? Maybe there are earlier errors like header files not found (which would explain the unknown types)?


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Multidimensional Array

    Posted Wed June 14, 2017 04:39 AM

    Originally posted by: JodokusQuak


    The lines in bold are the first errors.

    #include
    <iostream>                      

    #include<ilcplex/ilocplex.h>            

    #include<fstream>                       

    #include<iomanip>                      

    #include<time.h>                        

     

    using namespace std;

     

    int main() {                            

        

        /*definition of the environment & the model*/

        IloEnv env;

        IloModel model(env);

        

        /*********************************************************************************************************************************************

         *1. data

         *********************************************************************************************************************************************/

        

        /*1.1 import data*/

        ifstream myfile("folder_path");

        if (!myfile) {

            cout << "nothing was found" << endl;

            system("break");

            return 1;

        }

        

        /*1.2 Sets*/

        IloInt B;                          

        IloInt V;                           

        IloInt V_b;                         

        IloInt F;                          

        IloInt A;                         

        IloInt A_f;                         

        IloInt A_v;                         

        IloInt T;                           

        IloInt P;                           

        IloInt I;                           

        

        

        /*1.3 parameters*/

        IloIntArray t_penalty(env);         

        IloIntArray n_tech(env);           

        IloIntArray n_techatbase(env);      

        IloIntArray n_techcap(env);        

        IloIntArray speed(env);             

        IloIntArray b_service(env);         

        IloIntArray v_available(env);     

        IloIntArray v_skill(env);          

        IloIntArray parts_available(env);   

        

        IloFloatArray t_work(env);          

        IloFloatArray t_transfer(env);     

        IloFloatArray w_spareparts(env);    

        IloFloatArray c_tech(env);          

        IloFloatArray c_penalty(env);       

        IloFloatArray w_sparepartscap(env); 

        IloFloatArray c_fuel(env);          

        IloFloatArray t_weather(env);       

        IloFloatArray c_route(env);         

        

        /*1.4 assign parameters to data*/

        myfile >> B;

        myfile >> V;

        myfile >> V_b;

        myfile >> F;

        myfile >> A;

        myfile >> A_f;

        myfile >> A_v;

        myfile >> T;

        myfile >> P;

        myfile >> I;

        

        myfile >> t_penalty;

        myfile >> n_tech;

        myfile >> n_techatbase;

        myfile >> n_techcap;

        myfile >> speed;

        myfile >> b_service;

        myfile >> v_available;

        myfile >> v_skill;

        myfile >> parts_available;

        

        myfile >> t_work;

        myfile >> t_transfer;

        myfile >> w_spareparts;

        myfile >> c_tech;

        myfile >> c_penalty;

        myfile >> w_sparepartscap;

        myfile >> c_fuel;

        myfile >> t_weather;

        myfile >> c_route;

        

       

        /*1.5 t_travel[v][i][j]*/

        

        IloArray<IloArray<IloIntArray> > t_travel(env, V);                  

        for (int v = 0; v < V; v++){

            

            t_travel[v] = IloArray<IloIntArray> (env, I);  //invalid use of incomplete type 'IloArray<IloIntArray>'

            

            for (int i = 0; i < I; i++){                                     

                

                t_travel[v][i] = IloIntArray (env, I);     //Type 'IloArray<IloIntArray>' does not provide a subscript operator

            }

        }

     

        return 0;

    }


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Multidimensional Array

    Posted Wed June 14, 2017 05:28 AM

    Originally posted by: JodokusQuak


    Same Problem when I give these parameters fixed values like you above. 


    #CPLEXOptimizers
    #DecisionOptimization