diff options
Diffstat (limited to 'macros')
-rw-r--r-- | macros/Checkdims.bin | bin | 0 -> 8188 bytes | |||
-rw-r--r-- | macros/Checklhs.bin | bin | 0 -> 10312 bytes | |||
-rw-r--r-- | macros/Checkrhs.bin | bin | 0 -> 12852 bytes | |||
-rw-r--r-- | macros/Checktype.bin | bin | 0 -> 9156 bytes | |||
-rw-r--r-- | macros/Checkvector.bin | bin | 0 -> 9696 bytes | |||
-rw-r--r-- | macros/buildmacros.sce | 2 | ||||
-rw-r--r-- | macros/fgoalattain.bin | bin | 0 -> 76912 bytes | |||
-rw-r--r-- | macros/fgoalattain.sci | 139 | ||||
-rw-r--r-- | macros/fminbnd.bin | bin | 53664 -> 54876 bytes | |||
-rw-r--r-- | macros/fminbnd.sci | 8 | ||||
-rw-r--r-- | macros/fmincon.bin | bin | 149444 -> 149512 bytes | |||
-rw-r--r-- | macros/fmincon.sci | 14 | ||||
-rw-r--r-- | macros/fminimax.bin | bin | 0 -> 86512 bytes | |||
-rw-r--r-- | macros/fminimax.sci | 102 | ||||
-rw-r--r-- | macros/fminunc.bin | bin | 60828 -> 60896 bytes | |||
-rw-r--r-- | macros/fminunc.sci | 10 | ||||
-rw-r--r-- | macros/lib | bin | 864 -> 840 bytes | |||
-rw-r--r-- | macros/linprog.bin | bin | 28828 -> 29644 bytes | |||
-rw-r--r-- | macros/linprog.sci | 15 | ||||
-rw-r--r-- | macros/lsqlin.bin | bin | 59776 -> 64528 bytes | |||
-rw-r--r-- | macros/lsqlin.sci | 31 | ||||
-rw-r--r-- | macros/lsqnonneg.bin | bin | 30692 -> 33808 bytes | |||
-rw-r--r-- | macros/lsqnonneg.sci | 20 | ||||
-rw-r--r-- | macros/matrix_linprog.bin | bin | 30556 -> 31128 bytes | |||
-rwxr-xr-x | macros/matrix_linprog.sci | 50 | ||||
-rw-r--r-- | macros/mps_linprog.bin | bin | 9028 -> 10064 bytes | |||
-rw-r--r-- | macros/mps_linprog.sci | 16 | ||||
-rw-r--r-- | macros/names | 11 | ||||
-rw-r--r-- | macros/qpipopt.bin | bin | 58352 -> 63432 bytes | |||
-rw-r--r-- | macros/qpipopt.sci | 44 | ||||
-rw-r--r-- | macros/qpipoptmat.bin | bin | 61536 -> 66084 bytes | |||
-rw-r--r-- | macros/qpipoptmat.sci | 39 | ||||
-rw-r--r-- | macros/symphony.bin | bin | 59692 -> 62044 bytes | |||
-rw-r--r-- | macros/symphony.sci | 11 | ||||
-rw-r--r-- | macros/symphonymat.bin | bin | 63268 -> 65436 bytes | |||
-rw-r--r-- | macros/symphonymat.sci | 10 |
36 files changed, 260 insertions, 262 deletions
diff --git a/macros/Checkdims.bin b/macros/Checkdims.bin Binary files differnew file mode 100644 index 0000000..40e385a --- /dev/null +++ b/macros/Checkdims.bin diff --git a/macros/Checklhs.bin b/macros/Checklhs.bin Binary files differnew file mode 100644 index 0000000..7156107 --- /dev/null +++ b/macros/Checklhs.bin diff --git a/macros/Checkrhs.bin b/macros/Checkrhs.bin Binary files differnew file mode 100644 index 0000000..2c45876 --- /dev/null +++ b/macros/Checkrhs.bin diff --git a/macros/Checktype.bin b/macros/Checktype.bin Binary files differnew file mode 100644 index 0000000..bbe1585 --- /dev/null +++ b/macros/Checktype.bin diff --git a/macros/Checkvector.bin b/macros/Checkvector.bin Binary files differnew file mode 100644 index 0000000..dfe03ab --- /dev/null +++ b/macros/Checkvector.bin diff --git a/macros/buildmacros.sce b/macros/buildmacros.sce index fe6a619..284bc1c 100644 --- a/macros/buildmacros.sce +++ b/macros/buildmacros.sce @@ -9,7 +9,7 @@ // Organization: FOSSEE, IIT Bombay // Email: toolbox@scilab.in -tbx_build_macros("Symphony", get_absolute_file_path("buildmacros.sce")); +tbx_build_macros("FOSSEE_Optimization_Toolbox", get_absolute_file_path("buildmacros.sce")); clear tbx_build_macros; diff --git a/macros/fgoalattain.bin b/macros/fgoalattain.bin Binary files differnew file mode 100644 index 0000000..4889336 --- /dev/null +++ b/macros/fgoalattain.bin diff --git a/macros/fgoalattain.sci b/macros/fgoalattain.sci index d6bec24..41c0fcc 100644 --- a/macros/fgoalattain.sci +++ b/macros/fgoalattain.sci @@ -1,58 +1,47 @@ -// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab // Copyright (C) 2015 - IIT Bombay - FOSSEE // -// Authors: Prajwala TM,Sheetal Shalini -// Organization: FOSSEE, IIT Bombay -// Email: prajwala.tm@gmail.com,sheetalsh456@gmail.com // 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 +// Authors: Prajwala TM,Sheetal Shalini +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in function [x,fval,attainfactor,exitflag,output,lambda] = fgoalattain(varargin) // Solves a multiobjective goal attainment problem // // Calling Sequence - // x = fgoalattain(fun,x0,goal,weight) - // x = fgoalattain(fun,x0,goal,weight,A,b) - // x = fgoalattain(fun,x0,goal,weight,A,b,Aeq,beq) - // x = fgoalattain(fun,x0,goal,weight,A,b,Aeq,beq,lb,ub) - // x = fgoalattain(fun,x0,goal,weight,A,b,Aeq,beq,lb,ub,nonlcon) - // x = fgoalattain(fun,x0,goal,weight,A,b,Aeq,beq,lb,ub,nonlcon,options) - // [x,fval] = fgoalattain(...) - // [x,fval,attainfactor] = fgoalattain(...) - // [x,fval,attainfactor,exitflag] = fgoalattain(...) - // [x,fval,attainfactor,exitflag,output] = fgoalattain(...) - // [x,fval,attainfactor,exitflag,output,lambda] = fgoalattain(...) + // xopt = fgoalattain(fun,x0,goal,weight) + // xopt = fgoalattain(fun,x0,goal,weight,A,b) + // xopt = fgoalattain(fun,x0,goal,weight,A,b,Aeq,beq) + // xopt = fgoalattain(fun,x0,goal,weight,A,b,Aeq,beq,lb,ub) + // xopt = fgoalattain(fun,x0,goal,weight,A,b,Aeq,beq,lb,ub,nonlcon) + // xopt = fgoalattain(fun,x0,goal,weight,A,b,Aeq,beq,lb,ub,nonlcon,options) + // [xopt,fval] = fgoalattain(...) + // [xopt,fval,attainfactor] = fgoalattain(...) + // [xopt,fval,attainfactor,exitflag] = fgoalattain(...) + // [xopt,fval,attainfactor,exitflag,output] = fgoalattain(...) + // [xopt,fval,attainfactor,exitflag,output,lambda] = fgoalattain(...) // // Parameters // fun: a function that accepts a vector x and returns a vector F - // x0: a nx1 or 1xn matrix of double, where n is the number of variables. - // The initial guess for the optimization algorithm - // A: a nil x n matrix of double, where n is the number of variables and - // nil is the number of linear inequalities. - // - // b: a nil x 1 matrix of double, where nil is the number of linear - // inequalities - // Aeq: a nel x n matrix of double, where n is the number of variables - // and nel is the number of linear equalities. - // beq: a nel x 1 matrix of double, where nel is the number of linear - // equalities - // lb: a nx1 or 1xn matrix of double, where n is the number of variables. - // The lower bound for x. If lb==[], then the lower bound is - // automatically set to -inf - // ub: a nx1 or 1xn matrix of double, where n is the number of variables. - // The upper bound for x. If ub==[], then the upper bound is - // automatically set to +inf - // nonlcon: a function, the nonlinear constraints - // options : a list, containing the option for user to specify. See below for details. - // x: a nx1 matrix of double, the computed solution of the optimization problem - // fval: a vector of double, the value of functions at x - // attainfactor: The amount of over- or underachievement of the goals,γ at the solution. - // exitflag: a 1x1 matrix of floating point integers, the exit status - // output: a struct, the details of the optimization process - // lambda: a struct, the Lagrange multipliers at optimum + // x0 : a vector of double, contains initial guess of variables. + // A : a matrix of double, represents the linear coefficients in the inequality constraints A⋅x ≤ b. + // b : a vector of double, represents the linear coefficients in the inequality constraints A⋅x ≤ b. + // Aeq : a matrix of double, represents the linear coefficients in the equality constraints Aeq⋅x = beq. + // beq : a vector of double, represents the linear coefficients in the equality constraints Aeq⋅x = beq. + // lb : a vector of double, contains lower bounds of the variables. + // ub : a vector of double, contains upper bounds of the variables. + // nonlcon: a function, the nonlinear constraints + // options : a list, containing the option for user to specify. See below for details. + // xopt : a vector of double, the computed solution of the optimization problem. + // fopt : a double, the value of the function at x. + // attainfactor: The amount of over- or underachievement of the goals,γ at the solution. + // exitflag : The exit status. See below for details. + // output : The structure consist of statistics about the optimization. See below for details. + // lambda : The structure consist of the Lagrange multipliers at the solution of problem. See below for details. // // Description // fgoalattain solves the goal attainment problem, which is one formulation for minimizing a multiobjective optimization problem. @@ -164,21 +153,12 @@ function [x,fval,attainfactor,exitflag,output,lambda] = fgoalattain(varargin) // f1(5)=x(1)+x(2)-8 // endfunction // x0=[-1,1]; - // // goal=[-5,-3,-2,-1,-4]; // weight=abs(goal) - // gval = - // [- 0.0000011 - // - 63.999998 - // - 2.0000002 - // - 8. - // 3.485D-08] - // z = - // [4. 3.99] - // - // Run fgoalattain - // [x,fval,attainfactor,exitflag,output,lambda]=fgoalattain(gattainObjfun,x0,goal,weight) - // + // //gval =[- 0.0000011 -63.999998 -2.0000002 -8 3.485D-08] + // //z = [4 3.99] + // //Run fgoalattain + // [x,fval,attainfactor,exitflag,output,lambda]=fgoalattain(gattainObjfun,x0,goal,weight) // Authors // Prajwala TM, Sheetal Shalini , 2015 @@ -311,14 +291,14 @@ function [x,fval,attainfactor,exitflag,output,lambda] = fgoalattain(varargin) //To check the User Entry for Options and storing it for i = 1:(size(gattainUserOptions))/2 - select gattainUserOptions(2*i-1) - case "MaxIter" then + select convstr(gattainUserOptions(2*i-1),'l') + case "maxiter" then fgaMaxIter = gattainUserOptions(2*i); //Setting the Maximum Iteration as per user entry - case "CpuTime" then + case "cputime" then fgaCPU = gattainUserOptions(2*i); //Setting the Maximum CPU Time as per user entry - case "GradObj" then + case "gradobj" then if (type(gattainUserOptions(2*i))==10) then if (convstr(gattainUserOptions(2*i))=="off") then flag1 = 0; @@ -331,7 +311,7 @@ function [x,fval,attainfactor,exitflag,output,lambda] = fgoalattain(varargin) gattainFGrad = gattainUserOptions(2*i); end - case "GradCon" then + case "gradcon" then if (type(gattainUserOptions(2*i))==10) then if (convstr(gattainUserOptions(2*i))=="off") then flag2 = 0; @@ -479,49 +459,6 @@ function [x,fval,attainfactor,exitflag,output,lambda] = fgoalattain(varargin) end endfunction - - // disp(gattainStartpoint) - // disp(gattainObjfun(gattainStartpoint)) - // disp(newObjfun(gattainStartpoint)) - // disp(goal) - // disp(weight) - // - // disp(gattainA) - // disp(gattainB) - // disp(gattainAeq) - // disp(gattainBeq) - // disp(gattainLb) - // disp(gattainUb) - // - // [f,g] = gattainNonlinfun(gattainStartpoint) - // disp(f) - // disp(g) - // [f,g] = newNonlinfun(gattainStartpoint) - // disp(f) - // disp(g) - // - // // function foo = CgattainC(z) - // // [foo,tmp1] = newNonlinfun(z) - // // endfunction - // // - // // function foo = CgattainCEQ(z) - // // [tmp1,foo] = newNonlinfun(z) - // // endfunction - // // - // // // function handle defining gattainNonlinfun derivative using numderivative - // // function [dc,dceq] = derrNonlinApp(z) - // // dc = numderivative(CgattainC,z) - // // dceq = numderivative(CgattainCEQ,z) - // // endfunction - // - // // [f,g] = derrNonlinApp(gattainStartpoint) - // // disp(f) - // // disp(g) - // - // [f,g] = newCGrad(gattainStartpoint) - // disp(f) - // disp(g) - //to be passed as options to fmincon if (flag1 == 1 | flag2 == 1) then gattainPassOptions = list("MaxIter", fgaMaxIter, "CpuTime", fgaCPU, "GradCon", newCGrad) diff --git a/macros/fminbnd.bin b/macros/fminbnd.bin Binary files differindex df44ca0..97b00fc 100644 --- a/macros/fminbnd.bin +++ b/macros/fminbnd.bin diff --git a/macros/fminbnd.sci b/macros/fminbnd.sci index c9bf4cc..2c29b03 100644 --- a/macros/fminbnd.sci +++ b/macros/fminbnd.sci @@ -253,12 +253,12 @@ function [xopt,fopt,exitflag,output,lambda] = fminbnd (varargin) //To check the user entry for options and storing it for i = 1:(size(param))/2 - select param(2*i-1) - case "MaxIter" then + select convstr(param(2*i-1),'l') + case "maxiter" then options(2*i) = param(2*i); - case "CpuTime" then + case "cputime" then options(2*i) = param(2*i); - case "TolX" then + case "tolx" then options(2*i) = param(2*i); else errmsg = msprintf(gettext("%s: Unrecognized parameter name %s."), "fminbnd", param(2*i-1)); diff --git a/macros/fmincon.bin b/macros/fmincon.bin Binary files differindex 2e93c02..e1785a4 100644 --- a/macros/fmincon.bin +++ b/macros/fmincon.bin diff --git a/macros/fmincon.sci b/macros/fmincon.sci index 6e2d064..49adec5 100644 --- a/macros/fmincon.sci +++ b/macros/fmincon.sci @@ -673,22 +673,22 @@ function [xopt,fopt,exitflag,output,lambda,gradient,hessian] = fmincon (varargin //To check the user entry for options and storing it for i = 1:(size(param))/2 - select param(2*i-1) - case "MaxIter" then + select convstr(param(2*i-1),'l') + case "maxiter" then options(2*i) = param(2*i); //Setting the maximum number of iterations as per user entry - case "CpuTime" then + case "cputime" then options(2*i) = param(2*i); //Setting the maximum CPU time as per user entry - case "GradObj" then + case "gradobj" then flag1=1; fGrad=param(2*i); - case "Hessian" then + case "hessian" then flag2=1; lHess=param(2*i); - case "GradCon" then + case "gradcon" then flag3=1; cGrad=param(2*i); else - errmsg = msprintf(gettext("%s: Unrecognized parameter name %s."), "fminbnd", param(2*i-1)); + errmsg = msprintf(gettext("%s: Unrecognized parameter name %s."), "fmincon", param(2*i-1)); error(errmsg); end end diff --git a/macros/fminimax.bin b/macros/fminimax.bin Binary files differnew file mode 100644 index 0000000..8a8a8a4 --- /dev/null +++ b/macros/fminimax.bin diff --git a/macros/fminimax.sci b/macros/fminimax.sci index 04d0af6..c775b1b 100644 --- a/macros/fminimax.sci +++ b/macros/fminimax.sci @@ -1,49 +1,47 @@ -// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab // Copyright (C) 2015 - IIT Bombay - FOSSEE // -// Authors: Animesh Baranawal -// Organization: FOSSEE, IIT Bombay -// Email: animeshbaranawal@gmail.com // 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 +// Authors: Animesh Baranawal +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in function [x,fval,maxfval,exitflag,output,lambda] = fminimax(varargin) // Solves minimax constraint problem // // Calling Sequence - // x = fminimax(fun,x0) - // x = fminimax(fun,x0,A,b) - // x = fminimax(fun,x0,A,b,Aeq,beq) - // x = fminimax(fun,x0,A,b,Aeq,beq,lb,ub) - // x = fminimax(fun,x0,A,b,Aeq,beq,lb,ub,nonlinfun) - // x = fminimax(fun,x0,A,b,Aeq,beq,lb,ub,nonlinfun,options) - // [x, fval] = fmincon(.....) - // [x, fval, maxfval]= fmincon(.....) - // [x, fval, maxfval, exitflag]= fmincon(.....) - // [x, fval, maxfval, exitflag, output]= fmincon(.....) - // [x, fval, maxfval, exitflag, output, lambda]= fmincon(.....) + // xopt = fminimax(fun,x0) + // xopt = fminimax(fun,x0,A,b) + // xopt = fminimax(fun,x0,A,b,Aeq,beq) + // xopt = fminimax(fun,x0,A,b,Aeq,beq,lb,ub) + // xopt = fminimax(fun,x0,A,b,Aeq,beq,lb,ub,nonlinfun) + // xopt = fminimax(fun,x0,A,b,Aeq,beq,lb,ub,nonlinfun,options) + // [xopt, fval] = fmincon(.....) + // [xopt, fval, maxfval]= fmincon(.....) + // [xopt, fval, maxfval, exitflag]= fmincon(.....) + // [xopt, fval, maxfval, exitflag, output]= fmincon(.....) + // [xopt, fval, maxfval, exitflag, output, lambda]= fmincon(.....) // // Parameters // fun: The function to be minimized. fun is a function that accepts a vector x and returns a vector F, the objective functions evaluated at x. - // x0: a nx1 or 1xn matrix of doubles, where n is the number of variables, the initial guess for the optimization algorithm - // A: a nil x n matrix of doubles, where n is the number of variables and nil is the number of linear inequalities. If A==[] and b==[], it is assumed that there is no linear inequality constraints. If (A==[] & b<>[]), fminimax generates an error (the same happens if (A<>[] & b==[])) - // b: a nil x 1 matrix of doubles, where nil is the number of linear inequalities - // Aeq: a nel x n matrix of doubles, where n is the number of variables and nel is the number of linear equalities. If Aeq==[] and beq==[], it is assumed that there is no linear equality constraints. If (Aeq==[] & beq<>[]), fminimax generates an error (the same happens if (Aeq<>[] & beq==[])) - // beq: a nel x 1 matrix of doubles, where nel is the number of linear equalities - // lb: a nx1 or 1xn matrix of doubles, where n is the number of variables. The lower bound for x. If lb==[], then the lower bound is automatically set to -inf - // ub: a nx1 or 1xn matrix of doubles, where n is the number of variables. The upper bound for x. If ub==[], then the upper bound is automatically set to +inf - // nonlinfun: function that computes the nonlinear inequality constraints c(x) <= 0 and nonlinear equality constraints ceq(x) = 0. - // x: a nx1 matrix of doubles, the computed solution of the optimization problem - // fval: a vector of doubles, the value of fun at x - // maxfval: a 1x1 matrix of doubles, the maximum value in vector fval - // exitflag: a 1x1 matrix of floating point integers, the exit status - // output: a struct, the details of the optimization process - // lambda: a struct, the Lagrange multipliers at optimum - // options: a list, containing the option for user to specify. See below for details. - // + // x0 : a vector of double, contains initial guess of variables. + // A : a matrix of double, represents the linear coefficients in the inequality constraints A⋅x ≤ b. + // b : a vector of double, represents the linear coefficients in the inequality constraints A⋅x ≤ b. + // Aeq : a matrix of double, represents the linear coefficients in the equality constraints Aeq⋅x = beq. + // beq : a vector of double, represents the linear coefficients in the equality constraints Aeq⋅x = beq. + // lb : a vector of double, contains lower bounds of the variables. + // ub : a vector of double, contains upper bounds of the variables. + // nonlinfun: function that computes the nonlinear inequality constraints c⋅x ≤ 0 and nonlinear equality constraints c⋅x = 0. + // xopt : a vector of double, the computed solution of the optimization problem. + // fopt : a double, the value of the function at x. + // maxfval: a 1x1 matrix of doubles, the maximum value in vector fval + // exitflag : The exit status. See below for details. + // output : The structure consist of statistics about the optimization. See below for details. + // lambda : The structure consist of the Lagrange multipliers at the solution of problem. See below for details. + // // Description // fminimax minimizes the worst-case (largest) value of a set of multivariable functions, starting at an initial estimate. This is generally referred to as the minimax problem. // @@ -160,7 +158,6 @@ function [x,fval,maxfval,exitflag,output,lambda] = fminimax(varargin) // f(4)= -x(1) - x(2); // f(5)= x(1) + x(2) - 8; // endfunction - // // // The initial guess // x0 = [0.1,0.1]; // // The expected solution : only 4 digits are guaranteed @@ -169,6 +166,7 @@ function [x,fval,maxfval,exitflag,output,lambda] = fminimax(varargin) // maxfopt = 0 // // Run fminimax // [x,fval,maxfval,exitflag,output,lambda] = fminimax(myfun, x0) + // // Press ENTER to continue // // Examples // // A case where we provide the gradient of the objective @@ -181,14 +179,11 @@ function [x,fval,maxfval,exitflag,output,lambda] = fminimax(varargin) // 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) @@ -197,8 +192,6 @@ function [x,fval,maxfval,exitflag,output,lambda] = fminimax(varargin) // // No nonlinear equality constraints // ceq=[] // endfunction - // - // // // Defining gradient of confungrad // function [DC,DCeq] = cgrad(x) // // DC(:,i) = gradient of the i-th constraint @@ -212,7 +205,6 @@ function [x,fval,maxfval,exitflag,output,lambda] = fminimax(varargin) // ]' // DCeq = []' // endfunction - // // // Test with both gradient of objective and gradient of constraints // minimaxOptions = list("GradObj",myfungrad,"GradCon",cgrad); // // The initial guess @@ -223,8 +215,6 @@ function [x,fval,maxfval,exitflag,output,lambda] = fminimax(varargin) // maxfopt = 6.73443 // // Run fminimax // [x,fval,maxfval,exitflag,output] = fminimax(myfun,x0,[],[],[],[],[],[], confun, minimaxOptions) - // - // // Authors // Animesh Baranawal // @@ -377,14 +367,14 @@ function [x,fval,maxfval,exitflag,output,lambda] = fminimax(varargin) //To check the User Entry for Options and storing it for i = 1:(size(minmaxUserOptions))/2 - select minmaxUserOptions(2*i-1) - case "MaxIter" then + select convstr(minmaxUserOptions(2*i-1),'l') + case "maxiter" then minmaxIter = minmaxUserOptions(2*i); //Setting the Maximum Iteration as per user entry - case "CpuTime" then + case "cputime" then minmaxCPU = minmaxUserOptions(2*i); //Setting the Maximum CPU Time as per user entry - case "GradObj" then + case "gradobj" then if (type(minmaxUserOptions(2*i))==10) then if (convstr(minmaxUserOptions(2*i))=="off") then flag1 = 0; @@ -397,7 +387,7 @@ function [x,fval,maxfval,exitflag,output,lambda] = fminimax(varargin) minmaxFGrad = minmaxUserOptions(2*i); end - case "GradCon" then + case "gradcon" then if (type(minmaxUserOptions(2*i))==10) then if (convstr(minmaxUserOptions(2*i))=="off") then flag2 = 0; @@ -515,27 +505,6 @@ function [x,fval,maxfval,exitflag,output,lambda] = fminimax(varargin) end endfunction - // disp(minmaxStartpoint) - // a = minmaxObjfun(minmaxStartpoint) - // disp(a) - // disp(newObjfun(minmaxStartpoint)) - // disp(minmaxA) - // disp(minmaxB) - // disp(minmaxAeq) - // disp(minmaxBeq) - // disp(minmaxLb) - // disp(minmaxUb) - // [a,b] = minmaxNonlinfun(minmaxStartpoint) - // disp(a) - // disp(b) - // [a,b] = newNonlinfun(minmaxStartpoint) - // disp(a) - // disp(b) - // [a,b] = newCGrad(minmaxStartpoint) - // disp(a) - // disp(b) - // disp(newFGrad(minmaxStartpoint)) - // to be passed as minimaxOptions to fmincon if(flag1 == 1 | flag2 == 1) then minmaxPassOptions = list("MaxIter", minmaxMaxIter, "CpuTime", minmaxCPU, "GradCon", newCGrad) @@ -555,5 +524,4 @@ function [x,fval,maxfval,exitflag,output,lambda] = fminimax(varargin) maxfval = max(fval) end - endfunction diff --git a/macros/fminunc.bin b/macros/fminunc.bin Binary files differindex 4d67d1b..aa82fc3 100644 --- a/macros/fminunc.bin +++ b/macros/fminunc.bin diff --git a/macros/fminunc.sci b/macros/fminunc.sci index f39c312..a936aa1 100644 --- a/macros/fminunc.sci +++ b/macros/fminunc.sci @@ -264,15 +264,15 @@ function [xopt,fopt,exitflag,output,gradient,hessian] = fminunc (varargin) //To check the user entry for options and store it for i = 1:(size(param))/2 - select param(2*i-1) - case "MaxIter" then + select convstr(param(2*i-1),'l') + case "maxiter" then options(2*i) = param(2*i); //Setting the maximum number of iterations as per user entry - case "CpuTime" then + case "cputime" then options(2*i) = param(2*i); //Setting the maximum CPU time as per user entry - case "Gradient" then + case "gradient" then flag1 = 1; fGrad = param(2*i); - case "Hessian" then + case "hessian" then flag2 = 1; fHess = param(2*i); else Binary files differdiff --git a/macros/linprog.bin b/macros/linprog.bin Binary files differindex 82e3310..12a9f7d 100644 --- a/macros/linprog.bin +++ b/macros/linprog.bin diff --git a/macros/linprog.sci b/macros/linprog.sci index e3e2c71..5b12241 100644 --- a/macros/linprog.sci +++ b/macros/linprog.sci @@ -51,9 +51,18 @@ function [xopt,fopt,exitflag,output,lambda] = linprog (varargin) // & & lb \leq x \leq ub \\ // \end{eqnarray} // </latex> + // // The routine calls Clp for solving the linear programming problem, Clp is a library written in C++. // - // The exitflag allows to know the status of the optimization which is given back by Ipopt. + // The options allows the user to set various parameters of the Optimization problem. + // It should be defined as type "list" and contains the following fields. In the current version it only contains maxiter. + // <itemizedlist> + // <listitem>Syntax : options= list("MaxIter", [---]);</listitem> + // <listitem>MaxIter : a Scalar, containing the Maximum Number of Iteration that the solver should take.</listitem> + // <listitem>Default Values : options = list("MaxIter", [3000]);</listitem> + // </itemizedlist> + // + // The exitflag allows to know the status of the optimization which is given back by CLP. // <itemizedlist> // <listitem>exitflag=0 : Optimal Solution Found </listitem> // <listitem>exitflag=1 : Primal Infeasible </listitem> @@ -64,8 +73,6 @@ function [xopt,fopt,exitflag,output,lambda] = linprog (varargin) // <listitem>exitflag=6 : Dual objective limit reached.</listitem> // </itemizedlist> // - // For more details on exitflag see the ipopt documentation, go to http://www.coin-or.org/Ipopt/documentation/ - // // The output data structure contains detailed informations about the optimization process. // It has type "struct" and contains the following fields. // <itemizedlist> @@ -77,8 +84,6 @@ function [xopt,fopt,exitflag,output,lambda] = linprog (varargin) // of optimization. In the current version the values are returned only when the the solution is optimal. // It has type "struct" and contains the following fields. // <itemizedlist> - // <listitem>lambda.lower: The Lagrange multipliers for the lower bound constraints.</listitem> - // <listitem>lambda.upper: The Lagrange multipliers for the upper bound constraints.</listitem> // <listitem>lambda.eqlin: The Lagrange multipliers for the linear equality constraints.</listitem> // <listitem>lambda.ineqlin: The Lagrange multipliers for the linear inequality constraints.</listitem> // </itemizedlist> diff --git a/macros/lsqlin.bin b/macros/lsqlin.bin Binary files differindex 7018f4a..7baf7be 100644 --- a/macros/lsqlin.bin +++ b/macros/lsqlin.bin diff --git a/macros/lsqlin.sci b/macros/lsqlin.sci index 97aaae6..f236c0d 100644 --- a/macros/lsqlin.sci +++ b/macros/lsqlin.sci @@ -9,7 +9,6 @@ // Organization: FOSSEE, IIT Bombay // Email: toolbox@scilab.in - function [xopt,resnorm,residual,exitflag,output,lambda] = lsqlin (varargin) // Solves a linear quadratic problem. // @@ -54,6 +53,15 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqlin (varargin) // // The routine calls Ipopt for solving the linear least square problem, Ipopt is a library written in C++. // + // The options allows the user to set various parameters of the Optimization problem. + // It should be defined as type "list" and contains the following fields. + // <itemizedlist> + // <listitem>Syntax : options= list("MaxIter", [---], "CpuTime", [---]);</listitem> + // <listitem>MaxIter : a Scalar, containing the Maximum Number of Iteration that the solver should take.</listitem> + // <listitem>CpuTime : a Scalar, containing the Maximum amount of CPU Time that the solver should take.</listitem> + // <listitem>Default Values : options = list("MaxIter", [3000], "CpuTime", [600]);</listitem> + // </itemizedlist> + // // The exitflag allows to know the status of the optimization which is given back by Ipopt. // <itemizedlist> // <listitem>exitflag=0 : Optimal Solution Found </listitem> @@ -198,22 +206,32 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqlin (varargin) error(errmsg); end + //Check type of variables + Checktype("lsqlin", C, "C", 1, "constant") + Checktype("lsqlin", d, "d", 2, "constant") + Checktype("lsqlin", A, "A", 3, "constant") + Checktype("lsqlin", b, "b", 4, "constant") + Checktype("lsqlin", Aeq, "Aeq", 5, "constant") + Checktype("lsqlin", beq, "beq", 6, "constant") + Checktype("lsqlin", lb, "lb", 7, "constant") + Checktype("lsqlin", ub, "ub", 8, "constant") + Checktype("lsqlin", x0, "x0", 9, "constant") if (modulo(size(param),2)) then errmsg = msprintf(gettext("%s: Size of parameters should be even"), "lsqlin"); error(errmsg); end - options = list( "MaxIter" , [3000], ... + options = list( "MaxIter" , [3000], ... "CpuTime" , [600] ... - ); + ); for i = 1:(size(param))/2 - select param(2*i-1) - case "MaxIter" then + select convstr(param(2*i-1),'l') + case "maxiter" then options(2*i) = param(2*i); - case "CpuTime" then + case "cputime" then options(2*i) = param(2*i); else errmsg = msprintf(gettext("%s: Unrecognized parameter name ''%s''."), "lsqlin", param(2*i-1)); @@ -227,7 +245,6 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqlin (varargin) // Check if the user gives row vector // and Changing it to a column matrix - if (size(d,2)== [nbVar]) then d=d'; end diff --git a/macros/lsqnonneg.bin b/macros/lsqnonneg.bin Binary files differindex 39c553b..32620d0 100644 --- a/macros/lsqnonneg.bin +++ b/macros/lsqnonneg.bin diff --git a/macros/lsqnonneg.sci b/macros/lsqnonneg.sci index 3e5ea81..a60d417 100644 --- a/macros/lsqnonneg.sci +++ b/macros/lsqnonneg.sci @@ -41,6 +41,15 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqnonneg (varargin) // // The routine calls Ipopt for solving the nonnegative least-squares curve fitting problems, Ipopt is a library written in C++. // + // The options allows the user to set various parameters of the Optimization problem. + // It should be defined as type "list" and contains the following fields. + // <itemizedlist> + // <listitem>Syntax : options= list("MaxIter", [---], "CpuTime", [---]);</listitem> + // <listitem>MaxIter : a Scalar, containing the Maximum Number of Iteration that the solver should take.</listitem> + // <listitem>CpuTime : a Scalar, containing the Maximum amount of CPU Time that the solver should take.</listitem> + // <listitem>Default Values : options = list("MaxIter", [3000], "CpuTime", [600]);</listitem> + // </itemizedlist> + // // The exitflag allows to know the status of the optimization which is given back by Ipopt. // <itemizedlist> // <listitem>exitflag=0 : Optimal Solution Found </listitem> @@ -114,6 +123,9 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqnonneg (varargin) error(errmsg); end + //Check type of variables + Checktype("lsqnonneg", C, "C", 1, "constant") + Checktype("lsqnonneg", d, "d", 2, "constant") if (modulo(size(param),2)) then errmsg = msprintf(gettext("%s: Size of parameters should be even"), "lsqnonneg"); @@ -126,13 +138,13 @@ function [xopt,resnorm,residual,exitflag,output,lambda] = lsqnonneg (varargin) for i = 1:(size(param))/2 - select param(2*i-1) - case "MaxIter" then + select convstr(param(2*i-1),'l') + case "maxiter" then options(2*i) = param(2*i); - case "CpuTime" then + case "cputime" then options(2*i) = param(2*i); else - errmsg = msprintf(gettext("%s: Unrecognized parameter name ''%s''."), "lsqnonneg", param(2*i-1)); + errmsg = msprintf(gettext("%s: Unrecognized parameter name ''%s''."), "lsqlin", param(2*i-1)); error(errmsg) end end diff --git a/macros/matrix_linprog.bin b/macros/matrix_linprog.bin Binary files differindex 21e525c..ac4d8d9 100644 --- a/macros/matrix_linprog.bin +++ b/macros/matrix_linprog.bin diff --git a/macros/matrix_linprog.sci b/macros/matrix_linprog.sci index 1f6a6bf..c1f53a0 100755 --- a/macros/matrix_linprog.sci +++ b/macros/matrix_linprog.sci @@ -31,16 +31,16 @@ function [xopt,fopt,exitflag,output,lambda] = matrix_linprog (varargin) c = varargin(1); - if (size(c,2)~=1) then - errmsg = msprintf(gettext("%s: Objective Coefficients should be a column matrix"), "linprog"); - error(errmsg); - end - if(size(c,2) == 0) then errmsg = msprintf(gettext("%s: Cannot determine the number of variables because input objective coefficients is empty"), "linprog"); error(errmsg); end + if (size(c,2)~=1) then + errmsg = msprintf(gettext("%s: Objective Coefficients should be a column matrix"), "linprog"); + error(errmsg); + end + nbVar = size(c,1); A = varargin(2); b = varargin(3); @@ -67,25 +67,22 @@ function [xopt,fopt,exitflag,output,lambda] = matrix_linprog (varargin) param =varargin(8); end + //Check type of variables + Checktype("linprog", c, "c", 1, "constant") + Checktype("linprog", A, "A", 2, "constant") + Checktype("linprog", b, "b", 3, "constant") + Checktype("linprog", Aeq, "Aeq", 4, "constant") + Checktype("linprog", beq, "beq", 5, "constant") + Checktype("linprog", lb, "lb", 6, "constant") + Checktype("linprog", ub, "ub", 7, "constant") + nbConInEq = size(A,1); nbConEq = size(Aeq,1); - if (size(lb,2)== [nbVar]) then - lb = lb'; - end - - if (size(ub,2)== [nbVar]) then - ub = ub'; - end - - if (size(b,2)== [nbConInEq]) then - b = b'; - end - - if (size(beq,2)== [nbConEq]) then - beq = beq'; - end - + lb = lb(:); + ub = ub(:) + b = b(:); + beq = beq(:); if (size(lb,2)==0) then lb = repmat(-%inf,nbVar,1); @@ -110,11 +107,11 @@ function [xopt,fopt,exitflag,output,lambda] = matrix_linprog (varargin) for i = 1:(size(param))/2 - select param(2*i-1) - case "MaxIter" then + select convstr(param(2*i-1),'l') + case "maxiter" then options(2*i) = param(2*i); else - errmsg = msprintf(gettext("%s: Unrecognized parameter name ''%s''."), "qpipoptmat", param(2*i-1)); + errmsg = msprintf(gettext("%s: Unrecognized parameter name ''%s''."), "linprog", param(2*i-1)); error(errmsg) end end @@ -155,7 +152,6 @@ function [xopt,fopt,exitflag,output,lambda] = matrix_linprog (varargin) end //Check if the user gives a matrix instead of a vector - if (size(lb,1)~=1)& (size(lb,2)~=1) then errmsg = msprintf(gettext("%s: Lower Bound should be a vector"), "linprog"); error(errmsg); @@ -194,10 +190,6 @@ function [xopt,fopt,exitflag,output,lambda] = matrix_linprog (varargin) end end - lb = lb(:); - ub = ub(:) - b = b(:); - beq = beq(:); nbVar = size(c,1); c = c'; conMatrix = [Aeq;A]; diff --git a/macros/mps_linprog.bin b/macros/mps_linprog.bin Binary files differindex ee7d822..c0d2e3e 100644 --- a/macros/mps_linprog.bin +++ b/macros/mps_linprog.bin diff --git a/macros/mps_linprog.sci b/macros/mps_linprog.sci index 55f3edf..aa61d02 100644 --- a/macros/mps_linprog.sci +++ b/macros/mps_linprog.sci @@ -35,21 +35,27 @@ function [xopt,fopt,exitflag,output,lambda] =mps_linprog(varargin) end if (type(param) ~= 15) then - errmsg = msprintf(gettext("%s: options should be a list "), "mps_linprog"); + errmsg = msprintf(gettext("%s: options should be a list "), "linprog"); error(errmsg); end + //Check type of variables + Checktype("linprog", mpsFile, "mpsFile", 1, "string") + if (modulo(size(param),2)) then - errmsg = msprintf(gettext("%s: Size of parameters should be even"), "mps_linprog"); + errmsg = msprintf(gettext("%s: Size of parameters should be even"), "linprog"); error(errmsg); end options = list("MaxIter" , [3000],); for i = 1:(size(param))/2 - select param(2*i-1) - case "MaxIter" then + select convstr(param(2*i-1),'l') + case "maxiter" then options(2*i) = param(2*i); - end + else + errmsg = msprintf(gettext("%s: Unrecognized parameter name ''%s''."), "linprog", param(2*i-1)); + error(errmsg) + end end //Calling the function by passing the required parameters diff --git a/macros/names b/macros/names index 1055c2a..bff51fe 100644 --- a/macros/names +++ b/macros/names @@ -1,13 +1,12 @@ +Checkdims +Checklhs +Checkrhs +Checktype +Checkvector fgoalattain -fgoalattainFunctions fminbnd fmincon fminimax -fminimaxCheckdims -fminimaxChecklhs -fminimaxCheckrhs -fminimaxChecktype -fminimaxCheckvector fminunc linprog lsqlin diff --git a/macros/qpipopt.bin b/macros/qpipopt.bin Binary files differindex d5e2bd1..e2ba3de 100644 --- a/macros/qpipopt.bin +++ b/macros/qpipopt.bin diff --git a/macros/qpipopt.sci b/macros/qpipopt.sci index 25e7c07..c900f0c 100644 --- a/macros/qpipopt.sci +++ b/macros/qpipopt.sci @@ -51,6 +51,15 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) // // The routine calls Ipopt for solving the quadratic problem, Ipopt is a library written in C++. // + // The options allows the user to set various parameters of the Optimization problem. + // It should be defined as type "list" and contains the following fields. + // <itemizedlist> + // <listitem>Syntax : options= list("MaxIter", [---], "CpuTime", [---]);</listitem> + // <listitem>MaxIter : a Scalar, containing the Maximum Number of Iteration that the solver should take.</listitem> + // <listitem>CpuTime : a Scalar, containing the Maximum amount of CPU Time that the solver should take.</listitem> + // <listitem>Default Values : options = list("MaxIter", [3000], "CpuTime", [600]);</listitem> + // </itemizedlist> + // // The exitflag allows to know the status of the optimization which is given back by Ipopt. // <itemizedlist> // <listitem>exitflag=0 : Optimal Solution Found </listitem> @@ -187,23 +196,36 @@ function [xopt,fopt,exitflag,output,lambda] = qpipopt (varargin) error(errmsg); end + //Check type of variables + Checktype("qpipopt", nbVar, "nbVar", 1, "constant") + Checktype("qpipopt", nbCon, "nbCon", 2, "constant") + Checktype("qpipopt", H, "H", 3, "constant") + Checktype("qpipopt", f, "f", 4, "constant") + Checktype("qpipopt", lb, "lb", 5, "constant") + Checktype("qpipopt", ub, "lb", 6, "constant") + Checktype("qpipopt", A, "A", 7, "constant") + Checktype("qpipopt", conLB, "conlb", 8, "constant") + Checktype("qpipopt", conUB, "conub", 9, "constant") + Checktype("qpipopt", x0, "x0", 10, "constant") + options = list(.. "MaxIter" , [3000], ... "CpuTime" , [600] ... ); - for i = 1:(size(param))/2 - select param(2*i-1) - case "MaxIter" then - options(2*i) = param(2*i); - case "CpuTime" then - options(2*i) = param(2*i); - else - errmsg = msprintf(gettext("%s: Unrecognized parameter name ''%s''."), "qpipopt", param(2*i-1)); - error(errmsg) - end - end + for i = 1:(size(param))/2 + + select convstr(param(2*i-1),'l') + case "maxiter" then + options(2*i) = param(2*i); + case "cputime" then + options(2*i) = param(2*i); + else + errmsg = msprintf(gettext("%s: Unrecognized parameter name ''%s''."), "lsqlin", param(2*i-1)); + error(errmsg) + end + end // Check if the user gives row vector // and Changing it to a column matrix diff --git a/macros/qpipoptmat.bin b/macros/qpipoptmat.bin Binary files differindex 58424ec..057fa29 100644 --- a/macros/qpipoptmat.bin +++ b/macros/qpipoptmat.bin diff --git a/macros/qpipoptmat.sci b/macros/qpipoptmat.sci index ca32f8e..e64a83a 100644 --- a/macros/qpipoptmat.sci +++ b/macros/qpipoptmat.sci @@ -35,7 +35,6 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) // param : a list containing the parameters to be set. // xopt : a vector of double, the computed solution of the optimization problem. // fopt : a double, the value of the function at x. - // residual : a vector of double, solution residuals returned as the vector d-C*x. // exitflag : The exit status. See below for details. // output : The structure consist of statistics about the optimization. See below for details. // lambda : The structure consist of the Lagrange multipliers at the solution of problem. See below for details. @@ -55,6 +54,15 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) // // The routine calls Ipopt for solving the quadratic problem, Ipopt is a library written in C++. // + // The options allows the user to set various parameters of the Optimization problem. + // It should be defined as type "list" and contains the following fields. + // <itemizedlist> + // <listitem>Syntax : options= list("MaxIter", [---], "CpuTime", [---]);</listitem> + // <listitem>MaxIter : a Scalar, containing the Maximum Number of Iteration that the solver should take.</listitem> + // <listitem>CpuTime : a Scalar, containing the Maximum amount of CPU Time that the solver should take.</listitem> + // <listitem>Default Values : options = list("MaxIter", [3000], "CpuTime", [600]);</listitem> + // </itemizedlist> + // // The exitflag allows to know the status of the optimization which is given back by Ipopt. // <itemizedlist> // <listitem>exitflag=0 : Optimal Solution Found </listitem> @@ -208,21 +216,32 @@ function [xopt,fopt,exitflag,output,lambda] = qpipoptmat (varargin) error(errmsg); end + //Check type of variables + Checktype("qpipoptmat", H, "H", 1, "constant") + Checktype("qpipoptmat", f, "f", 2, "constant") + Checktype("qpipoptmat", A, "A", 3, "constant") + Checktype("qpipoptmat", b, "b", 4, "constant") + Checktype("qpipoptmat", Aeq, "Aeq", 5, "constant") + Checktype("qpipoptmat", beq, "beq", 6, "constant") + Checktype("qpipoptmat", lb, "lb", 7, "constant") + Checktype("qpipoptmat", ub, "ub", 8, "constant") + Checktype("qpipoptmat", x0, "x0", 9, "constant") + options = list(.. "MaxIter" , [3000], ... "CpuTime" , [600] ... ); for i = 1:(size(param))/2 - - select param(2*i-1) - case "MaxIter" then - options(2*i) = param(2*i); - case "CpuTime" then - options(2*i) = param(2*i); - else - errmsg = msprintf(gettext("%s: Unrecognized parameter name ''%s''."), "qpipoptmat", param(2*i-1)); - error(errmsg) + + select convstr(param(2*i-1),'l') + case "maxiter" then + options(2*i) = param(2*i); + case "cputime" then + options(2*i) = param(2*i); + else + errmsg = msprintf(gettext("%s: Unrecognized parameter name ''%s''."), "lsqlin", param(2*i-1)); + error(errmsg) end end diff --git a/macros/symphony.bin b/macros/symphony.bin Binary files differindex b98094e..2c3a43a 100644 --- a/macros/symphony.bin +++ b/macros/symphony.bin diff --git a/macros/symphony.sci b/macros/symphony.sci index 81b24fb..111f84c 100644 --- a/macros/symphony.sci +++ b/macros/symphony.sci @@ -219,6 +219,17 @@ function [xopt,fopt,status,output] = symphony (varargin) options = varargin(11); end + //Check type of variables + Checktype("symphony", nbVar, "nbVar", 1, "constant") + Checktype("symphony", nbCon, "nbCon", 2, "constant") + Checktype("symphony", c, "c", 3, "constant") + Checktype("symphony", isInt, "isInt", 4, "boolean") + Checktype("symphony", lb, "lb", 5, "constant") + Checktype("symphony", ub, "lb", 6, "constant") + Checktype("symphony", A, "A", 7, "constant") + Checktype("symphony", conLB, "conlb", 8, "constant") + Checktype("symphony", conUB, "conub", 9, "constant") + // Check if the user gives empty matrix if (size(lb,2)==0) then lb = repmat(-%inf,nbVar,1); diff --git a/macros/symphonymat.bin b/macros/symphonymat.bin Binary files differindex a5e68ab..7dffa2f 100644 --- a/macros/symphonymat.bin +++ b/macros/symphonymat.bin diff --git a/macros/symphonymat.sci b/macros/symphonymat.sci index 3848850..2016f00 100644 --- a/macros/symphonymat.sci +++ b/macros/symphonymat.sci @@ -227,6 +227,16 @@ function [xopt,fopt,status,iter] = symphonymat (varargin) options = varargin(9); end + //Check type of variables + Checktype("symphonymat", c, "c", 1, "constant") + Checktype("symphonymat", intcon, "intcon", 2, "constant") + Checktype("symphonymat", A, "A", 3, "constant") + Checktype("symphonymat", b, "b", 4, "constant") + Checktype("symphonymat", Aeq, "Aeq", 5, "constant") + Checktype("symphonymat", beq, "beq", 6, "constant") + Checktype("symphonymat", lb, "lb", 7, "constant") + Checktype("symphonymat", ub, "ub", 8, "constant") + // Check if the user gives empty matrix if (size(lb,2)==0) then lb = repmat(-%inf,nbVar,1); |