형식의 선형 제약조건을 저장하는 객체입니다. 여기서 lowerBound 및 upperBound는 상수이고, a(i)는 상수 계수이며, x(i)는 변수 (알 수 없음)입니다.lowerBound ≤ Sum(a(i) x(i)) ≤ upperBound
아래 예에서는 값이 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 | 제약조건에서 변수의 계수를 설정합니다. |
자세한 문서
setCoefficient(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 | 설정되는 계수 |
리턴
LinearOptimizationConstraint - 이 선형 최적화 제약조건