Class LinearOptimizationConstraint

محدودیت بهینه سازی خطی

شی ذخیره‌سازی یک محدودیت خطی به شکل lower Bound ≤ Sum(a(i) x(i)) ≤ upperBound که در آن lower Bound و upper Bound ثابت هستند، 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 Coefficient(variableName, coefficient) Linear Optimization Constraint ضریب یک متغیر را در محدودیت تنظیم می کند.

مستندات دقیق

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 Name String نام متغیری که ضریب برای آن تنظیم می شود
coefficient Number ضریب در حال تعیین

بازگشت

Linear Optimization Constraint - این محدودیت بهینه سازی خطی