شیء ذخیره کننده یک محدودیت خطی به شکل 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 Coefficient(variableName, coefficient) | Linear Optimization Constraint | ضریب یک متغیر در محدودیت را تنظیم میکند. |
مستندات دقیق
setCoefficient(variableName, coefficient)
ضریب یک متغیر در محدودیت را تنظیم میکند. به طور پیشفرض، متغیرها ضریب ۰ دارند.
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 | ضریب در حال تنظیم |
بازگشت
LinearOptimizationConstraint - این قید بهینهسازی خطی