lower 형식의 선형 제약 조건을 저장하는 객체입니다. 여기서 lower 및 upper는 상수이고, a(i)는 상수 계수이며, x(i)는 변수 (알 수 없는 수)입니다.
아래 예에서는 값이 0과 5 사이인 x 변수 하나를 만들고 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 | Linear | 제약 조건에서 변수의 계수를 설정합니다. |
자세한 문서
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 | String | 계수가 설정되는 변수의 이름 |
coefficient | Number | 설정되는 계수 |
리턴
Linear: 이 선형 최적화 제약 조건