Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a MIP model in CPLEX. I try to use a heuristic algorithm with using flow control. I need to use multiple ".dat" files and get the decision variables solution value in each time I solve the problem. I tried to used "addDataSource" but I have got no solution available error. When I try to solve without "addDataSource" I do not get this error. How can I handle with this problem.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
4.0k views
Welcome To Ask or Share your Answers For Others

1 Answer

see several dat files in

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

{string} datFiles={"zoodat.dat","zoodat2.dat"};
    
    main
    {
      var source = new IloOplModelSource("zoodat.mod");
      var cplex = new IloCplex();
      var def = new IloOplModelDefinition(source);
     
      for(datFile in thisOplModel.datFiles)
      {
         writeln("with ",datFile);
         var opl1 = new IloOplModel(def,cplex);
         var data1=new IloOplDataSource(datFile);
          opl1.addDataSource(data1);
        
          opl1.generate();
          cplex.solve();
          opl1.postProcess();
          writeln();
   

        }

 }
 
 /*
 
 which gives
 
 with zoodat.dat
The minimum cost is 380
We will use 6 40 seats buses and 2 30 seats buses 
with zoodat2.dat
The minimum cost is 500
We will use 10 40 seats buses and 0 30 seats buses 
*/ 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...