كائن يخزِّن قيدًا خطيًا بالصيغة lowerBound ≤ Sum(a(i) x(i)) ≤ upperBound
حيث يكون lowerBound
وupperBound
هما ثابتان، وa(i)
هما معاملان
ثابتون وx(i)
هما متغيّرات (غير معروفة).
ينشئ المثال أدناه متغيرًا واحدًا x
بقيم بين 0
و5
وينشئ القيد 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);
الطُرق
الطريقة | نوع القيمة التي يتم إرجاعها | وصف قصير |
---|---|---|
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);
المَعلمات
الاسم | Type | الوصف |
---|---|---|
variableName | String | اسم المتغير الذي يتم تعيين المُعامل له |
coefficient | Number | المُعامل الذي يتم تعيينه |
استرجاع الكرة
LinearOptimizationConstraint
- قيد التحسين الخطي هذا