次の例では、0~5 の値を持つ変数 x を 1 つ作成し、制約 0 ≤ 2 * x ≤ 5 を作成します。これを行うには、まず下限 5 と上限 5 の制約を作成します。次に、この制約の変数 x の係数は 2 に設定されます。
constengine=LinearOptimizationService.createEngine();// Create a variable so we can add it to the constraintengine.addVariable('x',0,5);// Create a linear constraint with the bounds 0 and 10constconstraint=engine.addConstraint(0,10);// Set the coefficient of the variable in the constraint. The constraint is now:// 0 <= 2 * x <= 5constraint.setCoefficient('x',2);
constengine=LinearOptimizationService.createEngine();// Create a linear constraint with the bounds 0 and 10constconstraint=engine.addConstraint(0,10);// Create a variable so we can add it to the constraintengine.addVariable('x',0,5);// Set the coefficient of the variable in the constraint. The constraint is now:// 0 <= 2 * x <= 5constraint.setCoefficient('x',2);
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2024-12-22 UTC。"],[[["`LinearOptimizationConstraint` objects define constraints in the form of `lowerBound ≤ Sum(a(i) x(i)) ≤ upperBound`, where `a(i)` are coefficients and `x(i)` are variables."],["You can set the coefficient of a variable within a constraint using the `setCoefficient(variableName, coefficient)` method."],["Constraints are created with lower and upper bounds, and variables are added with their own bounds before being incorporated into the constraint."],["The provided code example demonstrates creating a variable, adding a constraint, and setting the coefficient for the variable within that constraint."]]],[]]