nlpsolve computes the optimum of a multivariate objective function subject to equality and/or inequality constraints with continuous and/or integer variables.
f(x)=min{ | √ |
| −1, | √ |
| −1.005, | √ |
| +0.5}, |
[−1.0049992998,[x=−1.0]] |
|
nlpsolve(x1*x4*(x1+x2+x3)+x3, |
[x1*x2*x3*x4-25>=0,x1^2+x2^2+x3^2+x4^2-40=0], |
[x1,x2,x3,x4]=1..5) |
[17.0140172892,[x1=1.0,x2=4.74299973362,x3=3.82114985829,x4=1.3794083106]] |
|
nlpsolve((x1-1)^2+(x1-x2)^2+(x3-1)^2+(x4-1)^4+(x5-1)^6, |
[x1^2*x4+sin(x4-x5)=2*sqrt(2),x2+x3^4*x4^2=8+sqrt(2)]) |
|
nlpsolve(3x1*x2-x1+6x2,[5x1*x2-4x1-4.5x2<=32], |
[x1,x2]=1..5,assume=integer,maximize) |
[58.0,[x1=2.0,x2=5.0]] |
nlpsolve(2x1+3x2+6x3-2x1*x2-x1*x3-4x2*x3, |
assume=nlp_binary,maximize) |
[7.0,[x1=1.0,x2=0,x3=1.0]] |
|
nlpsolve(5y-2*ln(x+1), |
[exp(x/2)-sqrt(y)/2-1<=0,-2*ln(x+1)-y+2.5<=0,x+y-4<=0], |
x=0..2,y=1..3,nlp_integervariables=[y]) |
[8.54528930252,[x=1.06959999348,y=2.0]] |
|
obj:=x1^2+x2^2+3x3^2+4x4^2+2x5^2-8x1-2x2-3x3-x4-2x5; |
constr:=[x1+x2+x3+x4+x5<=400,x1+2x2+2x3+x4+6x5<=800, |
2x1+x2+6x3<=200,x3+x4+5x5<=200, |
x1+x2+x3+x4+x5>=55,x1+x2+x3+x4>=48, |
x2+x4+x5>=34,6x1+7x5>=104]; |
nlpsolve(obj,constr,[x1,x2,x3,x4,x5]=0..99,assume=integer) |
[807.0,[x1=16.0,x2=22.0,x3=5.0,x4=5.0,x5=7.0]] |
f(x1,x2)= |
|
f:=proc(x1,x2,a) local t; purge(t); if x1<x2 then return approx(int(exp(-t)*t^a*sin(t+x1)*cos(2t-x2),t=x1..x2)); else return 0; fi; end:;
⎡ ⎣ | −0.445124159544, | ⎡ ⎣ | x1=2.15550857079,x2=5.66106529292 | ⎤ ⎦ | ⎤ ⎦ |