عنصر يخزّن قيدًا خطيًا بالشكل lowerBound ≤ Sum(a(i) x(i)) ≤ upperBound
حيث lowerBound وupperBound ثابتان، و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);
الطُرق
| الطريقة | نوع القيمة التي تم إرجاعها | وصف قصير |
|---|---|---|
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: هذا القيد الخاص بالتحسين الخطي