Decision Optimization

Decision Optimization

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

 View Only
  • 1.  pbme de dimmension en c++ cplex

    Posted Sat April 16, 2016 10:50 AM

    Originally posted by: benzaid_yasmine@hotmail.fr


    Bonjour ya t'il quelqu'un qui pourra m'aider svp a voir pour quoi je peut pas afficher le deuxieme tableau

     

    #include<ilcplex/ilocplex.h>
    #include<iostream>
    #include<fstream>
    ILOSTLBEGIN

    typedef IloArray<IloNumArray> DataMatrix;
    typedef IloArray<IloNumArray> DataMatrix2;
    DataMatrix M;
    DataMatrix2 M2;
    IloInt n=2;

     


    void getData(const IloEnv, char filename[]){
    char char1,char2,char3,char4;
    int num,num1,num2;
    IloEnv env;
    ifstream file(filename);

        if(file){

            M=DataMatrix(env,n);
            M2=DataMatrix(env,n);

            file>>char2>>ws;
            cout<<"ici:"<<char2<<endl;

            if (char2=='E') {


           int k=-1;
            for(int i=1;i<=n;i++){

                        k++;
                M[k]=IloNumArray(env);


                for(int j=0;j<n;j++){
                    file>>num>>char2;


                     M[k].add(num);
                    }

            }

            }else {
                cout<<"il existe pas";
            }


            for(int i=2;i<6;i++){

           file>>char1;

           cout<<"ici:"<<char1<<endl;

           file>>num>>char2>>ws;
           cout<<num<<char2;
            }
    /*
            if (char1=='L') {


           int k=-1;
            for(int i=4;i<=6;i++){

                       k++;
                M2[k]=IloNumArray(env);


                for(int j=0;j<n;j++){
                    file>>num>>char2;


                    M2[k].add(num);
                    }

            }

            }else {
                cout<<"il existe pas";
            }

    */

     


            file.close();

        }
    }

      int main() {

        IloEnv env;

        getData(env,"steel.dat");


        cout<<"le tableau lu:"<<endl;

                for(int i=0;i<n;i++){
                   for(int j=0;j<n;j++){
                    cout<<"\t"<<M[i][j];
                   }
               cout<<endl;
                }
                cout<<endl;


                cout<<"le tableau 2 lu:"<<endl;

                        for(int i=0;i<n;i++){
                           for(int j=0;j<n;j++){
                            cout<<"\t"<<M2[i][j];
                           }
                       cout<<endl;
                        }
                        cout<<endl;


        env.end();

        return 0;

     

     

     


      }

     

     

    /*#include<ilcplex/ilocplex.h>
    #include<iostream>
    #include<fstream>
    ILOSTLBEGIN

    typedef IloArray<IloNumVarArray> IloNumVarArray2;

    int main(int argc,char **argv){

        IloEnv env;
        try{
             const char* filename="steel.dat";

            if(argc >= 2) filename = argv[1];
            ifstream file(filename);
            if(!file){
                cerr<<"no_sush_file"<<filename<<endl;
                throw(-1);

            }

           cerr<<"la lectur c'est tres bien passé"<<endl;
           cout<<endl;

            char char1, char2,char3, char4;
            IloInt n,p;


    IloNumVarArray2 E(env);
    //file>>n>>char1>>ws;
    file>>char1>>char2>>char3>>n>>char4>>ws;
    cout<<"char1:"<<char1<<endl;
    cout<<"char2:"<<char2<<endl;
    cout<<"n:"<<n<<endl;

    IloInt nPerso=E.getSize();

     

            for(p=0;p<nPerso;p++){
                E[p].add(IloNumVarArray(env,nPerso,0.0,IloInfinity));
            }

            file.close();

            cout<<"le tableau lu:"<<endl;

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

                cout<<E[i]<<endl;

            }
            cout<<endl;


        }catch(IloException& ex){
             cout<<"Error:"<<ex<<endl;
         }

    env.end();

    return 0;
        }

     


    */

    le data utiliser est

    E
    1,2|
    3,2|
    L
    5,2|
    3,9|

     

     

     

     

     

     

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: pbme de dimmension en c++ cplex

    Posted Mon April 18, 2016 04:42 AM

    Can you please describe in more detail (and in English) what you are trying to do and what the problem is?

    I understand that in getData() you are trying to parse the data file you pasted at the bottom but the code in getData() does not look like it would correctly parse a file with that structure.


    #CPLEXOptimizers
    #DecisionOptimization