lowerBound と upperBound が定数、a(i) が定数係数、x(i) が変数(未知数)である lowerBound ≤ Sum(a(i) x(i)) ≤ upperBound 形式の線形制約を格納するオブジェクト。
次の例では、0~5 の値を持つ 1 つの変数 x を作成し、制約 0 ≤ 2 * x ≤ 5 を作成します。これを行うには、まず下限 5 と上限 5 を持つ制約を作成します。この制約の変数 x の係数が 2 に設定されます。
const engine = LinearOptimizationService.createEngine(); // Create a variable so we can add it to the constraint engine.addVariable('x', 0, 5); // Create a linear constraint with the bounds 0 and 10 const constraint = engine.addConstraint(0, 10); // Set the coefficient of the variable in the constraint. The constraint is now: // 0 <= 2 * x <= 5 constraint.setCoefficient('x', 2);
メソッド
| メソッド | 戻り値の型 | 概要 |
|---|---|---|
set | Linear | 制約内の変数の係数を設定します。 |
詳細なドキュメント
setCoefficient(variableName, coefficient)
制約内の変数の係数を設定します。デフォルトでは、変数の係数は 0 です。
const engine = LinearOptimizationService.createEngine(); // Create a linear constraint with the bounds 0 and 10 const constraint = engine.addConstraint(0, 10); // Create a variable so we can add it to the constraint engine.addVariable('x', 0, 5); // Set the coefficient of the variable in the constraint. The constraint is now: // 0 <= 2 * x <= 5 constraint.setCoefficient('x', 2);
パラメータ
| 名前 | タイプ | 説明 |
|---|---|---|
variable | String | 係数が設定されている変数の名前 |
coefficient | Number | 係数が設定されている |
戻る
LinearOptimizationConstraint - この線形最適化制約