Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to access ilog decision variable from java?
    text
    copied!<p>I have a linear problem modelled in IBM ILOG CPLEX Optimization Studio, that returns correct solutions, i.e. objective values. For simulation purposes I use an ILOG model model file and a data file that I both call from java:</p> <pre><code>IloOplFactory.setDebugMode(false); IloOplFactory oplF = new IloOplFactory(); IloOplErrorHandler errHandler = oplF.createOplErrorHandler(System.out); IloOplModelSource modelSource = oplF.createOplModelSource("CDA_Welfare_Examination_sparse2.mod"); IloCplex cplex = oplF.createCplex(); IloOplSettings settings = oplF.createOplSettings(errHandler); IloOplModelDefinition def=oplF.createOplModelDefinition(modelSource,settings); IloOplModel opl=oplF.createOplModel(def,cplex); String inDataFile = path; IloOplDataSource dataSource=oplF.createOplDataSource(inDataFile); opl.addDataSource(dataSource); opl.generate(); opl.convertAllIntVars(); // converts integer bounds into LP compatible format if (cplex.solve()){ } else{ System.out.println("Solution could not be achieved, probably insufficient memory or some other weird problem."); } </code></pre> <p>Now, I would like to access the actual decision variable match[Matchable] from java.</p> <p>In ILOG CPLEX Optimization Studio I use the following nomenclatura:</p> <pre><code>tuple bidAsk{ int b; int a; } {bidAsk} Matchable = ...; dvar float match[Matchable]; </code></pre> <p>In Java I access the objective value in the following way (which works fine):</p> <pre><code>double sol = new Double(opl.getSolutionGetter().getObjValue()); </code></pre> <p>Now, how do I access the decision variable "match"? So far I have started with</p> <pre><code>IloOplElement dVarMatch = opl.getElement("match"); </code></pre> <p>but I can't seem to get any further. Help is very much appreciated! Thanks a lot!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload