Topic
  • 13 replies
  • Latest Post - ‏2013-05-13T19:52:11Z by AlexFleischer
82BF_AIT_HADDADENE_Syrine_Rouf
8 Posts

Pinned topic question Cplex studio OPL

‏2013-04-24T19:14:54Z |

Hello, I am a beginner, I'm working on Cplex in OPL Studio IDE? I have a problem which is that: when I run my program without the main function I get to see my solutions on the "browser problem" so it allows me to study well the achievements against when I add the function main I have not posted anything on the browser, I can only display the results on the console. Thank you for helping me;  

  • AlexFleischer
    AlexFleischer
    1248 Posts
    ACCEPTED ANSWER

    Re: question Cplex studio OPL

    ‏2013-04-28T08:51:45Z  

    Hi,

     

    are you sure that your model is feasible?

    In the problem browser do you see solution with objective x or relaxed solution ?

     

    regards

  • AlexFleischer
    AlexFleischer
    1248 Posts
    ACCEPTED ANSWER

    Re: question Cplex studio OPL

    ‏2013-04-28T11:36:31Z  

     

    thank you for your reply.
    Yes I am sure that the model is feasible because though nothing is displayed in the browser problems, I can see solutions on the console these are correct.

     

    I do not know if there is a command to add to the main function to display the solutions in the browser problems?
    Here is my main function

     

    main
    {  
        var opl = thisOplModel;
        var mod = opl.modelDefinition;
        var dat = opl.dataElements;
        var status = 0;
        
       var best;
       var curr = Infinity;
       while (best != curr) 
       {
            best=curr;
            // IloCplex() sert à résoudre a Mixed Integer Programming
            var cplex1 = new IloCplex();
            opl = new IloOplModel(mod,cplex1);
            opl.addDataSource(dat);
            opl.generate();
            if (!cplex1.solve()) {
                writeln("ERROR: could not solve");
                status = 1;
                opl.end();
                break;
            }   
            opl.postProcess();   
            curr = cplex1.getObjValue();
            writeln("Current solution : ", curr);
            writeln("Arcs Adjacents : ", opl.Adj);
            if (opl.newk!=0) 
            {
            dat.subtours.add(opl.newk, opl.newS);
            writeln("le sous tours existant : ", opl.subtours);
    opl.end();
    cplex1.end();
            }
            else
            {          
             writeln("y a rien à rajouter");
              opl.end();
              cplex1.end();
              break;      
           }      
      }    
        status;
    }
     

     

    regards.

    Hi

     

    so then what you could do to see the problem browser for each step is the following:

    use

    printExternalData

    at each iteration and then use the mod file and this generated dat file without any main block and then you will have access for sure to the problem browser

     

    I hope this helps

     

    regards

     

     

     

  • AlexFleischer
    AlexFleischer
    1248 Posts
    ACCEPTED ANSWER

    Re: question Cplex studio OPL

    ‏2013-05-03T16:39:37Z  

     

    Hi

    unfortunately,

    it does not work,

    I have the solutions displayed only on console,

     

    regards

    Hi

     

    indeed if you use plain write or writeln you will have the result in the console.

     

    But with an IloOplOutputFile you can write in dat files.

     

    1. 
      
      var ofile = new 
      
      
      IloOplOutputFile("mulprod_main.txt");
      
    2. Then you can write statements such as:
      
           ofile.writeln("Objective with capFlour = ", capFlour, " is ", curr);  
      

    I hope this helps

     

    Regards

     

    Alex Fleischer

  • AlexFleischer
    AlexFleischer
    1248 Posts
    ACCEPTED ANSWER

    Re: question Cplex studio OPL

    ‏2013-05-04T13:56:01Z  

    Hi

    Thank you for your reply,

    but my real concern is not that,
    because what I want is a good look at my results, I would to see something that looks like this "see navigateur.png"
      
    By cons, if I display my results with writeln either console or a txt file, I have something that looks like this "see console.png",
    and it is not easy to study.

     

    in fact, I have another question
    how can I tell it to generate some constraints, such as opl.generate () "I want it to generate only the first five constraints??

     

    Regards

     

    Hi,

     

    printExternalData will not write the result but the .dat and then running the .mod and the .dat in the IDE you will have access to the problem browser info, which is what you need.

    In your subject to constraints, you can use if in order to condition some constraints:

    subject to

    if (a==1) ct: x<=3;

     

    regards

     

  • AlexFleischer
    AlexFleischer
    1248 Posts

    Re: question Cplex studio OPL

    ‏2013-04-28T08:51:45Z  

    Hi,

     

    are you sure that your model is feasible?

    In the problem browser do you see solution with objective x or relaxed solution ?

     

    regards

  • 82BF_AIT_HADDADENE_Syrine_Rouf
    8 Posts

    Re: question Cplex studio OPL

    ‏2013-04-28T10:34:58Z  

    Hi,

     

    are you sure that your model is feasible?

    In the problem browser do you see solution with objective x or relaxed solution ?

     

    regards

     

    thank you for your reply.
    Yes I am sure that the model is feasible because though nothing is displayed in the browser problems, I can see solutions on the console these are correct.

     

    I do not know if there is a command to add to the main function to display the solutions in the browser problems?
    Here is my main function

     

    main
    {  
        var opl = thisOplModel;
        var mod = opl.modelDefinition;
        var dat = opl.dataElements;
        var status = 0;
        
       var best;
       var curr = Infinity;
       while (best != curr) 
       {
            best=curr;
            // IloCplex() sert à résoudre a Mixed Integer Programming
            var cplex1 = new IloCplex();
            opl = new IloOplModel(mod,cplex1);
            opl.addDataSource(dat);
            opl.generate();
            if (!cplex1.solve()) {
                writeln("ERROR: could not solve");
                status = 1;
                opl.end();
                break;
            }   
            opl.postProcess();   
            curr = cplex1.getObjValue();
            writeln("Current solution : ", curr);
            writeln("Arcs Adjacents : ", opl.Adj);
            if (opl.newk!=0) 
            {
            dat.subtours.add(opl.newk, opl.newS);
            writeln("le sous tours existant : ", opl.subtours);
    opl.end();
    cplex1.end();
            }
            else
            {          
             writeln("y a rien à rajouter");
              opl.end();
              cplex1.end();
              break;      
           }      
      }    
        status;
    }
     

     

    regards.

  • 82BF_AIT_HADDADENE_Syrine_Rouf
    8 Posts

    Re: question Cplex studio OPL

    ‏2013-04-28T10:35:36Z  

    Hi,

     

    are you sure that your model is feasible?

    In the problem browser do you see solution with objective x or relaxed solution ?

     

    regards

     

    thank you for your reply.
    Yes I am sure that the model is feasible because though nothing is displayed in the browser problems, I can see solutions on the console these are correct.

     

    I do not know if there is a command to add to the main function to display the solutions in the browser problems?
    Here is my main function

     

    main
    {  
        var opl = thisOplModel;
        var mod = opl.modelDefinition;
        var dat = opl.dataElements;
        var status = 0;
        
       var best;
       var curr = Infinity;
       while (best != curr) 
       {
            best=curr;
            // IloCplex() sert à résoudre a Mixed Integer Programming
            var cplex1 = new IloCplex();
            opl = new IloOplModel(mod,cplex1);
            opl.addDataSource(dat);
            opl.generate();
            if (!cplex1.solve()) {
                writeln("ERROR: could not solve");
                status = 1;
                opl.end();
                break;
            }   
            opl.postProcess();   
            curr = cplex1.getObjValue();
            writeln("Current solution : ", curr);
            writeln("Arcs Adjacents : ", opl.Adj);
            if (opl.newk!=0) 
            {
            dat.subtours.add(opl.newk, opl.newS);
            writeln("le sous tours existant : ", opl.subtours);
    opl.end();
    cplex1.end();
            }
            else
            {          
             writeln("y a rien à rajouter");
              opl.end();
              cplex1.end();
              break;      
           }      
      }    
        status;
    }
     

     

    regards.

  • AlexFleischer
    AlexFleischer
    1248 Posts

    Re: question Cplex studio OPL

    ‏2013-04-28T11:36:31Z  

     

    thank you for your reply.
    Yes I am sure that the model is feasible because though nothing is displayed in the browser problems, I can see solutions on the console these are correct.

     

    I do not know if there is a command to add to the main function to display the solutions in the browser problems?
    Here is my main function

     

    main
    {  
        var opl = thisOplModel;
        var mod = opl.modelDefinition;
        var dat = opl.dataElements;
        var status = 0;
        
       var best;
       var curr = Infinity;
       while (best != curr) 
       {
            best=curr;
            // IloCplex() sert à résoudre a Mixed Integer Programming
            var cplex1 = new IloCplex();
            opl = new IloOplModel(mod,cplex1);
            opl.addDataSource(dat);
            opl.generate();
            if (!cplex1.solve()) {
                writeln("ERROR: could not solve");
                status = 1;
                opl.end();
                break;
            }   
            opl.postProcess();   
            curr = cplex1.getObjValue();
            writeln("Current solution : ", curr);
            writeln("Arcs Adjacents : ", opl.Adj);
            if (opl.newk!=0) 
            {
            dat.subtours.add(opl.newk, opl.newS);
            writeln("le sous tours existant : ", opl.subtours);
    opl.end();
    cplex1.end();
            }
            else
            {          
             writeln("y a rien à rajouter");
              opl.end();
              cplex1.end();
              break;      
           }      
      }    
        status;
    }
     

     

    regards.

    Hi

     

    so then what you could do to see the problem browser for each step is the following:

    use

    printExternalData

    at each iteration and then use the mod file and this generated dat file without any main block and then you will have access for sure to the problem browser

     

    I hope this helps

     

    regards

     

     

     

  • 82BF_AIT_HADDADENE_Syrine_Rouf
    8 Posts

    Re: question Cplex studio OPL

    ‏2013-04-28T13:07:45Z  

    I will try

    thank you

  • 82BF_AIT_HADDADENE_Syrine_Rouf
    8 Posts

    Re: question Cplex studio OPL

    ‏2013-05-03T16:00:13Z  

    Hi

     

    so then what you could do to see the problem browser for each step is the following:

    use

    printExternalData

    at each iteration and then use the mod file and this generated dat file without any main block and then you will have access for sure to the problem browser

     

    I hope this helps

     

    regards

     

     

     

     

    Hi

    unfortunately,

    it does not work,

    I have the solutions displayed only on console,

     

    regards

  • AlexFleischer
    AlexFleischer
    1248 Posts

    Re: question Cplex studio OPL

    ‏2013-05-03T16:39:37Z  

     

    Hi

    unfortunately,

    it does not work,

    I have the solutions displayed only on console,

     

    regards

    Hi

     

    indeed if you use plain write or writeln you will have the result in the console.

     

    But with an IloOplOutputFile you can write in dat files.

     

    1. 
      
      var ofile = new 
      
      
      IloOplOutputFile("mulprod_main.txt");
      
    2. Then you can write statements such as:
      
           ofile.writeln("Objective with capFlour = ", capFlour, " is ", curr);  
      

    I hope this helps

     

    Regards

     

    Alex Fleischer

  • 82BF_AIT_HADDADENE_Syrine_Rouf
    8 Posts

    Re: question Cplex studio OPL

    ‏2013-05-04T12:23:17Z  

    Hi

     

    indeed if you use plain write or writeln you will have the result in the console.

     

    But with an IloOplOutputFile you can write in dat files.

     

    1. <pre class="pre codeblock"> var ofile = new IloOplOutputFile("mulprod_main.txt"); </pre>
    2. Then you can write statements such as: <pre class="pre codeblock"> ofile.writeln("Objective with capFlour = ", capFlour, " is ", curr); </pre>

    I hope this helps

     

    Regards

     

    Alex Fleischer

    Hi

    Thank you for your reply,

    but my real concern is not that,
    because what I want is a good look at my results, I would to see something that looks like this "see navigateur.png"
      
    By cons, if I display my results with writeln either console or a txt file, I have something that looks like this "see console.png",
    and it is not easy to study.

     

    in fact, I have another question
    how can I tell it to generate some constraints, such as opl.generate () "I want it to generate only the first five constraints??

     

    Regards

     

  • AlexFleischer
    AlexFleischer
    1248 Posts

    Re: question Cplex studio OPL

    ‏2013-05-04T13:56:01Z  

    Hi

    Thank you for your reply,

    but my real concern is not that,
    because what I want is a good look at my results, I would to see something that looks like this "see navigateur.png"
      
    By cons, if I display my results with writeln either console or a txt file, I have something that looks like this "see console.png",
    and it is not easy to study.

     

    in fact, I have another question
    how can I tell it to generate some constraints, such as opl.generate () "I want it to generate only the first five constraints??

     

    Regards

     

    Hi,

     

    printExternalData will not write the result but the .dat and then running the .mod and the .dat in the IDE you will have access to the problem browser info, which is what you need.

    In your subject to constraints, you can use if in order to condition some constraints:

    subject to

    if (a==1) ct: x<=3;

     

    regards

     

  • 82BF_AIT_HADDADENE_Syrine_Rouf
    8 Posts

    Re: question Cplex studio OPL

    ‏2013-05-07T10:31:53Z  

    Hi,

     

    printExternalData will not write the result but the .dat and then running the .mod and the .dat in the IDE you will have access to the problem browser info, which is what you need.

    In your subject to constraints, you can use if in order to condition some constraints:

    subject to

    if (a==1) ct: x<=3;

     

    regards

     

     

    Hello,
    I have a problem with my Oplide, I can not open it,
    I was working normally, and then I put my computer to sleep and resuming it he said : une erreur est survenue, Reportez vous au fichier journal???
    thanks.
  • AlexFleischer
    AlexFleischer
    1248 Posts

    Re: question Cplex studio OPL

    ‏2013-05-13T08:47:54Z  

     

    Hello,
    I have a problem with my Oplide, I can not open it,
    I was working normally, and then I put my computer to sleep and resuming it he said : une erreur est survenue, Reportez vous au fichier journal???
    thanks.

    Hi

     

    have tou tried oplide -clean in the command line ?

    regards

  • 82BF_AIT_HADDADENE_Syrine_Rouf
    8 Posts

    Re: question Cplex studio OPL

    ‏2013-05-13T14:13:08Z  

    Hi,

     

    printExternalData will not write the result but the .dat and then running the .mod and the .dat in the IDE you will have access to the problem browser info, which is what you need.

    In your subject to constraints, you can use if in order to condition some constraints:

    subject to

    if (a==1) ct: x<=3;

     

    regards

     

     

    Hello, 

     

    Please, I still have the same concern compared to the display in the browser problem, except that this time, I can see the browser, but it gives me no value while a solution is displayed in the console. 

    thanks.

    Attachments

  • AlexFleischer
    AlexFleischer
    1248 Posts

    Re: question Cplex studio OPL

    ‏2013-05-13T19:52:11Z  

     

    Hello, 

     

    Please, I still have the same concern compared to the display in the browser problem, except that this time, I can see the browser, but it gives me no value while a solution is displayed in the console. 

    thanks.

    You see solutions in the problem browser when you do not have a main.

     

    regards