diff options
author | Georgey | 2017-07-05 11:43:47 +0530 |
---|---|---|
committer | Georgey | 2017-07-05 11:43:47 +0530 |
commit | ecdd7ba6762a15bdb867be900e7128201be2e690 (patch) | |
tree | dc36ba4879b83eb45d042d76c0650ab7ae59144b /demos/intfminimax.dem.sce | |
parent | 66089674c189f557b401f2ad0cf6b35354caadfa (diff) | |
download | FOSSEE-Optimization-toolbox-ecdd7ba6762a15bdb867be900e7128201be2e690.tar.gz FOSSEE-Optimization-toolbox-ecdd7ba6762a15bdb867be900e7128201be2e690.tar.bz2 FOSSEE-Optimization-toolbox-ecdd7ba6762a15bdb867be900e7128201be2e690.zip |
Added demo files
Diffstat (limited to 'demos/intfminimax.dem.sce')
-rw-r--r-- | demos/intfminimax.dem.sce | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/demos/intfminimax.dem.sce b/demos/intfminimax.dem.sce new file mode 100644 index 0000000..db74b92 --- /dev/null +++ b/demos/intfminimax.dem.sce @@ -0,0 +1,57 @@ +mode(1) +// +// Demo of intfminimax.sci +// + +// A basic case : +// we provide only the objective function and the nonlinear constraint +// function +function f = myfun(x) +f(1)= 2*x(1)^2 + x(2)^2 - 48*x(1) - 40*x(2) + 304; //Objectives +f(2)= -x(1)^2 - 3*x(2)^2; +f(3)= x(1) + 3*x(2) -18; +f(4)= -x(1) - x(2); +f(5)= x(1) + x(2) - 8; +endfunction +// The initial guess +x0 = [0.1,0.1]; +// The expected solution : only 4 digits are guaranteed +xopt = [4 4] +fopt = [0 -64 -2 -8 0] +intcon = [1] +maxfopt = 0 +// Run fminimax +[x,fval,maxfval,exitflag] = intfminimax(myfun, x0,intcon) +// Press ENTER to continue +halt() // Press return to continue + +// A case where we provide the gradient of the objective +// functions and the Jacobian matrix of the constraints. +// The objective function and its gradient +function [f,G] = myfun(x) +f(1)= 2*x(1)^2 + x(2)^2 - 48*x(1) - 40*x(2) + 304; +f(2)= -x(1)^2 - 3*x(2)^2; +f(3)= x(1) + 3*x(2) -18; +f(4)= -x(1) - x(2); +f(5)= x(1) + x(2) - 8; +G = [ 4*x(1) - 48, -2*x(1), 1, -1, 1; +2*x(2) - 40, -6*x(2), 3, -1, 1; ]' +endfunction +// The nonlinear constraints +function [c,ceq,DC,DCeq] = confun(x) +// Inequality constraints +c = [1.5 + x(1)*x(2) - x(1) - x(2), -x(1)*x(2) - 10] +// No nonlinear equality constraints +ceq=[] +DC= [x(2)-1, -x(2); +x(1)-1, -x(1)]' +DCeq = []' +endfunction +// Test with both gradient of objective and gradient of constraints +minimaxOptions = list("GradObj","on","GradCon","on"); +// The initial guess +x0 = [0,10]; +intcon = [2] +// Run intfminimax +[x,fval,maxfval,exitflag] = intfminimax(myfun,x0,intcon,[],[],[],[],[],[], confun, minimaxOptions) +//========= E N D === O F === D E M O =========// |