Decision Optimization

Decision Optimization

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

 View Only
  • 1.  writeln() shows [aIloNumVar]

    Posted Tue February 28, 2012 03:29 PM

    Originally posted by: MSaqib


    Hi everyone
    I have written a main script in my OPL model file. It's purpose is to invoke the model with different data values over an over in a loop. Furthermore, I'm trying to do some fine tuning based on the results of the optimization. My model defines a variable:

    
    dvar 
    
    boolean bootup[AVAIL_LOCATIONS][PUREINTERVALS];
    


    that is, a two dimensional decision variable array. After the solver has found a solution, I am trying to write the value of this array to a file.

    
    
    
    if (cplex.solve()) 
    { 
    
    for(var q = 1 ; q <= rb1.interval_size ; q++) 
    { var filename = 
    "planned" + o + 
    "." + i + 
    "." + q + 
    ".dat"; var planfile = 
    
    new IloOplOutputFile(filename); planfile.write(
    "INIT_WORKLOAD=["); 
    
    for(var p = 1 ; p <= rb1.availLocations ; p++) planfile.write(rb1.x[p][q] + 
    " " ); planfile.write(
    "];"); planfile.close(); 
    } 
    
    for(k = 1 ; k <= o ; k++) 
    { f1.write(
    "INIT_BOOTUP=["); 
    
    for (dabba = 1 ; dabba <= rb1.availLocations ; dabba++) 
    { f1.write(rb1.bootup[dabba][k]); f1.write(
    " "); 
    } f1.writeln(
    "];"); 
    } f1.close(); 
    }
    


    What I get in the file is a line like this:

    
    INIT_BOOTUP=[[a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] [a IloNumVar] ];
    


    What does
    
    [a IloNumVar]
    
    mean? I have tried a number of things but to no avail. Done web searches as well as looked through the documentation but didn't find anything. I'm attaching the model file with this post.
    Thanks in advance for the help.
    Best regards
    Saqib
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: writeln() shows [aIloNumVar]

    Posted Wed February 29, 2012 11:54 AM
    Hi,

    a reason why you get this IloNumVar may be the fact that you did not solve your model.

    For example

    dvar float+ Gas;
    dvar float+ Chloride;
     
    maximize
      40 * Gas + 50 * Chloride;
    subject to {
      ctMaxTotal:     
        Gas + Chloride <= 50;
    }
     
    main
    {
     thisOplModel.generate();
     //cplex.solve();
     writeln(thisOplModel.Chloride);
     }
    


    gives

    [IloNumVar]
    


    whereas if you uncomment cplex.solve you'll get the real value

    Regards
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: writeln() shows [aIloNumVar]

    Posted Wed February 29, 2012 11:54 AM
    Hi,

    a reason why you get this IloNumVar may be the fact that you did not solve your model.

    For example

    dvar float+ Gas;
    dvar float+ Chloride;
     
    maximize
      40 * Gas + 50 * Chloride;
    subject to {
      ctMaxTotal:     
        Gas + Chloride <= 50;
    }
     
    main
    {
     thisOplModel.generate();
     //cplex.solve();
     writeln(thisOplModel.Chloride);
     }
    


    gives

    [IloNumVar]
    


    whereas if you uncomment cplex.solve you'll get the real value

    Regards
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: writeln() shows [aIloNumVar]

    Posted Wed February 29, 2012 12:15 PM

    Originally posted by: MSaqib


    Thanks for the reply Alex. However, if you notice, I have called cplex.solve on the model prior to trying to access the model variables. One thing that I noticed is that in the for loop involving the variable k, the first time through the loop, I get the expected real values, but the second time through the loop, when k = 2, I get those strange values for
    bootup[dabba][k]
    


    Any other clues?
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: writeln() shows [aIloNumVar]

    Posted Wed February 29, 2012 12:56 PM
    Hi

    and what happens if you replace

    f1.write(rb1.bootup[dabba][k]);
    


    by

    f1.write(rb1.bootup[dabba][k].solutionValue);
    


    ?

    Regards
    #DecisionOptimization
    #OPLusingCPLEXOptimizer