diff options
Diffstat (limited to 'demos/qpipoptmat.dem.sce')
-rw-r--r-- | demos/qpipoptmat.dem.sce | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/demos/qpipoptmat.dem.sce b/demos/qpipoptmat.dem.sce index 0892855..1e8ebc8 100644 --- a/demos/qpipoptmat.dem.sce +++ b/demos/qpipoptmat.dem.sce @@ -3,17 +3,19 @@ mode(1) // Demo of qpipoptmat.sci // -//Find the value of x that minimize following function -// f(x) = 0.5*x1^2 + x2^2 - x1*x2 - 2*x1 - 6*x2 -// Subject to: -// x1 + x2 ≤ 2 -// –x1 + 2x2 ≤ 2 -// 2x1 + x2 ≤ 3 -// 0 ≤ x1, 0 ≤ x2. -H = [1 -1; -1 2]; -f = [-2; -6]; -A = [1 1; -1 2; 2 1]; -b = [2; 2; 3]; +//Ref : example 14 : +//https://www.me.utexas.edu/~jensen/ORMM/supplements/methods/nlpmethod/S2_quadratic.pdf +// min. -8*x1*x1 -16*x2*x2 + x1 + 4*x2 +// such that +// x1 + x2 <= 5, +// x1 <= 3, +// x1 >= 0, +// x2 >= 0 +H = [2 0 +0 8]; +f = [-8; -16]; +A = [1 1;1 0]; +b = [5;3]; lb = [0; 0]; ub = [%inf; %inf]; [xopt,fopt,exitflag,output,lambda] = qpipoptmat(H,f,A,b,[],[],lb,ub) @@ -34,5 +36,5 @@ x0 = repmat(0,6,1); param = list("MaxIter", 300, "CpuTime", 100); //and minimize 0.5*x'*H*x + f'*x with f=[1; 2; 3; 4; 5; 6]; H=eye(6,6); -[xopt,fopt,exitflag,output,lambda]=qpipoptmat(H,f,A,b,Aeq,beq,lb,ub,[],param) +[xopt,fopt,exitflag,output,lambda]=qpipoptmat(H,f,A,b,Aeq,beq,lb,ub,x0,param) //========= E N D === O F === D E M O =========// |