Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Error using different .dat files

    Posted 08/24/19 05:21 AM

    Originally posted by: Paroth2


    So i have a simple linear program written in my .mod file. However, i want to use different input parameters (+10%, +20% etc...) for each run. The .dat files are all identical except the changed parameters. I used an example from this forum and added the main block into my .mod (see below) to solve these instances, however i am getting an error that .datfiles is not available. I also tried to put it into a separate mod, but still without success. I would appreciate any help.

     

    {string} datFiles={"+10% N.dat","+20% N.dat"};
    main{
    var src = new IloOplModelSource("Fall 2_NP.mod");
    var cplex = new IloCplex();
    var def = new IloOplModelDefinition(src);
        for(var datFile in thisOplModel.datFiles){
            var opl = new IloOplModel(def, cplex);    
            var data = new IloOplDataSource(datFile);
            opl.addDataSource(data);
            var details=opl.dataElements;
            opl.generate();
            if(cplex.solve()){
            writeln("Gesamtkosten =" + cplex.getObjValue());}
            else{
                writeln("No Solution");}
    }}

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Error using different .dat files

    Posted 08/26/19 04:52 AM

    Hi,

    if I run

    {string} datFiles={"+10% N.dat","+20% N.dat"};
    main{
    var src = new IloOplModelSource("Fall 2_NP.mod");
    var cplex = new IloCplex();
    var def = new IloOplModelDefinition(src);
        for(var datFile in thisOplModel.datFiles){
            var opl = new IloOplModel(def, cplex);    
            var data = new IloOplDataSource(datFile);
            opl.addDataSource(data);
            var details=opl.dataElements;
            opl.generate();
            if(cplex.solve()){
            writeln("Gesamtkosten =" + cplex.getObjValue());}
            else{
                writeln("No Solution");}
    }}

    with .mod

    int maxOfX=...;
     
     dvar int x;
     maximize x;
     subject to
     {
     x==maxOfX;
     }

    and .dat

    maxOfX=10;

    and

    maxOfX=20;

    I get

     

    Gesamtkosten =10
    Gesamtkosten =20

    regards

     

    https://www.linkedin.com/pulse/making-decision-optimization-simple-alex-fleischer/


    #DecisionOptimization
    #OPLusingCPLEXOptimizer