Objeto que armazena uma restrição linear do formulário lower,
em que lower e upper são constantes, a(i) são coeficientes
constantes e x(i) são variáveis (desconhecidas).
O exemplo abaixo cria uma variável x com valores entre 0 e 5
e cria a restrição 0 ≤ 2 * x ≤ 5. Para isso, primeiro crie uma restrição
com o limite inferior 5 e o limite superior 5. O coeficiente da variável
x nessa restrição é definido como 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);
Métodos
| Método | Tipo de retorno | Breve descrição |
|---|---|---|
set | Linear | Define o coeficiente de uma variável na restrição. |
Documentação detalhada
set Coefficient(variableName, coefficient)
Define o coeficiente de uma variável na restrição. Por padrão, as variáveis têm um coeficiente de 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);
Parâmetros
| Nome | Tipo | Descrição |
|---|---|---|
variable | String | O nome da variável para a qual o coeficiente está sendo definido |
coefficient | Number | coeficiente sendo definido |
Retornar
Linear: essa restrição de otimização linear