내 모델 MIP 모델 CPLEX. 나는 기능을 포함하는 변수 결정 및 필요하고 완전한의 이 기능을 계산합니다. 하는 방법은 없고 완전한 기능에 CPLEX? 감사합니다!
0
으로 구분할 수 있습 선형 대략적인 모든 기능에 의존하는 수학적 프로그래밍입니다.
// linearization of f(x)=1/x through a piecewise linear function
int sampleSize=10000;
float s=1;
float e=10;
float x[i in 0..sampleSize]=s+(e-s)*i/sampleSize;
int nbSegments=5;
float x2[i in 0..nbSegments]=(s)+(e-s)*i/nbSegments;
float y2[i in 0..nbSegments]=1/x2[i]; // y=f(x)
float firstSlope=0;
float lastSlope=0;
tuple breakpoint // y=f(x)
{
key float x;
float y;
}
sorted { breakpoint } breakpoints={<x2[i],y2[i]> | i in 0..nbSegments};
float slopesBeforeBreakpoint[b in breakpoints]=
(b.x==first(breakpoints).x)
?firstSlope
:(b.y-prev(breakpoints,b).y)/(b.x-prev(breakpoints,b).x);
pwlFunction f=piecewise(b in breakpoints)
{ slopesBeforeBreakpoint[b]->b.x; lastSlope } (first(breakpoints).x, first(breakpoints).y);
assert forall(b in breakpoints) abs(f(b.x)-b.y)<=0.001;
으로 제약 조건에서 프로그래밍 CPLEX 당신이 함수를 사용할 수 있습니다(심지어는 선형)도 블랙박스 기능이다.
using CP;
// CPOptimizer allows all kind of non linearities
int nbKids=300;
float costBus40=500;
float costBus30=400;
dvar int+ nbBus40;
dvar int+ nbBus30;
// Non linear objective (exponential)
minimize
costBus40*exp(nbBus40) +exp(nbBus30)*costBus30;
subject to
{
40*nbBus40+nbBus30*30>=nbKids;
}