Objek yang menyimpan batasan linear dalam bentuk lower
dengan lower dan upper adalah konstanta, a(i) adalah koefisien
konstanta, dan x(i) adalah variabel (tidak diketahui).
Contoh di bawah membuat satu variabel x dengan nilai antara 0 dan 5
dan membuat batasan 0 ≤ 2 * x ≤ 5. Hal ini dilakukan dengan membuat batasan terlebih dahulu
dengan batas bawah 5 dan batas atas 5. Kemudian, koefisien untuk variabel
x dalam batasan ini ditetapkan ke 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);
Metode
| Metode | Jenis hasil yang ditampilkan | Deskripsi singkat |
|---|---|---|
set | Linear | Menetapkan koefisien variabel dalam batasan. |
Dokumentasi mendetail
set Coefficient(variableName, coefficient)
Menetapkan koefisien variabel dalam batasan. Secara default, variabel memiliki koefisien 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);
Parameter
| Nama | Jenis | Deskripsi |
|---|---|---|
variable | String | nama variabel yang koefisiennya ditetapkan |
coefficient | Number | koefisien yang ditetapkan |
Pulang pergi
Linear — batasan pengoptimalan linear ini