Class LinearOptimizationConstraint

LinearOptimizationConstraint

lowerBound ≤ Sum(a(i) x(i)) ≤ upperBound 형식의 선형 제약 조건을 저장하는 객체. 여기서 lowerBoundupperBound는 상수, a(i)는 상수 계수, x(i)는 변수 (알 수 없음)입니다.

아래 예시에서는 05 사이의 값으로 하나의 변수 x를 만들고 0 ≤ 2 * x ≤ 5 제약 조건을 만듭니다. 이를 위해서는 먼저 하한 5 및 상한 5를 사용하여 제약조건을 만들면 됩니다. 그러면 이 제약 조건에서 변수 x의 계수가 2로 설정됩니다.

var 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
var 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);

방법

메서드반환 유형간략한 설명
setCoefficient(variableName, coefficient)LinearOptimizationConstraint제약조건에서 변수의 계수를 설정합니다.

자세한 문서

setCoefficient(variableName, coefficient)

제약조건에서 변수의 계수를 설정합니다. 기본적으로 변수의 계수는 0입니다.

var engine = LinearOptimizationService.createEngine();
// Create a linear constraint with the bounds 0 and 10
var 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);

매개변수

이름유형설명
variableNameString계수를 설정하는 변수의 이름
coefficientNumber계수 설정

리턴

LinearOptimizationConstraint: 이 선형 최적화 제약조건