diff options
Diffstat (limited to 'tests/general_tests/lsqlin')
-rw-r--r-- | tests/general_tests/lsqlin/lsqlin_A1.sce | 28 | ||||
-rw-r--r-- | tests/general_tests/lsqlin/lsqlin_Aeq1.sce | 29 | ||||
-rw-r--r-- | tests/general_tests/lsqlin/lsqlin_C1.sce | 26 | ||||
-rw-r--r-- | tests/general_tests/lsqlin/lsqlin_b1.sce | 23 | ||||
-rw-r--r-- | tests/general_tests/lsqlin/lsqlin_beq1.sce | 23 | ||||
-rw-r--r-- | tests/general_tests/lsqlin/lsqlin_infeasible1.sce | 29 | ||||
-rw-r--r-- | tests/general_tests/lsqlin/lsqlin_input1.sce | 27 | ||||
-rw-r--r-- | tests/general_tests/lsqlin/lsqlin_input2.sce | 26 | ||||
-rw-r--r-- | tests/general_tests/lsqlin/lsqlin_logical1.sce | 54 | ||||
-rw-r--r-- | tests/general_tests/lsqlin/lsqlin_maxiter.sce | 42 | ||||
-rw-r--r-- | tests/general_tests/lsqlin/lsqlin_param1.sce | 26 | ||||
-rw-r--r-- | tests/general_tests/lsqlin/lsqlin_param2.sce | 26 | ||||
-rw-r--r-- | tests/general_tests/lsqlin/lsqlin_param3.sce | 26 | ||||
-rw-r--r-- | tests/general_tests/lsqlin/lsqlin_x01.sce | 52 | ||||
-rw-r--r-- | tests/general_tests/lsqlin/lsqlin_zeros.sce | 32 |
15 files changed, 228 insertions, 241 deletions
diff --git a/tests/general_tests/lsqlin/lsqlin_A1.sce b/tests/general_tests/lsqlin/lsqlin_A1.sce index ba9b5be..1c2128b 100644 --- a/tests/general_tests/lsqlin/lsqlin_A1.sce +++ b/tests/general_tests/lsqlin/lsqlin_A1.sce @@ -1,23 +1,17 @@ // Check for elements in A -C = [0.9501 0.7620 0.6153 0.4057 - 0.2311 0.4564 0.7919 0.9354 - 0.6068 0.0185 0.9218 0.9169 - 0.4859 0.8214 0.7382 0.4102 - 0.8912 0.4447 0.1762 0.8936]; -d = [0.0578 - 0.3528 - 0.8131 - 0.0098 - 0.1388]; -A = [0.2027 0.2721 0.7467 0.4659 0 - 0.1987 0.1988 0.4450 0.4186 0 - 0.6037 0.0152 0.9318 0.8462 0]; -b = [0.5251 - 0.2026 - 0.6721]; +C = [2 0; + -1 1; + 0 2] +d = [1 + 0 + -1]; +A = [10 -2 0; + -2 10 0]; +b = [4 + -4]; //Error -//lsqlin: The number of columns in A must be the same as the number of elements of d +//lsqlin: The number of columns in A must be the same as the number of columns in C //at line 213 of function lsqlin called by : //[xopt,resnorm,residual,exitflag,output,lambda] = lsqlin(C,d,A,b) diff --git a/tests/general_tests/lsqlin/lsqlin_Aeq1.sce b/tests/general_tests/lsqlin/lsqlin_Aeq1.sce index 458cbb0..f574e9d 100644 --- a/tests/general_tests/lsqlin/lsqlin_Aeq1.sce +++ b/tests/general_tests/lsqlin/lsqlin_Aeq1.sce @@ -1,23 +1,18 @@ // Check for elements in Aeq -C = [0.9501 0.7620 0.6153 0.4057 - 0.2311 0.4564 0.7919 0.9354 - 0.6068 0.0185 0.9218 0.9169 - 0.4859 0.8214 0.7382 0.4102 - 0.8912 0.4447 0.1762 0.8936]; -d = [0.0578 - 0.3528 - 0.8131 - 0.0098 - 0.1388]; -Aeq = [0.2027 0.2721 0.7467 0.4659 0 - 0.1987 0.1988 0.4450 0.4186 0 - 0.6037 0.0152 0.9318 0.8462 0]; -beq = [0.5251 - 0.2026 - 0.6721]; + C = [2 0; + -1 1; + 0 2] + d = [1 + 0 + -1]; + Aeq = [10 -2 0; + -2 10 0]; + beq = [4 + -4]; + //Error -//lsqlin: The number of columns in Aeq must be the same as the number of elements of d +//lsqlin: The number of columns in Aeq must be the same as the number of columns in C //at line 219 of function lsqlin called by : //[xopt,resnorm,residual,exitflag,output,lambda] = lsqlin(C,d,[],[],Aeq,beq) diff --git a/tests/general_tests/lsqlin/lsqlin_C1.sce b/tests/general_tests/lsqlin/lsqlin_C1.sce index 55fe976..6da1d49 100644 --- a/tests/general_tests/lsqlin/lsqlin_C1.sce +++ b/tests/general_tests/lsqlin/lsqlin_C1.sce @@ -1,21 +1,13 @@ // Check for elements in C and d -C = [0.9501 0.7620 0.6153 0.4057 - 0.2311 0.4564 0.7919 0.9354 - 0.6068 0.0185 0.9218 0.9169 - 0.4859 0.8214 0.7382 0.4102 - 0.8912 0.4447 0.1762 0.8936]; -d = [0.0578 - 0.3528 - 0.8131 - 0.0098 - 0.1388 - 0.2536]; -A = [0.2027 0.2721 0.7467 0.4659 - 0.1987 0.1988 0.4450 0.4186 - 0.6037 0.0152 0.9318 0.8462]; -b = [0.5251 - 0.2026 - 0.6721]; +C = [2 0; + -1 1; + 0 2] +d = [1 + 0]; +A = [10 -2; + -2 10]; +b = [4 + -4]; //Error //lsqlin: The number of rows in C must be equal the number of elements of d diff --git a/tests/general_tests/lsqlin/lsqlin_b1.sce b/tests/general_tests/lsqlin/lsqlin_b1.sce index 49b6dec..fb01b79 100644 --- a/tests/general_tests/lsqlin/lsqlin_b1.sce +++ b/tests/general_tests/lsqlin/lsqlin_b1.sce @@ -1,18 +1,13 @@ // Check for elements in b -C = [0.9501 0.7620 0.6153 0.4057 - 0.2311 0.4564 0.7919 0.9354 - 0.6068 0.0185 0.9218 0.9169 - 0.4859 0.8214 0.7382 0.4102 - 0.8912 0.4447 0.1762 0.8936]; -d = [0.0578 - 0.3528 - 0.8131 - 0.0098 - 0.1388]; -A = [0.2027 0.2721 0.7467 0.4659 - 0.1987 0.1988 0.4450 0.4186 - 0.6037 0.0152 0.9318 0.8462]; -b = [-%inf -%inf -%inf]; +C = [2 0; + -1 1; + 0 2] +d = [1 + 0 + -1]; +A = [10 -2; + -2 10]; +b = [-%inf -%inf]; //Error //lsqlin: Value of b can not be negative infinity diff --git a/tests/general_tests/lsqlin/lsqlin_beq1.sce b/tests/general_tests/lsqlin/lsqlin_beq1.sce index b71486e..38056c0 100644 --- a/tests/general_tests/lsqlin/lsqlin_beq1.sce +++ b/tests/general_tests/lsqlin/lsqlin_beq1.sce @@ -1,18 +1,13 @@ // Check for elements in beq -C = [0.9501 0.7620 0.6153 0.4057 - 0.2311 0.4564 0.7919 0.9354 - 0.6068 0.0185 0.9218 0.9169 - 0.4859 0.8214 0.7382 0.4102 - 0.8912 0.4447 0.1762 0.8936]; -d = [0.0578 - 0.3528 - 0.8131 - 0.0098 - 0.1388]; -Aeq = [0.2027 0.2721 0.7467 0.4659 - 0.1987 0.1988 0.4450 0.4186 - 0.6037 0.0152 0.9318 0.8462]; -beq = [-%inf -%inf -%inf]; +C = [2 0; + -1 1; + 0 2] +d = [1 + 0 + -1]; +Aeq = [10 -2; + -2 10]; +beq = [-%inf -%inf]; //Error //lsqlin: Value of beq can not be negative infinity diff --git a/tests/general_tests/lsqlin/lsqlin_infeasible1.sce b/tests/general_tests/lsqlin/lsqlin_infeasible1.sce index a66dd0f..9509309 100644 --- a/tests/general_tests/lsqlin/lsqlin_infeasible1.sce +++ b/tests/general_tests/lsqlin/lsqlin_infeasible1.sce @@ -1,15 +1,11 @@ // Check for the infeasible problem -C = [0.9501 0.7620 0.6153 0.4057 - 0.2311 0.4564 0.7919 0.9354 - 0.6068 0.0185 0.9218 0.9169 - 0.4859 0.8214 0.7382 0.4102 - 0.8912 0.4447 0.1762 0.8936]; -d = [0.0578 - 0.3528 - 0.8131 - 0.0098 - 0.1388]; -Aeq = [-1 0 0 0; 0 -1 0 0; 1 1 0 0 ]; +C = [2 0 0; + -1 1 0; + 0 2 0] +d = [1 + 0 + -1]; +Aeq = [-1 0 0; 0 -1 0; 1 1 0 ]; beq = [-6 -6 11]; //Converged to a point of local infeasibility. @@ -27,17 +23,14 @@ beq = [-6 -6 11]; // 5 // residual = // -// 0.0578 -// 0.3528 -// 0.8131 -// 0.0098 -// 0.1388 +// 1. +// 0. +// - 1. // resnorm = // -// 0.8083018 +// 2. // xopt = // // [] - [xopt,resnorm,residual,exitflag,output,lambda] = lsqlin(C,d,[],[],Aeq,beq) diff --git a/tests/general_tests/lsqlin/lsqlin_input1.sce b/tests/general_tests/lsqlin/lsqlin_input1.sce index 7521f61..5b97670 100644 --- a/tests/general_tests/lsqlin/lsqlin_input1.sce +++ b/tests/general_tests/lsqlin/lsqlin_input1.sce @@ -1,21 +1,14 @@ // Check for the input arguments -C = [0.9501 0.7620 0.6153 0.4057 - 0.2311 0.4564 0.7919 0.9354 - 0.6068 0.0185 0.9218 0.9169 - 0.4859 0.8214 0.7382 0.4102 - 0.8912 0.4447 0.1762 0.8936]; -d = [0.0578 - 0.3528 - 0.8131 - 0.0098 - 0.1388]; -A = [0.2027 0.2721 0.7467 0.4659 - 0.1987 0.1988 0.4450 0.4186 - 0.6037 0.0152 0.9318 0.8462]; -b = [0.5251 - 0.2026 - 0.6721]; - +C = [2 0; + -1 1; + 0 2] +d = [1 + 0 + -1]; +A = [10 -2; + -2 10]; +b = [4 + -4]; //Error //lsqlin: Unexpected number of input arguments : 2 provided while should be in the set of [4 6 8 9 10] //at line 99 of function lsqlin called by : diff --git a/tests/general_tests/lsqlin/lsqlin_input2.sce b/tests/general_tests/lsqlin/lsqlin_input2.sce index 9826583..dbfe187 100644 --- a/tests/general_tests/lsqlin/lsqlin_input2.sce +++ b/tests/general_tests/lsqlin/lsqlin_input2.sce @@ -1,20 +1,14 @@ // Check for the input arguments -C = [0.9501 0.7620 0.6153 0.4057 - 0.2311 0.4564 0.7919 0.9354 - 0.6068 0.0185 0.9218 0.9169 - 0.4859 0.8214 0.7382 0.4102 - 0.8912 0.4447 0.1762 0.8936]; -d = [0.0578 - 0.3528 - 0.8131 - 0.0098 - 0.1388]; -A = [0.2027 0.2721 0.7467 0.4659 - 0.1987 0.1988 0.4450 0.4186 - 0.6037 0.0152 0.9318 0.8462]; -b = [0.5251 - 0.2026 - 0.6721]; +C = [2 0; + -1 1; + 0 2] +d = [1 + 0 + -1]; +A = [10 -2; + -2 10]; +b = [4 + -4]; //Error //lsqlin: Unexpected number of input arguments : 14 provided while should be in the set of [4 6 8 9 10] diff --git a/tests/general_tests/lsqlin/lsqlin_logical1.sce b/tests/general_tests/lsqlin/lsqlin_logical1.sce index bc0dc06..959cc7c 100644 --- a/tests/general_tests/lsqlin/lsqlin_logical1.sce +++ b/tests/general_tests/lsqlin/lsqlin_logical1.sce @@ -1,51 +1,41 @@ -// Check for elements in A -C = [0.9501 0.7620 0.6153 0.4057 - 0.2311 0.4564 0.7919 0.9354 - 0.6068 0.0185 0.9218 0.9169 - 0.4859 0.8214 0.7382 0.4102 - 0.8912 0.4447 0.1762 0.8936]; -d = [0.0578 - 0.3528 - 0.8131 - 0.0098 - 0.1388]; -A = [0.2027 0.2721 0.7467 0.4659 - 0.1987 0.1988 0.4450 0.4186 - 0.6037 0.0152 0.9318 0.8462]; -b = [0.5251 - 0.2026 - 0.6721]; +// An example with inequality constraints +C = [2 0; + -1 1; + 0 2] +d = [1 + 0 + -1]; +A = [10 -2; + -2 10]; +b = [4 + -4]; -// Output +//Output //Optimal Solution Found. // lambda = // -// lower: [0,0,0,0] -// upper: [0,0,0,0] +// lower: [0,0] +// upper: [0,0] // eqlin: [0x0 constant] -// ineqlin: [8.697D-11,0.0925859,0.1118582] +// ineqlin: [0.0000422,0.0000089] // output = // -// Iterations: 7 +// Iterations: 13 // exitflag = // // 0 // residual = // -// 0.0126031 -// 0.0208054 -// 0.1295085 -// 0.0057397 -// - 0.0137246 +// 0.3335021 +// 0.6666002 +// - 0.3332976 // resnorm = // -// 0.0175855 +// 0.6666667 // xopt = // -// 0.1298639 -// - 0.5756958 -// 0.4251033 -// 0.2438436 +// 0.3332490 +// - 0.3333512 [xopt,resnorm,residual,exitflag,output,lambda] = lsqlin(C,d,A,b) diff --git a/tests/general_tests/lsqlin/lsqlin_maxiter.sce b/tests/general_tests/lsqlin/lsqlin_maxiter.sce new file mode 100644 index 0000000..036cf39 --- /dev/null +++ b/tests/general_tests/lsqlin/lsqlin_maxiter.sce @@ -0,0 +1,42 @@ +// Check for maxiter +C = [2 0; + -1 1; + 0 2] +d = [1 + 0 + -1]; +A = [10 -2; + -2 10]; +b = [4 + -4]; +options = list("MaxIter",1); +// Output +//Maximum Number of Iterations Exceeded. Output may not be optimal. +// lambda = +// +// lower: [0x0 constant] +// upper: [0x0 constant] +// eqlin: [0x0 constant] +// ineqlin: [0x0 constant] +// output = +// +// Iterations: 1 +// exitflag = +// +// 1 +// residual = +// +// 1.0243179 +// 0.3941271 +// - 0.1874278 +// resnorm = +// +// 1.2396926 +// xopt = +// +// - 0.0121590 +// - 0.4062861 + +[xopt,resnorm,residual,exitflag,output,lambda] = lsqlin(C,d,A,b,[],[],[],[],[],options) + + diff --git a/tests/general_tests/lsqlin/lsqlin_param1.sce b/tests/general_tests/lsqlin/lsqlin_param1.sce index a9d24bc..65aff86 100644 --- a/tests/general_tests/lsqlin/lsqlin_param1.sce +++ b/tests/general_tests/lsqlin/lsqlin_param1.sce @@ -1,20 +1,14 @@ // Check for the param to be a list -C = [0.9501 0.7620 0.6153 0.4057 - 0.2311 0.4564 0.7919 0.9354 - 0.6068 0.0185 0.9218 0.9169 - 0.4859 0.8214 0.7382 0.4102 - 0.8912 0.4447 0.1762 0.8936]; -d = [0.0578 - 0.3528 - 0.8131 - 0.0098 - 0.1388]; -A = [0.2027 0.2721 0.7467 0.4659 - 0.1987 0.1988 0.4450 0.4186 - 0.6037 0.0152 0.9318 0.8462]; -b = [0.5251 - 0.2026 - 0.6721]; +C = [2 0; + -1 1; + 0 2] +d = [1 + 0 + -1]; +A = [10 -2; + -2 10]; +b = [4 + -4]; param = 0; //Error diff --git a/tests/general_tests/lsqlin/lsqlin_param2.sce b/tests/general_tests/lsqlin/lsqlin_param2.sce index bb7cffa..f780759 100644 --- a/tests/general_tests/lsqlin/lsqlin_param2.sce +++ b/tests/general_tests/lsqlin/lsqlin_param2.sce @@ -1,20 +1,14 @@ // Check for the param to be even in number -C = [0.9501 0.7620 0.6153 0.4057 - 0.2311 0.4564 0.7919 0.9354 - 0.6068 0.0185 0.9218 0.9169 - 0.4859 0.8214 0.7382 0.4102 - 0.8912 0.4447 0.1762 0.8936]; -d = [0.0578 - 0.3528 - 0.8131 - 0.0098 - 0.1388]; -A = [0.2027 0.2721 0.7467 0.4659 - 0.1987 0.1988 0.4450 0.4186 - 0.6037 0.0152 0.9318 0.8462]; -b = [0.5251 - 0.2026 - 0.6721]; +C = [2 0; + -1 1; + 0 2] +d = [1 + 0 + -1]; +A = [10 -2; + -2 10]; +b = [4 + -4]; param = list("MaxIter"); //Error diff --git a/tests/general_tests/lsqlin/lsqlin_param3.sce b/tests/general_tests/lsqlin/lsqlin_param3.sce index 60e960d..283c6e2 100644 --- a/tests/general_tests/lsqlin/lsqlin_param3.sce +++ b/tests/general_tests/lsqlin/lsqlin_param3.sce @@ -1,20 +1,14 @@ // Check for the param to be even in number -C = [0.9501 0.7620 0.6153 0.4057 - 0.2311 0.4564 0.7919 0.9354 - 0.6068 0.0185 0.9218 0.9169 - 0.4859 0.8214 0.7382 0.4102 - 0.8912 0.4447 0.1762 0.8936]; -d = [0.0578 - 0.3528 - 0.8131 - 0.0098 - 0.1388]; -A = [0.2027 0.2721 0.7467 0.4659 - 0.1987 0.1988 0.4450 0.4186 - 0.6037 0.0152 0.9318 0.8462]; -b = [0.5251 - 0.2026 - 0.6721]; +C = [2 0; + -1 1; + 0 2] +d = [1 + 0 + -1]; +A = [10 -2; + -2 10]; +b = [4 + -4]; param = list("Iter",300); //Error diff --git a/tests/general_tests/lsqlin/lsqlin_x01.sce b/tests/general_tests/lsqlin/lsqlin_x01.sce index 3b0f6f9..d014443 100644 --- a/tests/general_tests/lsqlin/lsqlin_x01.sce +++ b/tests/general_tests/lsqlin/lsqlin_x01.sce @@ -1,20 +1,14 @@ -// Check for elements in A -C = [0.9501 0.7620 0.6153 0.4057 - 0.2311 0.4564 0.7919 0.9354 - 0.6068 0.0185 0.9218 0.9169 - 0.4859 0.8214 0.7382 0.4102 - 0.8912 0.4447 0.1762 0.8936]; -d = [0.0578 - 0.3528 - 0.8131 - 0.0098 - 0.1388]; -A = [0.2027 0.2721 0.7467 0.4659 - 0.1987 0.1988 0.4450 0.4186 - 0.6037 0.0152 0.9318 0.8462]; -b = [0.5251 - 0.2026 - 0.6721]; +// Test for intial guess +C = [2 0; + -1 1; + 0 2] +d = [1 + 0 + -1]; +A = [10 -2; + -2 10]; +b = [4 + -4]; x0 = [0 0 0]; //WARNING: lsqlin: Ignoring initial guess of variables as it is not equal to the number of variables @@ -22,32 +16,28 @@ x0 = [0 0 0]; //Optimal Solution Found. // lambda = // -// lower: [0,0,0,0] -// upper: [0,0,0,0] +// lower: [0,0] +// upper: [0,0] // eqlin: [0x0 constant] -// ineqlin: [8.697D-11,0.0925859,0.1118582] +// ineqlin: [0.0000422,0.0000089] // output = // -// Iterations: 7 +// Iterations: 13 // exitflag = // // 0 // residual = // -// 0.0126031 -// 0.0208054 -// 0.1295085 -// 0.0057397 -// - 0.0137246 +// 0.3335021 +// 0.6666002 +// - 0.3332976 // resnorm = // -// 0.0175855 +// 0.6666667 // xopt = // -// 0.1298639 -// - 0.5756958 -// 0.4251033 -// 0.2438436 +// 0.3332490 +// - 0.3333512 [xopt,resnorm,residual,exitflag,output,lambda] = lsqlin(C,d,A,b,[],[],[],[],x0) diff --git a/tests/general_tests/lsqlin/lsqlin_zeros.sce b/tests/general_tests/lsqlin/lsqlin_zeros.sce new file mode 100644 index 0000000..2695ff1 --- /dev/null +++ b/tests/general_tests/lsqlin/lsqlin_zeros.sce @@ -0,0 +1,32 @@ +// Check for all zeros +C = [0]; +d = [0]; +A = [0]; +b = [0]; +// Output +//Optimal Solution Found. +// lambda = +// +// lower: 0 +// upper: 0 +// eqlin: [0x0 constant] +// ineqlin: 0.999901 +// output = +// +// Iterations: 2 +// exitflag = +// +// 0 +// residual = +// +// 0. +// resnorm = +// +// 0. +// xopt = +// +// 0. + +[xopt,resnorm,residual,exitflag,output,lambda] = lsqlin(C,d,A,b) + + |