summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHarpreet2016-01-29 16:38:03 +0530
committerHarpreet2016-01-29 16:38:03 +0530
commitf7c5cbc61d5b52c749824298cfa39a95db2d879c (patch)
tree27aafcca0159b7b3bb2926ff3a9c6c25834980d2 /tests
parent2db803c34c6df02379ec88df3a7aa186700d9fbf (diff)
downloadFOSSEE-Optimization-toolbox-f7c5cbc61d5b52c749824298cfa39a95db2d879c.tar.gz
FOSSEE-Optimization-toolbox-f7c5cbc61d5b52c749824298cfa39a95db2d879c.tar.bz2
FOSSEE-Optimization-toolbox-f7c5cbc61d5b52c749824298cfa39a95db2d879c.zip
linprog general tests added
Diffstat (limited to 'tests')
-rw-r--r--tests/general_tests/linprog/linprog_A1.sce18
-rw-r--r--tests/general_tests/linprog/linprog_Aeq1.sce18
-rw-r--r--tests/general_tests/linprog/linprog_b1.sce17
-rw-r--r--tests/general_tests/linprog/linprog_beq1.sce17
-rw-r--r--tests/general_tests/linprog/linprog_dual_infeasible1.sce31
-rw-r--r--tests/general_tests/linprog/linprog_input1.sce17
-rw-r--r--tests/general_tests/linprog/linprog_input2.sce17
-rw-r--r--tests/general_tests/linprog/linprog_logical1.sce36
-rw-r--r--tests/general_tests/linprog/linprog_logical2.sce32
-rw-r--r--tests/general_tests/linprog/linprog_logical3.sce32
-rw-r--r--tests/general_tests/linprog/linprog_logical4.sce33
-rw-r--r--tests/general_tests/linprog/linprog_maxiter.sce32
-rw-r--r--tests/general_tests/linprog/linprog_null1.sce17
-rw-r--r--tests/general_tests/linprog/linprog_param1.sce19
-rw-r--r--tests/general_tests/linprog/linprog_param2.sce19
-rw-r--r--tests/general_tests/linprog/linprog_param3.sce21
-rw-r--r--tests/general_tests/linprog/linprog_primal_infeasible1.sce34
-rw-r--r--tests/general_tests/linprog/linprog_zeros1.sce30
-rw-r--r--tests/general_tests/lsqlin/lsqlin_param3.sce2
-rw-r--r--tests/unit_tests/fgoalattain.dia.ref74
-rw-r--r--tests/unit_tests/fgoalattain.tst74
-rw-r--r--tests/unit_tests/fminbnd.dia.ref71
-rw-r--r--tests/unit_tests/fminbnd.tst71
-rw-r--r--tests/unit_tests/fmincon.dia.ref98
-rw-r--r--tests/unit_tests/fmincon.tst98
-rw-r--r--tests/unit_tests/fminimax.dia.ref105
-rw-r--r--tests/unit_tests/fminimax.tst105
-rw-r--r--tests/unit_tests/fminunc.dia.ref79
-rw-r--r--tests/unit_tests/fminunc.tst79
-rw-r--r--tests/unit_tests/linprog.dia.ref68
-rw-r--r--tests/unit_tests/linprog.tst68
-rw-r--r--tests/unit_tests/qpipopt_base.dia.ref4
-rw-r--r--tests/unit_tests/qpipopt_base.tst4
-rw-r--r--tests/unit_tests/qpipoptmat_base.dia.ref2
-rw-r--r--tests/unit_tests/qpipoptmat_base.tst2
35 files changed, 1437 insertions, 7 deletions
diff --git a/tests/general_tests/linprog/linprog_A1.sce b/tests/general_tests/linprog/linprog_A1.sce
new file mode 100644
index 0000000..bb3a00a
--- /dev/null
+++ b/tests/general_tests/linprog/linprog_A1.sce
@@ -0,0 +1,18 @@
+// Check for elements in A
+c=[-1,-1/3]'
+A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
+b=[2,1,2,1,-1,2]
+Aeq=[1,1/4]
+beq=[1/2]
+
+//Error
+//linprog: The number of columns in A must be the same as the number of elements of c
+//at line 113 of function matrix_linprog called by :
+//at line 169 of function linprog called by :
+//[xopt,fopt,exitflag,output,lambda]=linprog(c, b, b, Aeq, beq)
+//at line 30 of exec file called by :
+//exec linprog_A1.sce
+
+[xopt,fopt,exitflag,output,lambda]=linprog(c, b, b, Aeq, beq)
+
+
diff --git a/tests/general_tests/linprog/linprog_Aeq1.sce b/tests/general_tests/linprog/linprog_Aeq1.sce
new file mode 100644
index 0000000..6f1ca6e
--- /dev/null
+++ b/tests/general_tests/linprog/linprog_Aeq1.sce
@@ -0,0 +1,18 @@
+// Check for elements in Aeq
+c=[-1,-1/3]'
+A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
+b=[2,1,2,1,-1,2]
+Aeq=[1,1/4]
+beq=[1/2]
+
+//Error
+//linprog: The number of columns in Aeq must be the same as the number of elements of c
+//at line 119 of function matrix_linprog called by :
+//at line 169 of function linprog called by :
+//[xopt,fopt,exitflag,output,lambda]=linprog(c, A, b, beq, beq)
+//at line 16 of exec file called by :
+//exec linprog_Aeq1.sce
+
+[xopt,fopt,exitflag,output,lambda]=linprog(c, A, b, beq, beq)
+
+
diff --git a/tests/general_tests/linprog/linprog_b1.sce b/tests/general_tests/linprog/linprog_b1.sce
new file mode 100644
index 0000000..6b8ecd8
--- /dev/null
+++ b/tests/general_tests/linprog/linprog_b1.sce
@@ -0,0 +1,17 @@
+// Check for elements in b
+c=[-1,-1/3]'
+A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
+b=[2,1,2,1,-1,2]
+Aeq=[1,1/4]
+beq=[1/2]
+
+//Error
+//linprog: The number of rows in A must be the same as the number of elements of b
+//at line 133 of function matrix_linprog called by :
+//at line 169 of function linprog called by :
+//[xopt,fopt,exitflag,output,lambda]=linprog(c, A, beq, Aeq, beq)
+//at line 16 of exec file called by :
+//exec linprog_b1.sce
+
+[xopt,fopt,exitflag,output,lambda]=linprog(c, A, beq, Aeq, beq)
+
diff --git a/tests/general_tests/linprog/linprog_beq1.sce b/tests/general_tests/linprog/linprog_beq1.sce
new file mode 100644
index 0000000..870d05f
--- /dev/null
+++ b/tests/general_tests/linprog/linprog_beq1.sce
@@ -0,0 +1,17 @@
+// Check for elements in beq
+c=[-1,-1/3]'
+A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
+b=[2,1,2,1,-1,2]
+Aeq=[1,1/4]
+beq=[1/2]
+
+//Error
+//linprog: The number of columns in Aeq must be the same as the number of elements of c
+//at line 119 of function matrix_linprog called by :
+//at line 169 of function linprog called by :
+//[xopt,fopt,exitflag,output,lambda]=linprog(c, A, b, beq, beq)
+//at line 16 of exec file called by :
+//exec linprog_Aeq1.sce
+
+[xopt,fopt,exitflag,output,lambda]=linprog(c, A, b, Aeq, Aeq)
+
diff --git a/tests/general_tests/linprog/linprog_dual_infeasible1.sce b/tests/general_tests/linprog/linprog_dual_infeasible1.sce
new file mode 100644
index 0000000..9b910f4
--- /dev/null
+++ b/tests/general_tests/linprog/linprog_dual_infeasible1.sce
@@ -0,0 +1,31 @@
+ //Dual Infeasible Problem
+ c=[3,5,-7]'
+ A=[-1,-1,4;1,1,4]
+ b=[-8,5]
+ Aeq=[]
+ beq=[]
+ lb=[-%inf,-%inf,-%inf]
+ ub=[%inf,%inf,%inf]
+ //Output
+ // Dual Infeasible.
+ // lambda =
+ //
+ // reduced_cost: [0,2,0]
+ // ineqlin: [-2.375,0.625]
+ // eqlin: [0x0 constant]
+ // output =
+ //
+ // Iterations: 2
+ // constrviolation: 0
+ // exitflag =
+ //
+ // 2.
+ // fopt =
+ //
+ // 22.125
+ // xopt =
+ //
+ // 6.5
+ // 0.
+ // - 0.375
+ [xopt,fopt,exitflag,output,lambda]= linprog(c,A,b,Aeq,beq,lb,ub)
diff --git a/tests/general_tests/linprog/linprog_input1.sce b/tests/general_tests/linprog/linprog_input1.sce
new file mode 100644
index 0000000..9921fe9
--- /dev/null
+++ b/tests/general_tests/linprog/linprog_input1.sce
@@ -0,0 +1,17 @@
+// An example with inequality and equality constraints
+c=[-1,-1/3]'
+A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
+b=[2,1,2,1,-1,2]
+Aeq=[1,1/4]
+beq=[1/2]
+
+//Error
+//linprog: Unexpected number of input arguments : 2 provided while should be in the set of [3 5 7 8]
+//at line 141 of function linprog called by :
+//[xopt,fopt,exitflag,output,lambda]=linprog(c, A)
+//at line 30 of exec file called by :
+//exec linprog_input1.sce
+
+[xopt,fopt,exitflag,output,lambda]=linprog(c, A)
+
+
diff --git a/tests/general_tests/linprog/linprog_input2.sce b/tests/general_tests/linprog/linprog_input2.sce
new file mode 100644
index 0000000..a755efa
--- /dev/null
+++ b/tests/general_tests/linprog/linprog_input2.sce
@@ -0,0 +1,17 @@
+// An example with inequality and equality constraints
+c=[-1,-1/3]'
+A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
+b=[2,1,2,1,-1,2]
+Aeq=[1,1/4]
+beq=[1/2]
+
+//Error
+//linprog: Unexpected number of input arguments : 9 provided while should be in the set of [3 5 7 8]
+//at line 141 of function linprog called by :
+//[xopt,fopt,exitflag,output,lambda]=linprog(c, A, b, Aeq, beq,[],[],[],[])
+//at line 15 of exec file called by :
+//exec linprog_input2.sce
+
+[xopt,fopt,exitflag,output,lambda]=linprog(c, A, b, Aeq, beq,[],[],[],[])
+
+
diff --git a/tests/general_tests/linprog/linprog_logical1.sce b/tests/general_tests/linprog/linprog_logical1.sce
new file mode 100644
index 0000000..5dcc011
--- /dev/null
+++ b/tests/general_tests/linprog/linprog_logical1.sce
@@ -0,0 +1,36 @@
+// An example with inequality constraints
+c=[-1,-1/3]'
+A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
+b=[2,1,2,1,-1,2]
+
+//Output
+//Optimal Solution Found.
+// lambda =
+//
+// lower: [0,0]
+// upper: [0,0]
+// eqlin: [0x0 constant]
+// ineqlin: [0.0000422,0.0000089]
+// output =
+//
+// Iterations: 13
+// ConstrViolation: 0
+// exitflag =
+//
+// 0
+// residual =
+//
+// 0.3335021
+// 0.6666002
+// - 0.3332976
+// resnorm =
+//
+// 0.6666667
+// xopt =
+//
+// 0.3332490
+// - 0.3333512
+
+[xopt,fopt,exitflag,output,lambda]=linprog(c, A, b)
+
+
diff --git a/tests/general_tests/linprog/linprog_logical2.sce b/tests/general_tests/linprog/linprog_logical2.sce
new file mode 100644
index 0000000..a8f99a7
--- /dev/null
+++ b/tests/general_tests/linprog/linprog_logical2.sce
@@ -0,0 +1,32 @@
+// An example with inequality and equality constraints
+c=[-1,-1/3]'
+A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
+b=[2,1,2,1,-1,2]
+Aeq=[1,1/4]
+beq=[1/2]
+
+//Output
+//Optimal Solution.
+// lambda =
+//
+// reduced_cost: [0,0]
+// ineqlin: [-0.1111111,0,0,0,0,0]
+// eqlin: -0.8888889
+// output =
+//
+// Iterations: 0
+// constrviolation: 0
+// exitflag =
+//
+// 0.
+// fopt =
+//
+// - 0.6666667
+// xopt =
+//
+// 0.
+// 2.
+
+[xopt,fopt,exitflag,output,lambda]=linprog(c, A, b, Aeq, beq)
+
+
diff --git a/tests/general_tests/linprog/linprog_logical3.sce b/tests/general_tests/linprog/linprog_logical3.sce
new file mode 100644
index 0000000..a5b0bb7
--- /dev/null
+++ b/tests/general_tests/linprog/linprog_logical3.sce
@@ -0,0 +1,32 @@
+// An example with variable bounds, inequality and equality constraints
+c=[-1,-1/3]'
+A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
+b=[2,1,2,1,-1,2]
+Aeq=[1,1/4]
+beq=[1/2]
+lb=[-1,-0.5]
+ub=[1.5,1.25]
+
+//Output
+//Optimal Solution.
+// lambda =
+//
+// reduced_cost: [0,-0.0833333]
+// ineqlin: [0,0,0,0,0,0]
+// eqlin: -1
+// output =
+//
+// Iterations: 0
+// constrviolation: 0
+// exitflag =
+//
+// 0.
+// fopt =
+//
+// - 0.6041667
+// xopt =
+//
+// 0.1875
+// 1.25
+
+[xopt,fopt,exitflag,output,lambda]=linprog(c, A, b, Aeq, beq, lb, ub)
diff --git a/tests/general_tests/linprog/linprog_logical4.sce b/tests/general_tests/linprog/linprog_logical4.sce
new file mode 100644
index 0000000..7b765fa
--- /dev/null
+++ b/tests/general_tests/linprog/linprog_logical4.sce
@@ -0,0 +1,33 @@
+// An example with inequality constraints
+c=[-1,-1/3]'
+A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
+b=[2,1,2,1,-1,2]
+Aeq=[1,1/4]
+beq=[1/2]
+lb=[-1,-0.5]
+ub=[1.5,1.25]
+params = list("maxiter",20)
+
+//Output
+//Optimal Solution.
+// lambda =
+//
+// reduced_cost: [0,-0.0833333]
+// ineqlin: [0,0,0,0,0,0]
+// eqlin: -1
+// output =
+//
+// Iterations: 0
+// constrviolation: 0
+// exitflag =
+//
+// 0.
+// fopt =
+//
+// - 0.6041667
+// xopt =
+//
+// 0.1875
+// 1.25
+
+[xopt,fopt,exitflag,output,lambda]=linprog(c, A, b, Aeq, beq, lb, ub,params)
diff --git a/tests/general_tests/linprog/linprog_maxiter.sce b/tests/general_tests/linprog/linprog_maxiter.sce
new file mode 100644
index 0000000..0796f17
--- /dev/null
+++ b/tests/general_tests/linprog/linprog_maxiter.sce
@@ -0,0 +1,32 @@
+// An example with inequality constraints
+c=[-1,-1/3]'
+A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
+b=[2,1,2,1,-1,2]
+
+param = list("maxiter",3)
+
+//Output
+//Iteration limit reached.
+// lambda =
+//
+// reduced_cost: [0,0]
+// ineqlin: [0,0,0,0,0.6666667,0.3333333]
+// eqlin: [0x0 constant]
+// output =
+//
+// Iterations: 3
+// constrviolation: 0.7999992
+// exitflag =
+//
+// 3.
+// fopt =
+//
+// - 1.1999995
+// xopt =
+//
+// 0.3999996
+// 2.3999996
+
+[xopt,fopt,exitflag,output,lambda]=linprog(c, A, b,[],[],[],[],param)
+
+
diff --git a/tests/general_tests/linprog/linprog_null1.sce b/tests/general_tests/linprog/linprog_null1.sce
new file mode 100644
index 0000000..7a8b053
--- /dev/null
+++ b/tests/general_tests/linprog/linprog_null1.sce
@@ -0,0 +1,17 @@
+// Check for null elements
+c=[-1,-1/3]'
+A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
+b=[2,1,2,1,-1,2]
+Aeq=[1,1/4]
+beq=[1/2]
+
+//Error
+//linprog: Cannot determine the number of variables because input objective coefficients is empty
+//at line 24 of function matrix_linprog called by :
+//at line 169 of function linprog called by :
+//[xopt,fopt,exitflag,output,lambda]=linprog([],[],[])
+//at line 29 of exec file called by :
+//exec linprog_null1.sce
+
+[xopt,fopt,exitflag,output,lambda]=linprog([],[],[])
+
diff --git a/tests/general_tests/linprog/linprog_param1.sce b/tests/general_tests/linprog/linprog_param1.sce
new file mode 100644
index 0000000..6dcd8c6
--- /dev/null
+++ b/tests/general_tests/linprog/linprog_param1.sce
@@ -0,0 +1,19 @@
+// Check for the param to be a list
+c=[-1,-1/3]'
+A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
+b=[2,1,2,1,-1,2]
+Aeq=[1,1/4]
+beq=[1/2]
+lb=[-1,-0.5]
+ub=[1.5,1.25]
+params = 0
+
+//Error
+//linprog: options should be a list
+//at line 85 of function matrix_linprog called by :
+//at line 169 of function linprog called by :
+//[xopt,fopt,exitflag,output,lambda]=linprog(c, A, b, Aeq, beq, lb, ub,params)
+//at line 33 of exec file called by :
+//exec lsqlin_param1.sce
+
+[xopt,fopt,exitflag,output,lambda]=linprog(c, A, b, Aeq, beq, lb, ub,params)
diff --git a/tests/general_tests/linprog/linprog_param2.sce b/tests/general_tests/linprog/linprog_param2.sce
new file mode 100644
index 0000000..5b956b5
--- /dev/null
+++ b/tests/general_tests/linprog/linprog_param2.sce
@@ -0,0 +1,19 @@
+// Check for the param to be even in number
+c=[-1,-1/3]'
+A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
+b=[2,1,2,1,-1,2]
+Aeq=[1,1/4]
+beq=[1/2]
+lb=[-1,-0.5]
+ub=[1.5,1.25]
+params = list("maxiter")
+
+//Error
+//linprog: Size of parameters should be even
+//at line 91 of function matrix_linprog called by :
+//at line 169 of function linprog called by :
+//[xopt,fopt,exitflag,output,lambda]=linprog(c, A, b, Aeq, beq, lb, ub,params)
+//at line 13 of exec file called by :
+//exec lsqlin_param2.sce
+
+[xopt,fopt,exitflag,output,lambda]=linprog(c, A, b, Aeq, beq, lb, ub,params)
diff --git a/tests/general_tests/linprog/linprog_param3.sce b/tests/general_tests/linprog/linprog_param3.sce
new file mode 100644
index 0000000..42dbf13
--- /dev/null
+++ b/tests/general_tests/linprog/linprog_param3.sce
@@ -0,0 +1,21 @@
+// Check for the correct name of param
+// An example with inequality constraints
+c=[-1,-1/3]'
+A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
+b=[2,1,2,1,-1,2]
+Aeq=[1,1/4]
+beq=[1/2]
+lb=[-1,-0.5]
+ub=[1.5,1.25]
+params = list("iter",20)
+
+//Error
+//linprog: Unrecognized parameter name 'iter'.
+//at line 103 of function matrix_linprog called by :
+//at line 169 of function linprog called by :
+//[xopt,fopt,exitflag,output,lambda]=linprog(c, A, b, Aeq, beq, lb, ub,params)
+//at line 34 of exec file called by :
+//exec lsqlin_param3.sce
+
+[xopt,fopt,exitflag,output,lambda]=linprog(c, A, b, Aeq, beq, lb, ub,params)
+
diff --git a/tests/general_tests/linprog/linprog_primal_infeasible1.sce b/tests/general_tests/linprog/linprog_primal_infeasible1.sce
new file mode 100644
index 0000000..e267e13
--- /dev/null
+++ b/tests/general_tests/linprog/linprog_primal_infeasible1.sce
@@ -0,0 +1,34 @@
+//Primal Infeasible Problem
+c=[-1,-1,-1]'
+A=[1,2,-1]
+b=[-4]
+Aeq=[1,5,3;1,1,0]
+beq=[10,100]
+lb=[0,0,0]
+ub=[%inf,%inf,%inf]
+
+//Output
+//Primal Infeasible.
+// lambda =
+//
+// reduced_cost: [0,2.5,0]
+// ineqlin: -0.5
+// eqlin: [-0.5,0]
+// output =
+//
+// Iterations: 2
+// constrviolation: 100.5
+// exitflag =
+//
+// 1.
+// fopt =
+//
+// - 3.
+// xopt =
+//
+// - 0.5
+// 0.
+// 3.5
+
+[xopt,fopt,exitflag,output,lambda]= linprog(c,A,b,Aeq,beq,lb,ub)
+
diff --git a/tests/general_tests/linprog/linprog_zeros1.sce b/tests/general_tests/linprog/linprog_zeros1.sce
new file mode 100644
index 0000000..fffc6b5
--- /dev/null
+++ b/tests/general_tests/linprog/linprog_zeros1.sce
@@ -0,0 +1,30 @@
+// Check for elements all zeros
+c=[-1,-1/3]'
+A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
+b=[2,1,2,1,-1,2]
+Aeq=[1,1/4]
+beq=[1/2]
+
+//Output
+//Optimal Solution.
+// lambda =
+//
+// reduced_cost: 0
+// ineqlin: 0
+// eqlin: [0x0 constant]
+// output =
+//
+// Iterations: 4
+// constrviolation: 0
+// exitflag =
+//
+// 0.
+// fopt =
+//
+// 0.
+// xopt =
+//
+// 0.
+
+[xopt,fopt,exitflag,output,lambda]=linprog(0,0,0)
+
diff --git a/tests/general_tests/lsqlin/lsqlin_param3.sce b/tests/general_tests/lsqlin/lsqlin_param3.sce
index 283c6e2..be8012b 100644
--- a/tests/general_tests/lsqlin/lsqlin_param3.sce
+++ b/tests/general_tests/lsqlin/lsqlin_param3.sce
@@ -1,4 +1,4 @@
-// Check for the param to be even in number
+// Check for the correct name of param
C = [2 0;
-1 1;
0 2]
diff --git a/tests/unit_tests/fgoalattain.dia.ref b/tests/unit_tests/fgoalattain.dia.ref
new file mode 100644
index 0000000..3587dd3
--- /dev/null
+++ b/tests/unit_tests/fgoalattain.dia.ref
@@ -0,0 +1,74 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// Author: Prajwala TM,Sheetal Shalini
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+// <-- JVM NOT MANDATORY -->
+// <-- ENGLISH IMPOSED -->
+
+
+//
+// assert_close --
+// Returns 1 if the two real matrices computed and expected are close,
+// i.e. if the relative distance between computed and expected is lesser than epsilon.
+// Arguments
+// computed, expected : the two matrices to compare
+// epsilon : a small number
+//
+function flag = assert_close ( computed, expected, epsilon )
+ if expected==0.0 then
+ shift = norm(computed-expected);
+ else
+ shift = norm(computed-expected)/norm(expected);
+ end
+// if shift < epsilon then
+// flag = 1;
+// else
+// flag = 0;
+// end
+// if flag <> 1 then pause,end
+ flag = assert_checktrue ( shift < epsilon );
+endfunction
+//
+// assert_equal --
+// Returns 1 if the two real matrices computed and expected are equal.
+// Arguments
+// computed, expected : the two matrices to compare
+// epsilon : a small number
+//
+//function flag = assert_equal ( computed , expected )
+// if computed==expected then
+// flag = 1;
+// else
+// flag = 0;
+// end
+// if flag <> 1 then pause,end
+//endfunction
+
+
+function f1 = fun(x)
+f1(1)=2*x(1)*x(1)+x(2)*x(2)-48*x(1)-40*x(2)+304
+f1(2)=-x(1)*x(1)-3*x(2)*x(2)
+f1(3)=x(1)+3*x(2)-18
+f1(4)=-x(1)-x(2)
+f1(5)=x(1)+x(2)-8
+endfunction
+x0=[-1,1];
+goal=[-5,-3,-2,-1,-4];
+weight=abs(goal)
+//xopt = [-0.0000011 -63.999998 -2.0000002 -8 3.485D-08]
+//fval = [4 3.99]
+//Run fgoalattain
+[xopt,fval,attainfactor,exitflag,output,lambda]=fgoalattain(fun,x0,goal,weight)
+
+assert_close ( xopt , [ 4 4 ]' , 0.0005 );
+assert_close ( fval , [ -0.0000011 -63.999998 -2.0000002 -8. 0 ]' , 0.0005 );
+assert_checkequal( exitflag , int32(0) );
+printf("Test Successful");
diff --git a/tests/unit_tests/fgoalattain.tst b/tests/unit_tests/fgoalattain.tst
new file mode 100644
index 0000000..3587dd3
--- /dev/null
+++ b/tests/unit_tests/fgoalattain.tst
@@ -0,0 +1,74 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// Author: Prajwala TM,Sheetal Shalini
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+// <-- JVM NOT MANDATORY -->
+// <-- ENGLISH IMPOSED -->
+
+
+//
+// assert_close --
+// Returns 1 if the two real matrices computed and expected are close,
+// i.e. if the relative distance between computed and expected is lesser than epsilon.
+// Arguments
+// computed, expected : the two matrices to compare
+// epsilon : a small number
+//
+function flag = assert_close ( computed, expected, epsilon )
+ if expected==0.0 then
+ shift = norm(computed-expected);
+ else
+ shift = norm(computed-expected)/norm(expected);
+ end
+// if shift < epsilon then
+// flag = 1;
+// else
+// flag = 0;
+// end
+// if flag <> 1 then pause,end
+ flag = assert_checktrue ( shift < epsilon );
+endfunction
+//
+// assert_equal --
+// Returns 1 if the two real matrices computed and expected are equal.
+// Arguments
+// computed, expected : the two matrices to compare
+// epsilon : a small number
+//
+//function flag = assert_equal ( computed , expected )
+// if computed==expected then
+// flag = 1;
+// else
+// flag = 0;
+// end
+// if flag <> 1 then pause,end
+//endfunction
+
+
+function f1 = fun(x)
+f1(1)=2*x(1)*x(1)+x(2)*x(2)-48*x(1)-40*x(2)+304
+f1(2)=-x(1)*x(1)-3*x(2)*x(2)
+f1(3)=x(1)+3*x(2)-18
+f1(4)=-x(1)-x(2)
+f1(5)=x(1)+x(2)-8
+endfunction
+x0=[-1,1];
+goal=[-5,-3,-2,-1,-4];
+weight=abs(goal)
+//xopt = [-0.0000011 -63.999998 -2.0000002 -8 3.485D-08]
+//fval = [4 3.99]
+//Run fgoalattain
+[xopt,fval,attainfactor,exitflag,output,lambda]=fgoalattain(fun,x0,goal,weight)
+
+assert_close ( xopt , [ 4 4 ]' , 0.0005 );
+assert_close ( fval , [ -0.0000011 -63.999998 -2.0000002 -8. 0 ]' , 0.0005 );
+assert_checkequal( exitflag , int32(0) );
+printf("Test Successful");
diff --git a/tests/unit_tests/fminbnd.dia.ref b/tests/unit_tests/fminbnd.dia.ref
new file mode 100644
index 0000000..bed9eae
--- /dev/null
+++ b/tests/unit_tests/fminbnd.dia.ref
@@ -0,0 +1,71 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// Author: R.Vidyadhar & Vignesh Kannan
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+// <-- JVM NOT MANDATORY -->
+// <-- ENGLISH IMPOSED -->
+
+
+//
+// assert_close --
+// Returns 1 if the two real matrices computed and expected are close,
+// i.e. if the relative distance between computed and expected is lesser than epsilon.
+// Arguments
+// computed, expected : the two matrices to compare
+// epsilon : a small number
+//
+function flag = assert_close ( computed, expected, epsilon )
+ if expected==0.0 then
+ shift = norm(computed-expected);
+ else
+ shift = norm(computed-expected)/norm(expected);
+ end
+// if shift < epsilon then
+// flag = 1;
+// else
+// flag = 0;
+// end
+// if flag <> 1 then pause,end
+ flag = assert_checktrue ( shift < epsilon );
+endfunction
+//
+// assert_equal --
+// Returns 1 if the two real matrices computed and expected are equal.
+// Arguments
+// computed, expected : the two matrices to compare
+// epsilon : a small number
+//
+//function flag = assert_equal ( computed , expected )
+// if computed==expected then
+// flag = 1;
+// else
+// flag = 0;
+// end
+// if flag <> 1 then pause,end
+//endfunction
+
+//Find x in R such that it minimizes:
+//f(x)= 1/x^2
+//0 <= x <= 1000
+//Objective function to be minimised
+function y=f(x)
+y=1/x^2
+endfunction
+//Variable bounds
+x1 = [0];
+x2 = [1000];
+//Calling Ipopt
+[xopt,fval,exitflag,output,lambda] =fminbnd(f, x1, x2)
+
+assert_close ( xopt , [ 32.27955 ]' , 0.0005 );
+assert_close ( fval , [ 0.0009597 ]' , 0.0005 );
+assert_checkequal( exitflag , int32(0) );
+printf("Test Successful");
diff --git a/tests/unit_tests/fminbnd.tst b/tests/unit_tests/fminbnd.tst
new file mode 100644
index 0000000..bed9eae
--- /dev/null
+++ b/tests/unit_tests/fminbnd.tst
@@ -0,0 +1,71 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// Author: R.Vidyadhar & Vignesh Kannan
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+// <-- JVM NOT MANDATORY -->
+// <-- ENGLISH IMPOSED -->
+
+
+//
+// assert_close --
+// Returns 1 if the two real matrices computed and expected are close,
+// i.e. if the relative distance between computed and expected is lesser than epsilon.
+// Arguments
+// computed, expected : the two matrices to compare
+// epsilon : a small number
+//
+function flag = assert_close ( computed, expected, epsilon )
+ if expected==0.0 then
+ shift = norm(computed-expected);
+ else
+ shift = norm(computed-expected)/norm(expected);
+ end
+// if shift < epsilon then
+// flag = 1;
+// else
+// flag = 0;
+// end
+// if flag <> 1 then pause,end
+ flag = assert_checktrue ( shift < epsilon );
+endfunction
+//
+// assert_equal --
+// Returns 1 if the two real matrices computed and expected are equal.
+// Arguments
+// computed, expected : the two matrices to compare
+// epsilon : a small number
+//
+//function flag = assert_equal ( computed , expected )
+// if computed==expected then
+// flag = 1;
+// else
+// flag = 0;
+// end
+// if flag <> 1 then pause,end
+//endfunction
+
+//Find x in R such that it minimizes:
+//f(x)= 1/x^2
+//0 <= x <= 1000
+//Objective function to be minimised
+function y=f(x)
+y=1/x^2
+endfunction
+//Variable bounds
+x1 = [0];
+x2 = [1000];
+//Calling Ipopt
+[xopt,fval,exitflag,output,lambda] =fminbnd(f, x1, x2)
+
+assert_close ( xopt , [ 32.27955 ]' , 0.0005 );
+assert_close ( fval , [ 0.0009597 ]' , 0.0005 );
+assert_checkequal( exitflag , int32(0) );
+printf("Test Successful");
diff --git a/tests/unit_tests/fmincon.dia.ref b/tests/unit_tests/fmincon.dia.ref
new file mode 100644
index 0000000..26d29ea
--- /dev/null
+++ b/tests/unit_tests/fmincon.dia.ref
@@ -0,0 +1,98 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// Author: R.Vidyadhar & Vignesh Kannan
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+// <-- JVM NOT MANDATORY -->
+// <-- ENGLISH IMPOSED -->
+
+
+//
+// assert_close --
+// Returns 1 if the two real matrices computed and expected are close,
+// i.e. if the relative distance between computed and expected is lesser than epsilon.
+// Arguments
+// computed, expected : the two matrices to compare
+// epsilon : a small number
+//
+function flag = assert_close ( computed, expected, epsilon )
+ if expected==0.0 then
+ shift = norm(computed-expected);
+ else
+ shift = norm(computed-expected)/norm(expected);
+ end
+// if shift < epsilon then
+// flag = 1;
+// else
+// flag = 0;
+// end
+// if flag <> 1 then pause,end
+ flag = assert_checktrue ( shift < epsilon );
+endfunction
+//
+// assert_equal --
+// Returns 1 if the two real matrices computed and expected are equal.
+// Arguments
+// computed, expected : the two matrices to compare
+// epsilon : a small number
+//
+//function flag = assert_equal ( computed , expected )
+// if computed==expected then
+// flag = 1;
+// else
+// flag = 0;
+// end
+// if flag <> 1 then pause,end
+//endfunction
+
+//Find x in R^3 such that it minimizes:
+//f(x)= x1*x2 + x2*x3
+//x0=[0.1 , 0.1 , 0.1]
+//constraint-1 (c1): x1^2 - x2^2 + x3^2 <= 2
+//constraint-2 (c2): x1^2 + x2^2 + x3^2 <= 10
+//Objective function to be minimised
+function y=f(x)
+y=x(1)*x(2)+x(2)*x(3);
+endfunction
+//Starting point, linear constraints and variable bounds
+x0=[0.1 , 0.1 , 0.1];
+A=[];
+b=[];
+Aeq=[];
+beq=[];
+lb=[];
+ub=[];
+//Nonlinear constraints
+function [c,ceq]=nlc(x)
+c = [x(1)^2 - x(2)^2 + x(3)^2 - 2 , x(1)^2 + x(2)^2 + x(3)^2 - 10];
+ceq = [];
+endfunction
+//Gradient of objective function
+function y= fGrad(x)
+y= [x(2),x(1)+x(3),x(2)];
+endfunction
+//Hessian of the Lagrange Function
+function y= lHess(x,obj,lambda)
+y= obj*[0,1,0;1,0,1;0,1,0] + lambda(1)*[2,0,0;0,-2,0;0,0,2] + lambda(2)*[2,0,0;0,2,0;0,0,2]
+endfunction
+//Gradient of Non-Linear Constraints
+function [cg,ceqg] = cGrad(x)
+cg=[2*x(1) , -2*x(2) , 2*x(3) ; 2*x(1) , 2*x(2) , 2*x(3)];
+ceqg=[];
+endfunction
+//Options
+options=list("MaxIter", [1500], "CpuTime", [500], "GradObj", fGrad, "Hessian", lHess,"GradCon", cGrad);
+//Calling Ipopt
+[xopt,fval,exitflag,output] =fmincon(f, x0,A,b,Aeq,beq,lb,ub,nlc,options)
+
+assert_close ( xopt , [ -1.5811388 2.236068 -1.5811388 ]' , 0.0005 );
+assert_close ( fval , [-7.0710678 ]' , 0.0005 );
+assert_checkequal( exitflag , int32(0) );
+printf("Test Successful");
diff --git a/tests/unit_tests/fmincon.tst b/tests/unit_tests/fmincon.tst
new file mode 100644
index 0000000..26d29ea
--- /dev/null
+++ b/tests/unit_tests/fmincon.tst
@@ -0,0 +1,98 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// Author: R.Vidyadhar & Vignesh Kannan
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+// <-- JVM NOT MANDATORY -->
+// <-- ENGLISH IMPOSED -->
+
+
+//
+// assert_close --
+// Returns 1 if the two real matrices computed and expected are close,
+// i.e. if the relative distance between computed and expected is lesser than epsilon.
+// Arguments
+// computed, expected : the two matrices to compare
+// epsilon : a small number
+//
+function flag = assert_close ( computed, expected, epsilon )
+ if expected==0.0 then
+ shift = norm(computed-expected);
+ else
+ shift = norm(computed-expected)/norm(expected);
+ end
+// if shift < epsilon then
+// flag = 1;
+// else
+// flag = 0;
+// end
+// if flag <> 1 then pause,end
+ flag = assert_checktrue ( shift < epsilon );
+endfunction
+//
+// assert_equal --
+// Returns 1 if the two real matrices computed and expected are equal.
+// Arguments
+// computed, expected : the two matrices to compare
+// epsilon : a small number
+//
+//function flag = assert_equal ( computed , expected )
+// if computed==expected then
+// flag = 1;
+// else
+// flag = 0;
+// end
+// if flag <> 1 then pause,end
+//endfunction
+
+//Find x in R^3 such that it minimizes:
+//f(x)= x1*x2 + x2*x3
+//x0=[0.1 , 0.1 , 0.1]
+//constraint-1 (c1): x1^2 - x2^2 + x3^2 <= 2
+//constraint-2 (c2): x1^2 + x2^2 + x3^2 <= 10
+//Objective function to be minimised
+function y=f(x)
+y=x(1)*x(2)+x(2)*x(3);
+endfunction
+//Starting point, linear constraints and variable bounds
+x0=[0.1 , 0.1 , 0.1];
+A=[];
+b=[];
+Aeq=[];
+beq=[];
+lb=[];
+ub=[];
+//Nonlinear constraints
+function [c,ceq]=nlc(x)
+c = [x(1)^2 - x(2)^2 + x(3)^2 - 2 , x(1)^2 + x(2)^2 + x(3)^2 - 10];
+ceq = [];
+endfunction
+//Gradient of objective function
+function y= fGrad(x)
+y= [x(2),x(1)+x(3),x(2)];
+endfunction
+//Hessian of the Lagrange Function
+function y= lHess(x,obj,lambda)
+y= obj*[0,1,0;1,0,1;0,1,0] + lambda(1)*[2,0,0;0,-2,0;0,0,2] + lambda(2)*[2,0,0;0,2,0;0,0,2]
+endfunction
+//Gradient of Non-Linear Constraints
+function [cg,ceqg] = cGrad(x)
+cg=[2*x(1) , -2*x(2) , 2*x(3) ; 2*x(1) , 2*x(2) , 2*x(3)];
+ceqg=[];
+endfunction
+//Options
+options=list("MaxIter", [1500], "CpuTime", [500], "GradObj", fGrad, "Hessian", lHess,"GradCon", cGrad);
+//Calling Ipopt
+[xopt,fval,exitflag,output] =fmincon(f, x0,A,b,Aeq,beq,lb,ub,nlc,options)
+
+assert_close ( xopt , [ -1.5811388 2.236068 -1.5811388 ]' , 0.0005 );
+assert_close ( fval , [-7.0710678 ]' , 0.0005 );
+assert_checkequal( exitflag , int32(0) );
+printf("Test Successful");
diff --git a/tests/unit_tests/fminimax.dia.ref b/tests/unit_tests/fminimax.dia.ref
new file mode 100644
index 0000000..e887a38
--- /dev/null
+++ b/tests/unit_tests/fminimax.dia.ref
@@ -0,0 +1,105 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// Author: Animesh Baranawal
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+// <-- JVM NOT MANDATORY -->
+// <-- ENGLISH IMPOSED -->
+
+
+//
+// assert_close --
+// Returns 1 if the two real matrices computed and expected are close,
+// i.e. if the relative distance between computed and expected is lesser than epsilon.
+// Arguments
+// computed, expected : the two matrices to compare
+// epsilon : a small number
+//
+function flag = assert_close ( computed, expected, epsilon )
+ if expected==0.0 then
+ shift = norm(computed-expected);
+ else
+ shift = norm(computed-expected)/norm(expected);
+ end
+// if shift < epsilon then
+// flag = 1;
+// else
+// flag = 0;
+// end
+// if flag <> 1 then pause,end
+ flag = assert_checktrue ( shift < epsilon );
+endfunction
+//
+// assert_equal --
+// Returns 1 if the two real matrices computed and expected are equal.
+// Arguments
+// computed, expected : the two matrices to compare
+// epsilon : a small number
+//
+//function flag = assert_equal ( computed , expected )
+// if computed==expected then
+// flag = 1;
+// else
+// flag = 0;
+// end
+// if flag <> 1 then pause,end
+//endfunction
+
+// 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 = 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;
+endfunction
+// Defining gradient of myfun
+function G = myfungrad(x)
+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 and the Jacobian
+// matrix of the constraints
+function [c,ceq] = 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=[]
+endfunction
+// Defining gradient of confungrad
+function [DC,DCeq] = cgrad(x)
+// DC(:,i) = gradient of the i-th constraint
+// DC = [
+// Dc1/Dx1 Dc1/Dx2
+// Dc2/Dx1 Dc2/Dx2
+// ]
+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",myfungrad,"GradCon",cgrad);
+// The initial guess
+x0 = [0,10];
+// The expected solution : only 4 digits are guaranteed
+//xopt = [0.92791 7.93551]
+//fopt = [6.73443 -189.778 6.73443 -8.86342 0.86342]
+maxfopt = 6.73443
+// Run fminimax
+[xopt,fopt,maxfval,exitflag,output] = fminimax(myfun,x0,[],[],[],[],[],[], confun, minimaxOptions)
+
+assert_close ( xopt , [ 8.6737161 0.9348425 ]' , 0.0005 );
+assert_close ( fopt , [ 1.6085585 -77.855143 -6.5217563 -9.6085587 1.6085587 ]' , 0.0005 );
+assert_checkequal( exitflag , int32(0) );
+printf("Test Successful");
diff --git a/tests/unit_tests/fminimax.tst b/tests/unit_tests/fminimax.tst
new file mode 100644
index 0000000..e887a38
--- /dev/null
+++ b/tests/unit_tests/fminimax.tst
@@ -0,0 +1,105 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// Author: Animesh Baranawal
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+// <-- JVM NOT MANDATORY -->
+// <-- ENGLISH IMPOSED -->
+
+
+//
+// assert_close --
+// Returns 1 if the two real matrices computed and expected are close,
+// i.e. if the relative distance between computed and expected is lesser than epsilon.
+// Arguments
+// computed, expected : the two matrices to compare
+// epsilon : a small number
+//
+function flag = assert_close ( computed, expected, epsilon )
+ if expected==0.0 then
+ shift = norm(computed-expected);
+ else
+ shift = norm(computed-expected)/norm(expected);
+ end
+// if shift < epsilon then
+// flag = 1;
+// else
+// flag = 0;
+// end
+// if flag <> 1 then pause,end
+ flag = assert_checktrue ( shift < epsilon );
+endfunction
+//
+// assert_equal --
+// Returns 1 if the two real matrices computed and expected are equal.
+// Arguments
+// computed, expected : the two matrices to compare
+// epsilon : a small number
+//
+//function flag = assert_equal ( computed , expected )
+// if computed==expected then
+// flag = 1;
+// else
+// flag = 0;
+// end
+// if flag <> 1 then pause,end
+//endfunction
+
+// 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 = 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;
+endfunction
+// Defining gradient of myfun
+function G = myfungrad(x)
+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 and the Jacobian
+// matrix of the constraints
+function [c,ceq] = 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=[]
+endfunction
+// Defining gradient of confungrad
+function [DC,DCeq] = cgrad(x)
+// DC(:,i) = gradient of the i-th constraint
+// DC = [
+// Dc1/Dx1 Dc1/Dx2
+// Dc2/Dx1 Dc2/Dx2
+// ]
+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",myfungrad,"GradCon",cgrad);
+// The initial guess
+x0 = [0,10];
+// The expected solution : only 4 digits are guaranteed
+//xopt = [0.92791 7.93551]
+//fopt = [6.73443 -189.778 6.73443 -8.86342 0.86342]
+maxfopt = 6.73443
+// Run fminimax
+[xopt,fopt,maxfval,exitflag,output] = fminimax(myfun,x0,[],[],[],[],[],[], confun, minimaxOptions)
+
+assert_close ( xopt , [ 8.6737161 0.9348425 ]' , 0.0005 );
+assert_close ( fopt , [ 1.6085585 -77.855143 -6.5217563 -9.6085587 1.6085587 ]' , 0.0005 );
+assert_checkequal( exitflag , int32(0) );
+printf("Test Successful");
diff --git a/tests/unit_tests/fminunc.dia.ref b/tests/unit_tests/fminunc.dia.ref
new file mode 100644
index 0000000..d8cc387
--- /dev/null
+++ b/tests/unit_tests/fminunc.dia.ref
@@ -0,0 +1,79 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// Author: R.Vidyadhar & Vignesh Kannan
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+// <-- JVM NOT MANDATORY -->
+// <-- ENGLISH IMPOSED -->
+
+
+//
+// assert_close --
+// Returns 1 if the two real matrices computed and expected are close,
+// i.e. if the relative distance between computed and expected is lesser than epsilon.
+// Arguments
+// computed, expected : the two matrices to compare
+// epsilon : a small number
+//
+function flag = assert_close ( computed, expected, epsilon )
+ if expected==0.0 then
+ shift = norm(computed-expected);
+ else
+ shift = norm(computed-expected)/norm(expected);
+ end
+// if shift < epsilon then
+// flag = 1;
+// else
+// flag = 0;
+// end
+// if flag <> 1 then pause,end
+ flag = assert_checktrue ( shift < epsilon );
+endfunction
+//
+// assert_equal --
+// Returns 1 if the two real matrices computed and expected are equal.
+// Arguments
+// computed, expected : the two matrices to compare
+// epsilon : a small number
+//
+//function flag = assert_equal ( computed , expected )
+// if computed==expected then
+// flag = 1;
+// else
+// flag = 0;
+// end
+// if flag <> 1 then pause,end
+//endfunction
+
+//Find x in R^2 such that it minimizes the Rosenbrock function
+//f = 100*(x2 - x1^2)^2 + (1-x1)^2
+//Objective function to be minimised
+function y= f(x)
+y= 100*(x(2) - x(1)^2)^2 + (1-x(1))^2;
+endfunction
+//Starting point
+x0=[-1,2];
+//Gradient of objective function
+function y= fGrad(x)
+y= [-400*x(1)*x(2) + 400*x(1)^3 + 2*x(1)-2, 200*(x(2)-x(1)^2)];
+endfunction
+//Hessian of Objective Function
+function y= fHess(x)
+y= [1200*x(1)^2- 400*x(2) + 2, -400*x(1);-400*x(1), 200 ];
+endfunction
+//Options
+options=list("MaxIter", [1500], "CpuTime", [500], "Gradient", fGrad, "Hessian", fHess);
+//Calling Ipopt
+[xopt,fopt,exitflag,output,gradient,hessian]=fminunc(f,x0,options)
+
+assert_close ( xopt , [ 1 1 ]' , 0.0005 );
+assert_close ( fopt , [0] , 0.0005 );
+assert_checkequal( exitflag , int32(0) );
+printf("Test Successful");
diff --git a/tests/unit_tests/fminunc.tst b/tests/unit_tests/fminunc.tst
new file mode 100644
index 0000000..d8cc387
--- /dev/null
+++ b/tests/unit_tests/fminunc.tst
@@ -0,0 +1,79 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// Author: R.Vidyadhar & Vignesh Kannan
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+// <-- JVM NOT MANDATORY -->
+// <-- ENGLISH IMPOSED -->
+
+
+//
+// assert_close --
+// Returns 1 if the two real matrices computed and expected are close,
+// i.e. if the relative distance between computed and expected is lesser than epsilon.
+// Arguments
+// computed, expected : the two matrices to compare
+// epsilon : a small number
+//
+function flag = assert_close ( computed, expected, epsilon )
+ if expected==0.0 then
+ shift = norm(computed-expected);
+ else
+ shift = norm(computed-expected)/norm(expected);
+ end
+// if shift < epsilon then
+// flag = 1;
+// else
+// flag = 0;
+// end
+// if flag <> 1 then pause,end
+ flag = assert_checktrue ( shift < epsilon );
+endfunction
+//
+// assert_equal --
+// Returns 1 if the two real matrices computed and expected are equal.
+// Arguments
+// computed, expected : the two matrices to compare
+// epsilon : a small number
+//
+//function flag = assert_equal ( computed , expected )
+// if computed==expected then
+// flag = 1;
+// else
+// flag = 0;
+// end
+// if flag <> 1 then pause,end
+//endfunction
+
+//Find x in R^2 such that it minimizes the Rosenbrock function
+//f = 100*(x2 - x1^2)^2 + (1-x1)^2
+//Objective function to be minimised
+function y= f(x)
+y= 100*(x(2) - x(1)^2)^2 + (1-x(1))^2;
+endfunction
+//Starting point
+x0=[-1,2];
+//Gradient of objective function
+function y= fGrad(x)
+y= [-400*x(1)*x(2) + 400*x(1)^3 + 2*x(1)-2, 200*(x(2)-x(1)^2)];
+endfunction
+//Hessian of Objective Function
+function y= fHess(x)
+y= [1200*x(1)^2- 400*x(2) + 2, -400*x(1);-400*x(1), 200 ];
+endfunction
+//Options
+options=list("MaxIter", [1500], "CpuTime", [500], "Gradient", fGrad, "Hessian", fHess);
+//Calling Ipopt
+[xopt,fopt,exitflag,output,gradient,hessian]=fminunc(f,x0,options)
+
+assert_close ( xopt , [ 1 1 ]' , 0.0005 );
+assert_close ( fopt , [0] , 0.0005 );
+assert_checkequal( exitflag , int32(0) );
+printf("Test Successful");
diff --git a/tests/unit_tests/linprog.dia.ref b/tests/unit_tests/linprog.dia.ref
new file mode 100644
index 0000000..5c3d629
--- /dev/null
+++ b/tests/unit_tests/linprog.dia.ref
@@ -0,0 +1,68 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// Author: Guru Pradeep Reddy, Bhanu Priya Sayal
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+// <-- JVM NOT MANDATORY -->
+// <-- ENGLISH IMPOSED -->
+
+
+//
+// assert_close --
+// Returns 1 if the two real matrices computed and expected are close,
+// i.e. if the relative distance between computed and expected is lesser than epsilon.
+// Arguments
+// computed, expected : the two matrices to compare
+// epsilon : a small number
+//
+function flag = assert_close ( computed, expected, epsilon )
+ if expected==0.0 then
+ shift = norm(computed-expected);
+ else
+ shift = norm(computed-expected)/norm(expected);
+ end
+// if shift < epsilon then
+// flag = 1;
+// else
+// flag = 0;
+// end
+// if flag <> 1 then pause,end
+ flag = assert_checktrue ( shift < epsilon );
+endfunction
+//
+// assert_equal --
+// Returns 1 if the two real matrices computed and expected are equal.
+// Arguments
+// computed, expected : the two matrices to compare
+// epsilon : a small number
+//
+//function flag = assert_equal ( computed , expected )
+// if computed==expected then
+// flag = 1;
+// else
+// flag = 0;
+// end
+// if flag <> 1 then pause,end
+//endfunction
+
+//Linear program with all constraint types
+c=[-1,-1/3]'
+A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
+b=[2,1,2,1,-1,2]
+Aeq=[1,1/4]
+beq=[1/2]
+lb=[-1,-0.5]
+ub=[1.5,1.25]
+[xopt,fopt,exitflag,output,lambda]=linprog(c, A, b, Aeq, beq, lb, ub)
+
+assert_close ( xopt , [ 0.1875 1.25 ]' , 0.0005 );
+assert_close ( fopt , [ -0.6041667 ]' , 0.0005 );
+assert_checkequal( exitflag , 0 );
+printf("Test Successful");
diff --git a/tests/unit_tests/linprog.tst b/tests/unit_tests/linprog.tst
new file mode 100644
index 0000000..5c3d629
--- /dev/null
+++ b/tests/unit_tests/linprog.tst
@@ -0,0 +1,68 @@
+// Copyright (C) 2015 - IIT Bombay - FOSSEE
+//
+// Author: Guru Pradeep Reddy, Bhanu Priya Sayal
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+// <-- JVM NOT MANDATORY -->
+// <-- ENGLISH IMPOSED -->
+
+
+//
+// assert_close --
+// Returns 1 if the two real matrices computed and expected are close,
+// i.e. if the relative distance between computed and expected is lesser than epsilon.
+// Arguments
+// computed, expected : the two matrices to compare
+// epsilon : a small number
+//
+function flag = assert_close ( computed, expected, epsilon )
+ if expected==0.0 then
+ shift = norm(computed-expected);
+ else
+ shift = norm(computed-expected)/norm(expected);
+ end
+// if shift < epsilon then
+// flag = 1;
+// else
+// flag = 0;
+// end
+// if flag <> 1 then pause,end
+ flag = assert_checktrue ( shift < epsilon );
+endfunction
+//
+// assert_equal --
+// Returns 1 if the two real matrices computed and expected are equal.
+// Arguments
+// computed, expected : the two matrices to compare
+// epsilon : a small number
+//
+//function flag = assert_equal ( computed , expected )
+// if computed==expected then
+// flag = 1;
+// else
+// flag = 0;
+// end
+// if flag <> 1 then pause,end
+//endfunction
+
+//Linear program with all constraint types
+c=[-1,-1/3]'
+A=[1,1;1,1/4;1,-1;-1/4,-1;-1,-1;-1,1]
+b=[2,1,2,1,-1,2]
+Aeq=[1,1/4]
+beq=[1/2]
+lb=[-1,-0.5]
+ub=[1.5,1.25]
+[xopt,fopt,exitflag,output,lambda]=linprog(c, A, b, Aeq, beq, lb, ub)
+
+assert_close ( xopt , [ 0.1875 1.25 ]' , 0.0005 );
+assert_close ( fopt , [ -0.6041667 ]' , 0.0005 );
+assert_checkequal( exitflag , 0 );
+printf("Test Successful");
diff --git a/tests/unit_tests/qpipopt_base.dia.ref b/tests/unit_tests/qpipopt_base.dia.ref
index 25b440f..d85ed3e 100644
--- a/tests/unit_tests/qpipopt_base.dia.ref
+++ b/tests/unit_tests/qpipopt_base.dia.ref
@@ -68,9 +68,9 @@ nbVar = 6;
nbCon = 5;
x0 = repmat(0,nbVar,1);
param = list("MaxIter", 300, "CpuTime", 100);
-[xopt,fopt,exitflag,output,lambda] = qpipopt(nbVar,nbCon,Q,p,lb,ub,conMatrix,conLB,conUB,x0,param)
+[xopt,fopt,exitflag,output,lambda] = qpipopt(nbVar,nbCon,H,f,lb,ub,A,conLB,conUB,x0,param)
-assert_close ( xopt , [1.7975426 -0.3381487 0.1633880 - 4.9884023 0.6054943 -3.1155623]' , 1.e-7 );
+assert_close ( xopt , [1.7975426 -0.3381487 0.1633880 -4.9884023 0.6054943 -3.1155623]' , 1.e-7 );
assert_close ( fopt , [ -14.843248] , 1.e-7 );
assert_checkequal( exitflag , int32(0) );
printf("Test Successful");
diff --git a/tests/unit_tests/qpipopt_base.tst b/tests/unit_tests/qpipopt_base.tst
index 25b440f..d85ed3e 100644
--- a/tests/unit_tests/qpipopt_base.tst
+++ b/tests/unit_tests/qpipopt_base.tst
@@ -68,9 +68,9 @@ nbVar = 6;
nbCon = 5;
x0 = repmat(0,nbVar,1);
param = list("MaxIter", 300, "CpuTime", 100);
-[xopt,fopt,exitflag,output,lambda] = qpipopt(nbVar,nbCon,Q,p,lb,ub,conMatrix,conLB,conUB,x0,param)
+[xopt,fopt,exitflag,output,lambda] = qpipopt(nbVar,nbCon,H,f,lb,ub,A,conLB,conUB,x0,param)
-assert_close ( xopt , [1.7975426 -0.3381487 0.1633880 - 4.9884023 0.6054943 -3.1155623]' , 1.e-7 );
+assert_close ( xopt , [1.7975426 -0.3381487 0.1633880 -4.9884023 0.6054943 -3.1155623]' , 1.e-7 );
assert_close ( fopt , [ -14.843248] , 1.e-7 );
assert_checkequal( exitflag , int32(0) );
printf("Test Successful");
diff --git a/tests/unit_tests/qpipoptmat_base.dia.ref b/tests/unit_tests/qpipoptmat_base.dia.ref
index fbebe58..fdc2293 100644
--- a/tests/unit_tests/qpipoptmat_base.dia.ref
+++ b/tests/unit_tests/qpipoptmat_base.dia.ref
@@ -67,7 +67,7 @@ param = list("MaxIter", 300, "CpuTime",100);
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);
-assert_close ( xopt , [1.7975426 -0.3381487 0.1633880 - 4.9884023 0.6054943 -3.1155623]' , 1.e-7 );
+assert_close ( xopt , [1.7975426 -0.3381487 0.1633880 -4.9884023 0.6054943 -3.1155623]' , 1.e-7 );
assert_close ( fopt , [ -14.843248] , 1.e-7 );
assert_checkequal( exitflag , int32(0) );
printf("Test Successful");
diff --git a/tests/unit_tests/qpipoptmat_base.tst b/tests/unit_tests/qpipoptmat_base.tst
index fbebe58..fdc2293 100644
--- a/tests/unit_tests/qpipoptmat_base.tst
+++ b/tests/unit_tests/qpipoptmat_base.tst
@@ -67,7 +67,7 @@ param = list("MaxIter", 300, "CpuTime",100);
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);
-assert_close ( xopt , [1.7975426 -0.3381487 0.1633880 - 4.9884023 0.6054943 -3.1155623]' , 1.e-7 );
+assert_close ( xopt , [1.7975426 -0.3381487 0.1633880 -4.9884023 0.6054943 -3.1155623]' , 1.e-7 );
assert_close ( fopt , [ -14.843248] , 1.e-7 );
assert_checkequal( exitflag , int32(0) );
printf("Test Successful");