diff options
author | Harpreet | 2016-03-03 08:59:34 +0530 |
---|---|---|
committer | Harpreet | 2016-03-03 08:59:34 +0530 |
commit | 7cf9300c2eb4773afa9823cf4a179d43f70001aa (patch) | |
tree | 62f03c9c2df9ffe1c061d346a2059cc0fe862ba0 /tests/general_tests/fmincon/fmincon_gradcon2.sce | |
parent | d0cad398d8df199a4974112bfb7945c18636b5f8 (diff) | |
download | FOSSEE-Optimization-toolbox-7cf9300c2eb4773afa9823cf4a179d43f70001aa.tar.gz FOSSEE-Optimization-toolbox-7cf9300c2eb4773afa9823cf4a179d43f70001aa.tar.bz2 FOSSEE-Optimization-toolbox-7cf9300c2eb4773afa9823cf4a179d43f70001aa.zip |
lsqnonlin added
Diffstat (limited to 'tests/general_tests/fmincon/fmincon_gradcon2.sce')
-rw-r--r-- | tests/general_tests/fmincon/fmincon_gradcon2.sce | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/general_tests/fmincon/fmincon_gradcon2.sce b/tests/general_tests/fmincon/fmincon_gradcon2.sce new file mode 100644 index 0000000..f064e98 --- /dev/null +++ b/tests/general_tests/fmincon/fmincon_gradcon2.sce @@ -0,0 +1,44 @@ + +//Wrong dimensions of non-linear inequality constraint gradient function + +function y=f(x) + y=x(1)*x(2)+x(2)*x(3); +endfunction + +x0=[1,1,1]; +A=[]; +b=[]; +Aeq=[]; +beq=[]; +lb=[0 0.2,-%inf]; +ub=[0.6 %inf,1]; + +//Error +//fmincon: Definition of (cg) in Non-Linear Constraint function(10th Parameter) should be in the form of (m X n) or Empty Matrix where m is number of Non- linear inequality constraints and n is number of Variables +//at line 647 of function fmincon called by : +//ncon(f,x0,A,b,Aeq,beq,lb,ub,nlc,options +//at line 44 of exec file called by : +//exec fmincon_gradcon2.sce + +function [c,ceq]=nlc(x) + c=[x(1)^2-1,x(1)^2+x(2)^2-1,x(3)^2-1]; + ceq=[x(1)^3-0.5,x(2)^2+x(3)^2-0.75]; +endfunction + +function y= fGrad(x) + y= [x(2),x(1)+x(3),x(2)]; +endfunction + +function y= lHess(x,obj,lambda) + y= obj*[0,1,0;1,0,1;0,1,0] + lambda(1)*[2,0,0;0,0,0;0,0,0] + lambda(2)*[2,0,0;0,2,0;0,0,0] +lambda(3)*[0,0,0;0,0,0;0,0,2] + lambda(4)*[6*x(1),0,0;0,0,0;0,0,0] + lambda(5)*[0,0,0;0,2,0;0,0,2]; +endfunction + +//Dimension of cg is wrong here +function [cg,ceqg] = cGrad(x) + cg = [2*x(1),0,0;2*x(1),2*x(2),0;0,0,2*x(3);1,0,1]; + ceqg = [3*x(1)^2,0,0;0,2*x(2),2*x(3)]; +endfunction + +options=list("MaxIter", [1500], "CpuTime", [500], "GradObj", fGrad, "Hessian", lHess,"GradCon",cGrad); + +[x,fval,exitflag,output,lambda,grad,hessian] =fmincon(f,x0,A,b,Aeq,beq,lb,ub,nlc,options) |