diff options
Diffstat (limited to 'tests/general_tests/intfminunc')
20 files changed, 371 insertions, 0 deletions
diff --git a/tests/general_tests/intfminunc/intfminuc_f.sce b/tests/general_tests/intfminunc/intfminuc_f.sce new file mode 100644 index 0000000..472d768 --- /dev/null +++ b/tests/general_tests/intfminunc/intfminuc_f.sce @@ -0,0 +1,15 @@ + +// Check if a user specifies function or not +fun = []; +x0 = [1,1,1,1,1,1]; +intcon=[1,2,3,4,5,6]; + +// --error 10000 +// intfminunc: Expected type ["function"] for input argument fun at input #1, but got "constant" instead. +// at line 56 of function Checktype called by : +// at line 135 of function intfminunc called by : +// [x,fval] =intfminunc(fun ,x0 ,intcon) +// at line 7 of exec file called by : +// exec intfminuc_f.sce + +[x,fval] =intfminunc([] ,x0 ,intcon) diff --git a/tests/general_tests/intfminunc/intfminuc_gradient1.sce b/tests/general_tests/intfminunc/intfminuc_gradient1.sce new file mode 100644 index 0000000..93c3c7d --- /dev/null +++ b/tests/general_tests/intfminunc/intfminuc_gradient1.sce @@ -0,0 +1,19 @@ + +// Check if a user specifies correct format of gradient function or not + +function [y] = f(x) +y = -x(1)^2 - x(2)^2; +endfunction + +x0=[2,1]; +intcon = [1] +options = list("gradobj","Fn"); + +// !--error 999 +// Unknown string passed in gradobj. +// at line 200 of function intfminunc called by : +// [xopt,fopt,exitflag,gradient,hessian]=intfminunc(f,x0,intcon,options) +// at line 8 of exec file called by : +// exec intfminuc_gradient1.sce + +[xopt,fopt,exitflag,gradient,hessian]=intfminunc(f,x0,intcon,options) diff --git a/tests/general_tests/intfminunc/intfminuc_gradient2.sce b/tests/general_tests/intfminunc/intfminuc_gradient2.sce new file mode 100644 index 0000000..612ee66 --- /dev/null +++ b/tests/general_tests/intfminunc/intfminuc_gradient2.sce @@ -0,0 +1,18 @@ +// Check if a user specifies correct format of gradient function or not + +function [y] = f(x) +y = -x(1)^2 - x(2)^2; +endfunction + +x0=[2,1]; +intcon = [1] +options = list("gradobj",""); + +// !--error 999 +// Unknown string passed in gradobj. +// at line 200 of function intfminunc called by : +// [xopt,fopt,exitflag,gradient,hessian]=intfminunc(f,x0,intcon,options) +// at line 8 of exec file called by : +// exec intfminuc_gradient2.sce + +[xopt,fopt,exitflag,gradient,hessian]=intfminunc(f,x0,intcon,options) diff --git a/tests/general_tests/intfminunc/intfminuc_gradient3.sce b/tests/general_tests/intfminunc/intfminuc_gradient3.sce new file mode 100644 index 0000000..2357301 --- /dev/null +++ b/tests/general_tests/intfminunc/intfminuc_gradient3.sce @@ -0,0 +1,20 @@ +// Check if a user specifies correct format of gradient function or not + +function [y] = f(x) +y = -x(1)^2 - x(2)^2; +endfunction + +grad=[]; +x0=[2,1]; +intcon = [1] +options = list("gradobj",grad); + +// !--error 10000 +// intfminbnd_options: Expected type ["string"] for input argument gradobj at input #2, but got "constant" instead. +// at line 56 of function Checktype called by : +// at line 194 of function intfminunc called by : +// [xopt,fopt,exitflag,gradient,hessian]=intfminunc(f,x0,intcon,options) +// at line 8 of exec file called by : +// exec intfminuc_gradient3.sce + +[xopt,fopt,exitflag,gradient,hessian]=intfminunc(f,x0,intcon,options) diff --git a/tests/general_tests/intfminunc/intfminuc_gradient4.sce b/tests/general_tests/intfminunc/intfminuc_gradient4.sce new file mode 100644 index 0000000..0ef48de --- /dev/null +++ b/tests/general_tests/intfminunc/intfminuc_gradient4.sce @@ -0,0 +1,21 @@ +// Check if a user specifies correct format of gradient function or not + +function [y,g] = f(x) +y = -x(1)^2 - x(2)^2; +g = [-2*x(1)]; +endfunction + +x0=[2,1]; +intcon = [1] +options = list("gradobj","ON"); + +// !--error 10000 +// intfminunc_options: Expected 2 entries for input argument dy at input #12, but current dimensions are [1 1] instead. +// at line 54 of function Checkvector called by : +// at line 231 of function intfminunc called by : +// [xopt,fopt,exitflag,gradient,hessian]=intfminunc(f,x0,intcon,options) +// at line 9 of exec file called by : +// exec intfminuc_gradient4.sce + + +[xopt,fopt,exitflag,gradient,hessian]=intfminunc(f,x0,intcon,options) diff --git a/tests/general_tests/intfminunc/intfminuc_hessian1.sce b/tests/general_tests/intfminunc/intfminuc_hessian1.sce new file mode 100644 index 0000000..2a24b4e --- /dev/null +++ b/tests/general_tests/intfminunc/intfminuc_hessian1.sce @@ -0,0 +1,18 @@ +// Check if a user specifies correct format of hessian function or not + +function [y] = f(x) +y = -x(1)^2 - x(2)^2; +endfunction + +x0=[2,1]; +intcon = [1] +options = list("hessian","Fn"); + +// !--error 999 +// Unknown string passed in hessian. +// at line 209 of function intfminunc called by : +// [xopt,fopt,exitflag,gradient,hessian]=intfminunc(f,x0,intcon,options) +// at line 8 of exec file called by : +// exec intfminuc_hessian1.sce + +[xopt,fopt,exitflag,gradient,hessian]=intfminunc(f,x0,intcon,options)
\ No newline at end of file diff --git a/tests/general_tests/intfminunc/intfminuc_hessian2.sce b/tests/general_tests/intfminunc/intfminuc_hessian2.sce new file mode 100644 index 0000000..b14753e --- /dev/null +++ b/tests/general_tests/intfminunc/intfminuc_hessian2.sce @@ -0,0 +1,17 @@ +// Check if a user specifies correct format of hessian function or not +function [y] = f(x) +y = -x(1)^2 - x(2)^2; +endfunction + +x0=[2,1]; +intcon = [1] +options = list("hessian",""); + +// !--error 999 +// Unknown string passed in hessian. +// at line 209 of function intfminunc called by : +// [xopt,fopt,exitflag,gradient,hessian]=intfminunc(f,x0,intcon,options) +// at line 8 of exec file called by : +// exec intfminuc_hessian2.sce + +[xopt,fopt,exitflag,gradient,hessian]=intfminunc(f,x0,intcon,options) diff --git a/tests/general_tests/intfminunc/intfminuc_hessian3.sce b/tests/general_tests/intfminunc/intfminuc_hessian3.sce new file mode 100644 index 0000000..af9e560 --- /dev/null +++ b/tests/general_tests/intfminunc/intfminuc_hessian3.sce @@ -0,0 +1,18 @@ +// Check if a user specifies correct format of hessian function or not +function [y] = f(x) +y = -x(1)^2 - x(2)^2; +endfunction +hessian=[] +x0=[2,1]; +intcon = [1] +options = list("hessian",hessian); + +// !--error 10000 +// intfminbnd_options: Expected type ["string"] for input argument hessian at input #2, but got "constant" instead. +// at line 56 of function Checktype called by : +// at line 203 of function intfminunc called by : +// [xopt,fopt,exitflag,gradient,hessian]=intfminunc(f,x0,intcon,options) +// at line 8 of exec file called by : +// exec intfminuc_hessian3.sce + +[xopt,fopt,exitflag,gradient,hessian]=intfminunc(f,x0,intcon,options) diff --git a/tests/general_tests/intfminunc/intfminuc_hessian4.sce b/tests/general_tests/intfminunc/intfminuc_hessian4.sce new file mode 100644 index 0000000..120366a --- /dev/null +++ b/tests/general_tests/intfminunc/intfminuc_hessian4.sce @@ -0,0 +1,18 @@ +// gradient should be provided when hessian is ON +function [y] = f(x) +y = -x(1)^2 - x(2)^2; +h = [-2,0]; +endfunction + +x0=[2,1]; +intcon = [1] +options = list("hessian","ON"); + +// !--error 10000 +// intfminunc: Gradient of objective function is not provided +// at line 238 of function intfminunc called by : +// [xopt,fopt,exitflag,gradient,hessian]=intfminunc(f,x0,intcon,options) +// at line 9 of exec file called by : +// exec intfminuc_hessian4.sce + +[xopt,fopt,exitflag,gradient,hessian]=intfminunc(f,x0,intcon,options) diff --git a/tests/general_tests/intfminunc/intfminuc_logical1.sce b/tests/general_tests/intfminunc/intfminuc_logical1.sce new file mode 100644 index 0000000..b584bc1 --- /dev/null +++ b/tests/general_tests/intfminunc/intfminuc_logical1.sce @@ -0,0 +1,21 @@ +// An Infeasible Example +function y = fun(x) + y = log(x); +endfunction +x0 = [1]; +intcon = [1]; +options=list("MaxIter", [1500], "CpuTime", [500]); + + +// !--error 999 + +// Ipopt has failed to solve the problem! +// at line 301 of function intfminunc called by : +// [xopt,fopt,exitflag,gradient,hessian] = intfminunc (fun, x0,intcon, options) +// at line 7 of exec file called by : +// exec intfminuc_logical1.sce + + + +[xopt,fopt,exitflag,gradient,hessian] = intfminunc (fun, x0,intcon, options) +
\ No newline at end of file diff --git a/tests/general_tests/intfminunc/intfminuc_logical2.sce b/tests/general_tests/intfminunc/intfminuc_logical2.sce new file mode 100644 index 0000000..095cd49 --- /dev/null +++ b/tests/general_tests/intfminunc/intfminuc_logical2.sce @@ -0,0 +1,26 @@ +// InFeasible Solution +function y = fun(x) + y = (x(1)-x(2))^2 + x(1); +endfunction +x0 = [1,2]; +intcon = [1]; +options=list("MaxIter", [1000], "CpuTime", [500]); + +// InFeasible Solution. +// hessian = + +// [] +// gradient = + +// [] +// exitflag = + +// 1 +// fopt = + +// 0. +// xopt = + +// [] + +[xopt,fopt,exitflag,gradient,hessian] = intfminunc (fun, x0,intcon, options) diff --git a/tests/general_tests/intfminunc/intfminuc_logical3.sce b/tests/general_tests/intfminunc/intfminuc_logical3.sce new file mode 100644 index 0000000..7ec58be --- /dev/null +++ b/tests/general_tests/intfminunc/intfminuc_logical3.sce @@ -0,0 +1,28 @@ +// An Test for infeasible problem +function y = fun(x) + y = (x(1)-x(2))^2 + x(1); +endfunction +x0 = [1,2]; +options=list("maxiter", [1000], "cputime", [1.5]) +intcon = [1] + + +// InFeasible Solution. +// hessian = + +// [] +// gradient = + +// [] +// exitflag = + +// 1 +// fopt = + +// 0. +// xopt = + +// [] + + +[xopt,fopt,exitflag,gradient,hessian] = intfminunc (fun, x0,intcon, options) diff --git a/tests/general_tests/intfminunc/intfminuc_option1.sce b/tests/general_tests/intfminunc/intfminuc_option1.sce new file mode 100644 index 0000000..d61d65e --- /dev/null +++ b/tests/general_tests/intfminunc/intfminuc_option1.sce @@ -0,0 +1,15 @@ +function y = fun(x) + y = x(1)^2 + x(2)^2; +endfunction +x0 = [1,2]; +options=list("MaxIter", "", "CpuTime", [500], "gradobj", "OFF", "Hessian", "OFF"); +intcon = [1] +// !--error 10000 +// intfminbnd_options: Expected type ["constant"] for input argument MaxIter at input #2, but got "string" instead. +// at line 56 of function Checktype called by : +// at line 191 of function intfminunc called by : +// [xopt,fopt,exitflag,output] = intfminunc (fun, x0,intcon, options) +// at line 7 of exec file called by : +// exec intfminuc_option1.sce + +[xopt,fopt,exitflag,output] = intfminunc (fun, x0,intcon, options) diff --git a/tests/general_tests/intfminunc/intfminuc_option2.sce b/tests/general_tests/intfminunc/intfminuc_option2.sce new file mode 100644 index 0000000..3144406 --- /dev/null +++ b/tests/general_tests/intfminunc/intfminuc_option2.sce @@ -0,0 +1,14 @@ +function y = fun(x) + y = x(1)^2 + x(2)^2; +endfunction +x0 = [1,2]; +options=list("maxiter", [1000], "cputime", , "gradobj", "OFF", "hessian", "OFF"); +intcon = [1] +[xopt,fopt,exitflag] = intfminunc (fun, x0,intcon, options) +// !--error 10000 +// intfminunc_options: Expected type ["constant"] for input argument cpuTime at input #4, but got "string" instead. +// at line 56 of function Checktype called by : +// at line 196 of function intfminunc called by : +// [xopt,fopt,exitflag,output,lambda] = intfminunc (fun, intcon, x1, x2, options); +// at line 8 of exec file called by : +// exec intfminunc_options2.sce
\ No newline at end of file diff --git a/tests/general_tests/intfminunc/intfminuc_unbounded.sce b/tests/general_tests/intfminunc/intfminuc_unbounded.sce new file mode 100644 index 0000000..00f65ab --- /dev/null +++ b/tests/general_tests/intfminunc/intfminuc_unbounded.sce @@ -0,0 +1,22 @@ +function y = fun(x) + y = -(x(1)^2 + x(2)^2); +endfunction +x0 = [1,2]; +intcon = [1] +options=list("MaxIter", [1500], "CpuTime", [500]) + +// Objective Function is Continuous Unbounded. +// output = + +// [] +// exitflag = + +// 2 +// fopt = + +// 0. +// xopt = + +// [] + +[xopt,fopt,exitflag,gradient,hessian] = intfminunc (fun, x0,intcon, options) diff --git a/tests/general_tests/intfminunc/intfminuc_x01.sce b/tests/general_tests/intfminunc/intfminuc_x01.sce new file mode 100644 index 0000000..2cc4ec2 --- /dev/null +++ b/tests/general_tests/intfminunc/intfminuc_x01.sce @@ -0,0 +1,18 @@ +function [y,g,h] = f(x) +y = -x(1)^2 - x(2)^2; +g = [-2*x(1),-2*x(2)]; +h = [-2,0;0,-2]; +endfunction + +x0=[]; +intcon = [1] +options = list("gradobj","ON","hessian","on"); +// !--error 10000 +// intfminunc: Expected a vector matrix for input argument x0 at input #2, but got [0 0] instead. +// at line 49 of function Checkvector called by : +// at line 141 of function intfminunc called by : +// [xopt,fopt,exitflag,gradient,hessian]=intfminunc(f,x0,intcon,options) +// at line 10 of exec file called by : +// exec intfminuc_x01.sce + +[xopt,fopt,exitflag]=intfminunc(f,x0,intcon,options) diff --git a/tests/general_tests/intfminunc/intfminuc_x02.sce b/tests/general_tests/intfminunc/intfminuc_x02.sce new file mode 100644 index 0000000..9b6fe7b --- /dev/null +++ b/tests/general_tests/intfminunc/intfminuc_x02.sce @@ -0,0 +1,18 @@ +function [y,g,h] = f(x) +y = -x(1)^2 - x(2)^2; +g = [-2*x(1),-2*x(2)]; +h = [-2,0;0,-2]; +endfunction + +x0=[1]; +intcon = [1] +options = list("gradobj","ON","hessian","ON"); + +// !--error 10000 +// intfminunc: Objective function and x0 did not match +// at line 221 of function intfminunc called by : +// [xopt,fopt,exitflag]=intfminunc(f,x0,intcon,options) +// at line 10 of exec file called by : +// exec intfminuc_x02.sce + +[xopt,fopt,exitflag,gradient,hessian]=intfminunc(f,x0,intcon,options) diff --git a/tests/general_tests/intfminunc/intfminuc_x03.sce b/tests/general_tests/intfminunc/intfminuc_x03.sce new file mode 100644 index 0000000..96c3617 --- /dev/null +++ b/tests/general_tests/intfminunc/intfminuc_x03.sce @@ -0,0 +1,19 @@ +function [y,g,h] = f(x) +y = -x(1)^2 - x(2)^2; +g = [-2*x(1),-2*x(2)]; +h = [-2,0;0,-2]; +endfunction + +x0=[1,1,1]; +intcon = [1] +options = list("gradobj","ON","hessian","on"); + +// !--error 10000 +// intfminunc_options: Expected 3 entries for input argument dy at input #12, but current dimensions are [1 2] instead. +// at line 54 of function Checkvector called by : +// at line 231 of function intfminunc called by : +// [xopt,fopt,exitflag,gradient,hessian]=intfminunc(f,x0,intcon,options) +// at line 10 of exec file called by : +// exec intfminuc_x03.sce + +[xopt,fopt,exitflag,gradient,hessian]=intfminunc(f,x0,intcon,options) diff --git a/tests/general_tests/intfminunc/levi.sce b/tests/general_tests/intfminunc/levi.sce new file mode 100644 index 0000000..7f78674 --- /dev/null +++ b/tests/general_tests/intfminunc/levi.sce @@ -0,0 +1,11 @@ +function z=f(xx) +x=xx(1) +y=xx(2) +z=(sin(3*%pi*x))^2+((x-1)^2)*(1+(sin(3*%pi*y))^2)+((y-1)^2)*(1+(sin(3*%pi*y))^2) +endfunction + + +x0=[10,10]; +intcon=[1,2]; + +[x,fval] =intfminunc(f, x0 ,intcon) diff --git a/tests/general_tests/intfminunc/rosenbrock.sce b/tests/general_tests/intfminunc/rosenbrock.sce new file mode 100644 index 0000000..a2569a7 --- /dev/null +++ b/tests/general_tests/intfminunc/rosenbrock.sce @@ -0,0 +1,15 @@ +function y=rosenbrock(x) +y=0; +sum=0; +for ii = 1:(3-1) + xi = x(ii); + xnext = x(ii+1); + new = 100*(xnext-xi^2)^2 + (xi-1)^2; + sum = sum + new; +end +y = sum; +endfunction +x0=[10,10,10] +intcon=[1,2,3]; + +[x,fval] =intfminunc(rosenbrock ,x0 ,intcon) |