Decision Optimization

Decision Optimization

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

 View Only
  • 1.  main function

    Posted Thu September 22, 2011 06:01 PM

    Originally posted by: vplus


    Hi,
    I am a newbie, sorry if this question seems to be too easy for you.
    I am writing a model with column generation. In the main function, I put something like (which is very standard):
    function printSolution(){
    }    
     
    minimize ...;
     
    main {
        ...
        thisOplModel.generate();
        var Data = thisOplModel.dataElements;
        var masterDef = thisOplModel.modelDefinition;
        var masterCplex = cplex;
     
        while (true) {
            var masterOpl = new IloOplModel(masterDef, masterCplex);
            masterOpl.addDataSource(Data);
            masterOpl.generate();
            // blah blah blah
     
            // If found a solution, then print it
            printSolution();
        }
    }
    


    Which puzzles me is that , the function
    printSolution()
    
    should need an input - this case would be masterOpl - to print the result correctly. However, without the input, it still works. Maybe it's because main function is in the master.mod file, but it's not very clear since the object masterOpl is created several times italics inside italics the
    main
    
    .

    Thanks.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: main function

    Posted Thu September 22, 2011 06:59 PM

    Originally posted by: SystemAdmin


    Within OPL scripts, the IloOplModel object has an inbuilt function called 'printSolution()' that prints the current values of the decision variables in the model.

    You seem to be overriding this function call in your code which may be the cause for the behavior. If you were to change your function name from :

    function printSolution(){
    }

    to

    function printOPLSolution(){
    }

    then I would think that this call would definitely require an IloOplModel instance for its invocation and not work if you were to call it without one.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: main function

    Posted Fri September 23, 2011 10:52 AM

    Originally posted by: vplus


    Thank AbhishekRaman.
    I changed the name of the function, and it still works.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer