5

CPLEXJavaAPIを使用して大規模な最適化問題を解決しています。現在私はただ

IloCplex cplex = new IloCplex();
... add lots of variables and constraints ...
cplex.solve();
cplex.end();

これはうまく機能しますが、係数を変更するだけの場合は、このプロセスを頻繁に繰り返します。繰り返すたびに、新しいcplexオブジェクトを作成し、すべての変数を再作成します。

これを行うためのより効率的な方法はありますか?IBMのドキュメントには、「モデルをモデルのインスタンスに追加する」などの言葉があり、奇妙に聞こえますが、それは物事を再利用できることを示唆していると思いました。

より経験豊富なユーザーからの提案は素晴らしいでしょう。ありがとう。

4

1 に答える 1

7

制約の係数(または目的関数の係数)を変更したいだけの場合は、既存のIloCplexオブジェクトの係数を変更できます。モデルを最初から作成しないでください。

retval = cplex.solve();
// verify that the solve was successful

// change coeficients on constraints (or in the objective)
cplex.setLinearCoef(constraint, newCoef, variable);
cplex.setLinearCoef(objective, newObjCoef, variable);

// change right bounds on constraints
constraint.setBounds(newLB, newUB);

// change variable bounds
var.setBounds(newLB, newUB);

retval = cplex.solve();
// verify the solve
于 2012-04-13T05:06:56.687 に答える