diff options
author | Harpreet | 2016-01-29 16:38:03 +0530 |
---|---|---|
committer | Harpreet | 2016-01-29 16:38:03 +0530 |
commit | f7c5cbc61d5b52c749824298cfa39a95db2d879c (patch) | |
tree | 27aafcca0159b7b3bb2926ff3a9c6c25834980d2 /tests/general_tests/linprog | |
parent | 2db803c34c6df02379ec88df3a7aa186700d9fbf (diff) | |
download | FOSSEE-Optimization-toolbox-f7c5cbc61d5b52c749824298cfa39a95db2d879c.tar.gz FOSSEE-Optimization-toolbox-f7c5cbc61d5b52c749824298cfa39a95db2d879c.tar.bz2 FOSSEE-Optimization-toolbox-f7c5cbc61d5b52c749824298cfa39a95db2d879c.zip |
linprog general tests added
Diffstat (limited to 'tests/general_tests/linprog')
18 files changed, 440 insertions, 0 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) + |