Re: Error using different .dat files

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/

Source: Re: Error using different .dat files