diff options
Diffstat (limited to 'demos')
-rw-r--r-- | demos/lsqlin.dem.sce | 66 | ||||
-rw-r--r-- | demos/lsqnonneg.dem.sce | 20 | ||||
-rw-r--r-- | demos/qpipopt.dem.sce | 42 | ||||
-rw-r--r-- | demos/qpipoptmat.dem.sce | 26 | ||||
-rw-r--r-- | demos/symphony.dem.sce | 2 | ||||
-rw-r--r-- | demos/symphonymat.dem.sce | 1 |
6 files changed, 78 insertions, 79 deletions
diff --git a/demos/lsqlin.dem.sce b/demos/lsqlin.dem.sce index 0b81630..827ba63 100644 --- a/demos/lsqlin.dem.sce +++ b/demos/lsqlin.dem.sce @@ -4,46 +4,40 @@ mode(1) // //A simple linear least square example -C = [0.9501 0.7620 0.6153 0.4057 -0.2311 0.4564 0.7919 0.9354 -0.6068 0.0185 0.9218 0.9169 -0.4859 0.8214 0.7382 0.4102 -0.8912 0.4447 0.1762 0.8936]; -d = [0.0578 -0.3528 -0.8131 -0.0098 -0.1388]; -A = [0.2027 0.2721 0.7467 0.4659 -0.1987 0.1988 0.4450 0.4186 -0.6037 0.0152 0.9318 0.8462]; -b = [0.5251 -0.2026 -0.6721]; +C = [ 2 0; +-1 1; +0 2] +d = [1 +0 +-1]; +A = [10 -2; +-2 10]; +b = [4 +-4]; [xopt,resnorm,residual,exitflag,output,lambda] = lsqlin(C,d,A,b) // Press ENTER to continue halt() // Press return to continue //A basic example for equality, inequality constraints and variable bounds -C = [0.9501 0.7620 0.6153 0.4057 -0.2311 0.4564 0.7919 0.9354 -0.6068 0.0185 0.9218 0.9169 -0.4859 0.8214 0.7382 0.4102 -0.8912 0.4447 0.1762 0.8936]; -d = [0.0578 -0.3528 -0.8131 -0.0098 -0.1388]; -A =[0.2027 0.2721 0.7467 0.4659 -0.1987 0.1988 0.4450 0.4186 -0.6037 0.0152 0.9318 0.8462]; -b =[0.5251 -0.2026 -0.6721]; -Aeq = [3 5 7 9]; -beq = 4; -lb = -0.1*ones(4,1); -ub = 2*ones(4,1); +C = [1 1 1; +1 1 0; +0 1 1; +1 0 0; +0 0 1] +d = [89; +67; +53; +35; +20;] +A = [3 2 1; +2 3 4; +1 2 3]; +b = [191 +209 +162]; +Aeq = [1 2 1]; +beq = 10; +lb = repmat(0.1,3,1); +ub = repmat(4,3,1); [xopt,resnorm,residual,exitflag,output,lambda] = lsqlin(C,d,A,b,Aeq,beq,lb,ub) //========= E N D === O F === D E M O =========// diff --git a/demos/lsqnonneg.dem.sce b/demos/lsqnonneg.dem.sce index 73fa6df..d8be39b 100644 --- a/demos/lsqnonneg.dem.sce +++ b/demos/lsqnonneg.dem.sce @@ -4,15 +4,15 @@ mode(1) // // A basic lsqnonneg problem -C = [ -0.0372 0.2869 -0.6861 0.7071 -0.6233 0.6245 -0.6344 0.6170]; -d = [ -0.8587 -0.1781 -0.0747 -0.8405]; +C = [1 1 1; +1 1 0; +0 1 1; +1 0 0; +0 0 1] +d = [89; +67; +53; +35; +20;] [xopt,resnorm,residual,exitflag,output,lambda] = lsqnonneg(C,d) //========= E N D === O F === D E M O =========// diff --git a/demos/qpipopt.dem.sce b/demos/qpipopt.dem.sce index 8e405e1..3fa7476 100644 --- a/demos/qpipopt.dem.sce +++ b/demos/qpipopt.dem.sce @@ -3,6 +3,28 @@ mode(1) // Demo of qpipopt.sci // +//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]; +conUB = [5;3]; +conLB = [-%inf; -%inf]; +lb = [0; 0]; +ub = [%inf; %inf]; +nbVar = 2; +nbCon = 2; +[xopt,fopt,exitflag,output,lambda] = qpipopt(nbVar,nbCon,H,f,lb,ub,A,conLB,conUB) +//Press ENTER to continue +halt() // Press return to continue + //Find x in R^6 such that: A= [1,-1,1,0,3,1; -1,0,-3,-4,5,6; @@ -20,24 +42,4 @@ nbCon = 5; x0 = repmat(0,nbVar,1); param = list("MaxIter", 300, "CpuTime", 100); [xopt,fopt,exitflag,output,lambda]=qpipopt(nbVar,nbCon,H,f,lb,ub,A,conLB,conUB,x0,param) -// Press ENTER to continue -halt() // Press return to continue - -//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]; -conUB = [2; 2; 3]; -conLB = [-%inf; -%inf; -%inf]; -lb = [0; 0]; -ub = [%inf; %inf]; -nbVar = 2; -nbCon = 3; -[xopt,fopt,exitflag,output,lambda] = qpipopt(nbVar,nbCon,H,f,lb,ub,A,conLB,conUB) //========= E N D === O F === D E M O =========// 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 =========// diff --git a/demos/symphony.dem.sce b/demos/symphony.dem.sce index 67886a3..a0b629e 100644 --- a/demos/symphony.dem.sce +++ b/demos/symphony.dem.sce @@ -3,7 +3,7 @@ mode(1) // Demo of symphony.sci // -//A basic case : +//Reference: Westerberg, Carl-Henrik, Bengt Bjorklund, and Eskil Hultman. "An application of mixed integer programming in a Swedish steel mill." Interfaces 7, no. 2 (1977): 39-43. // Objective function c = [350*5,330*3,310*4,280*6,500,450,400,100]'; // Lower Bound of variable diff --git a/demos/symphonymat.dem.sce b/demos/symphonymat.dem.sce index a5e19ac..7bc751e 100644 --- a/demos/symphonymat.dem.sce +++ b/demos/symphonymat.dem.sce @@ -4,6 +4,7 @@ mode(1) // // Objective function +// Reference: Westerberg, Carl-Henrik, Bengt Bjorklund, and Eskil Hultman. "An application of mixed integer programming in a Swedish steel mill." Interfaces 7, no. 2 (1977): 39-43. c = [350*5,330*3,310*4,280*6,500,450,400,100]'; // Lower Bound of variable lb = repmat(0,1,8); |