lower
形式の線形制約を格納するオブジェクト。ここで、lower
と upper
は定数、a(i)
は定数係数、x(i)
は変数(未知数)です。
次の例では、0
~5
の値を持つ変数 x
を 1 つ作成し、制約 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 | 設定される係数 |
戻る
Linear
- この線形最適化制約