Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Restriccióndeoptimizaciónlineal
Objeto que almacena una restricción lineal del tipo lowerBound ≤ Sum(a(i) x(i)) ≤ upperBound, en la que lowerBound y upperBound son constantes, a(i) son coeficientes constantes y x(i) son variables (incógnitas).
En el siguiente ejemplo, se crea una variable x con valores entre 0 y 5, y se crea la restricción 0 ≤ 2 * x ≤ 5. Para ello, primero debes crear una restricción con el límite inferior 5 y el límite superior 5. Luego, el coeficiente de la variable x en esta restricción se establece en 2.
constengine=LinearOptimizationService.createEngine();// Create a variable so we can add it to the constraintengine.addVariable('x',0,5);// Create a linear constraint with the bounds 0 and 10constconstraint=engine.addConstraint(0,10);// Set the coefficient of the variable in the constraint. The constraint is now:// 0 <= 2 * x <= 5constraint.setCoefficient('x',2);
Establece el coeficiente de una variable en la restricción.
Documentación detallada
setCoefficient(variableName, coefficient)
Establece el coeficiente de una variable en la restricción. De forma predeterminada, las variables tienen un coeficiente de 0.
constengine=LinearOptimizationService.createEngine();// Create a linear constraint with the bounds 0 and 10constconstraint=engine.addConstraint(0,10);// Create a variable so we can add it to the constraintengine.addVariable('x',0,5);// Set the coefficient of the variable in the constraint. The constraint is now:// 0 <= 2 * x <= 5constraint.setCoefficient('x',2);
Parámetros
Nombre
Tipo
Descripción
variableName
String
el nombre de la variable para la que se establece el coeficiente
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Falta la información que necesito","missingTheInformationINeed","thumb-down"],["Muy complicado o demasiados pasos","tooComplicatedTooManySteps","thumb-down"],["Desactualizado","outOfDate","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Problema con las muestras o los códigos","samplesCodeIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-07-26 (UTC)"],[[["\u003cp\u003e\u003ccode\u003eLinearOptimizationConstraint\u003c/code\u003e objects define constraints in the form of \u003ccode\u003elowerBound ≤ Sum(a(i) x(i)) ≤ upperBound\u003c/code\u003e, where \u003ccode\u003ea(i)\u003c/code\u003e are coefficients and \u003ccode\u003ex(i)\u003c/code\u003e are variables.\u003c/p\u003e\n"],["\u003cp\u003eYou can set the coefficient of a variable within a constraint using the \u003ccode\u003esetCoefficient(variableName, coefficient)\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eConstraints are created with lower and upper bounds, and variables are added with their own bounds before being incorporated into the constraint.\u003c/p\u003e\n"],["\u003cp\u003eThe provided code example demonstrates creating a variable, adding a constraint, and setting the coefficient for the variable within that constraint.\u003c/p\u003e\n"]]],[],null,[]]