lowerBound ≤ Sum(a(i) x(i)) ≤ upperBound
という形式の線形制約を格納するオブジェクト。ここで、lowerBound
と upperBound
は定数、a(i)
は定数係数、x(i)
は変数(不明)です。
次の例では、0
~5
の値を持つ変数 x
を 1 つ作成し、制約 0 ≤ 2 * x ≤ 5
を作成しています。これを行うには、まず下限の 5
と上限の 5
を使用して制約を作成します。次に、この制約の変数 x
の係数が 2
に設定されます。
var 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 var 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);
Methods
メソッド | 戻り値の型 | 概要 |
---|---|---|
setCoefficient(variableName, coefficient) | LinearOptimizationConstraint | 制約に含まれる変数の係数を設定します。 |
詳細なドキュメント
setCoefficient(variableName, coefficient)
制約に含まれる変数の係数を設定します。デフォルトでは、変数の係数は 0 です。
var engine = LinearOptimizationService.createEngine(); // Create a linear constraint with the bounds 0 and 10 var 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);
パラメータ
名前 | 型 | 説明 |
---|---|---|
variableName | String | 係数を設定する変数の名前 |
coefficient | Number | 係数が設定されます。 |
リターン
LinearOptimizationConstraint
- この線形最適化制約