אובייקט שמאחסן אילוץ לינארי בצורה lower, כאשר lower ו-upper הם קבועים, a(i) הם מקדם קבועים ו-x(i) הם משתנים (לא ידועים).
בדוגמה הבאה נוצר משתנה אחד x עם ערכים בין 0 ל-5, ויוצרים את האילוץ 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);
Methods
| שיטה | סוג הערך המוחזר | תיאור קצר |
|---|---|---|
set | Linear | הגדרת המקדם של משתנה באילוץ. |
מסמכים מפורטים
set Coefficient(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 – האילוץ הזה של אופטימיזציה לינארית