summaryrefslogtreecommitdiff
path: root/tests/general_tests/fmincon
diff options
context:
space:
mode:
Diffstat (limited to 'tests/general_tests/fmincon')
-rw-r--r--tests/general_tests/fmincon/fmincon_grad1.sce44
-rw-r--r--tests/general_tests/fmincon/fmincon_grad2.sce44
-rw-r--r--tests/general_tests/fmincon/fmincon_gradcon1.sce44
-rw-r--r--tests/general_tests/fmincon/fmincon_gradcon2.sce44
-rw-r--r--tests/general_tests/fmincon/fmincon_gradcon3.sce44
-rw-r--r--tests/general_tests/fmincon/fmincon_hess1.sce44
-rw-r--r--tests/general_tests/fmincon/fmincon_hess2.sce44
-rw-r--r--tests/general_tests/fmincon/fmincon_nlc1.sce44
-rw-r--r--tests/general_tests/fmincon/fmincon_nlc2.sce44
-rw-r--r--tests/general_tests/fmincon/fmincon_nlc3.sce44
-rw-r--r--tests/general_tests/fmincon/fmincon_nlc4.sce40
-rw-r--r--tests/general_tests/fmincon/fmincon_options1.sce44
-rw-r--r--tests/general_tests/fmincon/fmincon_options2.sce44
13 files changed, 568 insertions, 0 deletions
diff --git a/tests/general_tests/fmincon/fmincon_grad1.sce b/tests/general_tests/fmincon/fmincon_grad1.sce
new file mode 100644
index 0000000..bf72b8f
--- /dev/null
+++ b/tests/general_tests/fmincon/fmincon_grad1.sce
@@ -0,0 +1,44 @@
+
+//Incompatibility between user defined gradient function and dimensions of the starting point x0
+
+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: Gradient function of Objective and x0 did not match
+//at line 606 of function fmincon called by :
+//fmincon(f,x0,A,b,Aeq,beq,lb,ub,nlc,options)
+//at line 44 of exec file called by :
+//exec fmincon_grad1.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
+
+//x(4) is invalid here
+function y= fGrad(x)
+ y= [x(2),x(1)+x(3),x(4)];
+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
+
+function [cg,ceqg] = cGrad(x)
+ cg = [2*x(1),0,0;2*x(1),2*x(2),0;0,0,2*x(3)];
+ 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)
diff --git a/tests/general_tests/fmincon/fmincon_grad2.sce b/tests/general_tests/fmincon/fmincon_grad2.sce
new file mode 100644
index 0000000..9f29a39
--- /dev/null
+++ b/tests/general_tests/fmincon/fmincon_grad2.sce
@@ -0,0 +1,44 @@
+
+//User defined gradient function does not return a vector
+
+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: Wrong Input for Objective Gradient function(10th Parameter)---->Vector function is Expected
+//at line 615 of function fmincon called by :
+//fmincon(f,x0,A,b,Aeq,beq,lb,ub,nlc,options)
+//at line 44 of exec file called by :
+//exec fmincon_grad2.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 is not a vector here
+ y= [x(2),x(1)+x(3);x(2),x(1)];
+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
+
+function [cg,ceqg] = cGrad(x)
+ cg = [2*x(1),0,0;2*x(1),2*x(2),0;0,0,2*x(3)];
+ 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)
diff --git a/tests/general_tests/fmincon/fmincon_gradcon1.sce b/tests/general_tests/fmincon/fmincon_gradcon1.sce
new file mode 100644
index 0000000..7a1efa4
--- /dev/null
+++ b/tests/general_tests/fmincon/fmincon_gradcon1.sce
@@ -0,0 +1,44 @@
+
+//Incompatibility between user defined constraint gradient function and dimensions of the starting point x0
+
+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: Gradient function of Constraint and x0 did not match
+//at line 640 of function fmincon called by :
+//fmincon(f,x0,A,b,Aeq,beq,lb,ub,nlc,options)
+//at line 44 of exec file called by :
+//exec fmincon_gradcon1.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
+
+//x(4) is invalid here
+function [cg,ceqg] = cGrad(x)
+ cg = [2*x(1),0,0;2*x(1),2*x(2),0;0,0,2*x(4)];
+ ceqg = [3*x(1)^2,0,0;0,2*x(2),2*x(4)];
+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)
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)
diff --git a/tests/general_tests/fmincon/fmincon_gradcon3.sce b/tests/general_tests/fmincon/fmincon_gradcon3.sce
new file mode 100644
index 0000000..eeda192
--- /dev/null
+++ b/tests/general_tests/fmincon/fmincon_gradcon3.sce
@@ -0,0 +1,44 @@
+
+//Wrong dimensions of non-linear equality 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 (ceqg) 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 equality constraints and n is number of Variables
+//at line 653 of function fmincon called by :
+//fmincon(f,x0,A,b,Aeq,beq,lb,ub,nlc,options)
+//at line 44 of exec file called by :
+//exec fmincon_gradcon3.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 ceqg 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)];
+ ceqg = [3*x(1)^2,0,0,x(3);0,2*x(2),2*x(3),2*x(1)];
+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)
diff --git a/tests/general_tests/fmincon/fmincon_hess1.sce b/tests/general_tests/fmincon/fmincon_hess1.sce
new file mode 100644
index 0000000..058f521
--- /dev/null
+++ b/tests/general_tests/fmincon/fmincon_hess1.sce
@@ -0,0 +1,44 @@
+
+//Incompatibility between user defined hessian function and dimensions of the starting point x0
+
+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: Hessian function of Objective and x0 did not match
+//at line 625 of function fmincon called by :
+//fmincon(f,x0,A,b,Aeq,beq,lb,ub,nlc,options)
+//at line 44 of exec file called by :
+//exec fmincon_hess1.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
+
+//x(4) is invalid here
+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(4),0,0;0,0,0;0,0,0] + lambda(5)*[0,0,0;0,2,0;0,0,2];
+endfunction
+
+function [cg,ceqg] = cGrad(x)
+ cg = [2*x(1),0,0;2*x(1),2*x(2),0;0,0,2*x(3)];
+ 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)
diff --git a/tests/general_tests/fmincon/fmincon_hess2.sce b/tests/general_tests/fmincon/fmincon_hess2.sce
new file mode 100644
index 0000000..58f8804
--- /dev/null
+++ b/tests/general_tests/fmincon/fmincon_hess2.sce
@@ -0,0 +1,44 @@
+
+//User defined hessian is of wrong dimensions
+
+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: Wrong Input for Objective Hessian function(10th Parameter)---->Symmetric Matrix function is Expected
+//at line 630 of function fmincon called by :
+//fmincon(f,x0,A,b,Aeq,beq,lb,ub,nlc,options)
+//at line 44 of exec file called by :
+//exec fmincon_hess2.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
+
+//Wrong dimensions of Hessian here
+function y= lHess(x,obj,lambda)
+ y= obj*[0,1;1,0;0,1] + lambda(1)*[2,0;0,0;0,0] + lambda(2)*[2,0;0,2;0,0] +lambda(3)*[0,0;0,0;0,0] + lambda(4)*[6*x(1),0;0,0;0,0] + lambda(5)*[0,0;0,2;0,0];
+endfunction
+
+function [cg,ceqg] = cGrad(x)
+ cg = [2*x(1),0,0;2*x(1),2*x(2),0;0,0,2*x(3)];
+ 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)
diff --git a/tests/general_tests/fmincon/fmincon_nlc1.sce b/tests/general_tests/fmincon/fmincon_nlc1.sce
new file mode 100644
index 0000000..65064d7
--- /dev/null
+++ b/tests/general_tests/fmincon/fmincon_nlc1.sce
@@ -0,0 +1,44 @@
+
+//Mismatch in dimensions of starting point x0 and that of non-linear constraints
+
+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: Non-Linear Constraint function(9th Parameter) and x0(2nd Parameter) did not match
+//at line 487 of function fmincon called by :
+//fmincon(f,x0,A,b,Aeq,beq,lb,ub,nlc,options)
+//at line 44 of exec file called by :
+//exec fmincon_nlc1.sce
+
+function [c,ceq]=nlc(x)
+ //x(4) is out of dimension here when compared to x0
+ c=[x(1)^2-1,x(4)^2+x(2)^2-1,x(4)^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
+
+function [cg,ceqg] = cGrad(x)
+ cg = [2*x(1),0,0;2*x(1),2*x(2),0;0,0,2*x(3)];
+ 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)
diff --git a/tests/general_tests/fmincon/fmincon_nlc2.sce b/tests/general_tests/fmincon/fmincon_nlc2.sce
new file mode 100644
index 0000000..5a524fd
--- /dev/null
+++ b/tests/general_tests/fmincon/fmincon_nlc2.sce
@@ -0,0 +1,44 @@
+
+//Checking if non-linear inequality constraints are specified in row vector format
+
+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 c in Non-Linear Constraint function(9th Parameter) should be in the form of Row Vector or Empty Vector
+//at line 493 of function fmincon called by :
+//fmincon(f,x0,A,b,Aeq,beq,lb,ub,nlc,options)
+//at line 44 of exec file called by :
+//exec fmincon_nlc2.sce
+
+function [c,ceq]=nlc(x)
+ //Expected a row vector or an empty vector for c, but found a column vector
+ 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
+
+function [cg,ceqg] = cGrad(x)
+ cg = [2*x(1),0,0;2*x(1),2*x(2),0;0,0,2*x(3)];
+ 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)
diff --git a/tests/general_tests/fmincon/fmincon_nlc3.sce b/tests/general_tests/fmincon/fmincon_nlc3.sce
new file mode 100644
index 0000000..d82bf84
--- /dev/null
+++ b/tests/general_tests/fmincon/fmincon_nlc3.sce
@@ -0,0 +1,44 @@
+
+//Checking if non-linear equality constraints are specified in row vector format
+
+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 ceq in Non-Linear Constraint function(9th Parameter) should be in the form of Row Vector or Empty Vector
+//at line 498 of function fmincon called by :
+//fmincon(f,x0,A,b,Aeq,beq,lb,ub,nlc,options)
+//at line 44 of exec file called by :
+//exec fmincon_nlc3.sce
+
+function [c,ceq]=nlc(x)
+ c=[x(1)^2-1,x(1)^2+x(2)^2-1,x(3)^2-1];
+ //Expected a row vector or an empty vector for ceq, but found a column vector
+ 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
+
+function [cg,ceqg] = cGrad(x)
+ cg = [2*x(1),0,0;2*x(1),2*x(2),0;0,0,2*x(3)];
+ 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)
diff --git a/tests/general_tests/fmincon/fmincon_nlc4.sce b/tests/general_tests/fmincon/fmincon_nlc4.sce
new file mode 100644
index 0000000..7e7c180
--- /dev/null
+++ b/tests/general_tests/fmincon/fmincon_nlc4.sce
@@ -0,0 +1,40 @@
+
+//If non-linear constraints is neither a function nor an empty matrix then flag an error
+
+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: Non Linear Constraint (9th Parameter) should be a function or an Empty Matrix
+//at line 542 of function fmincon called by :
+//fmincon(f,x0,A,b,Aeq,beq,lb,ub,nlc,options)
+//at line 40 of exec file called by :
+//exec fmincon_nlc4.sce
+
+nlc=[1,2,3,4];
+
+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
+
+function [cg,ceqg] = cGrad(x)
+ cg = [2*x(1),0,0;2*x(1),2*x(2),0;0,0,2*x(3)];
+ 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)
diff --git a/tests/general_tests/fmincon/fmincon_options1.sce b/tests/general_tests/fmincon/fmincon_options1.sce
new file mode 100644
index 0000000..e5fc008
--- /dev/null
+++ b/tests/general_tests/fmincon/fmincon_options1.sce
@@ -0,0 +1,44 @@
+
+//Size of options is not even
+
+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: Size of Options (list) should be even
+//at line 558 of function fmincon called by :
+//fmincon(f,x0,A,b,Aeq,beq,lb,ub,nlc,options)
+//at line 43 of exec file called by :
+//exec fmincon_options1.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
+
+function [cg,ceqg] = cGrad(x)
+ cg = [2*x(1),0,0;2*x(1),2*x(2),0;0,0,2*x(3)];
+ ceqg = [3*x(1)^2,0,0;0,2*x(2),2*x(3)];
+endfunction
+
+//cGrad is missing in the options
+options=list("MaxIter", [1500], "CpuTime", [500], "GradObj", fGrad, "Hessian", lHess,"GradCon");
+
+[x,fval,exitflag,output,lambda,grad,hessian] =fmincon(f,x0,A,b,Aeq,beq,lb,ub,nlc,options)
diff --git a/tests/general_tests/fmincon/fmincon_options2.sce b/tests/general_tests/fmincon/fmincon_options2.sce
new file mode 100644
index 0000000..1097690
--- /dev/null
+++ b/tests/general_tests/fmincon/fmincon_options2.sce
@@ -0,0 +1,44 @@
+
+//Typing error in arguments to options
+
+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: Unrecognized parameter name GradientObj.
+//at line 596 of function fmincon called by :
+//fmincon(f,x0,A,b,Aeq,beq,lb,ub,nlc,options)
+//at line 44 of exec file called by :
+//exec fmincon_options2.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
+
+function [cg,ceqg] = cGrad(x)
+ cg = [2*x(1),0,0;2*x(1),2*x(2),0;0,0,2*x(3)];
+ ceqg = [3*x(1)^2,0,0;0,2*x(2),2*x(3)];
+endfunction
+
+//Typing error: Expected "GradObj" instead of "GradientObj"
+options=list("MaxIter", [1500], "CpuTime", [500], "GradientObj", fGrad, "Hessian", lHess,"GradCon",cGrad);
+
+[x,fval,exitflag,output,lambda,grad,hessian] =fmincon(f,x0,A,b,Aeq,beq,lb,ub,nlc,options)