diff options
author | Harpreet | 2015-08-31 18:36:09 +0530 |
---|---|---|
committer | Harpreet | 2015-08-31 18:36:09 +0530 |
commit | b9490a903ae42debe53a96b224d508974c86db6e (patch) | |
tree | c8fe139842f0fe0c8c70fea575de24b966ea1e61 | |
parent | 8b1a4b1ba36dfdf584d9b5a139de4220573a5a1b (diff) | |
download | FOSSEE-Optimization-toolbox-b9490a903ae42debe53a96b224d508974c86db6e.tar.gz FOSSEE-Optimization-toolbox-b9490a903ae42debe53a96b224d508974c86db6e.tar.bz2 FOSSEE-Optimization-toolbox-b9490a903ae42debe53a96b224d508974c86db6e.zip |
Set Options Checked
19 files changed, 164 insertions, 103 deletions
diff --git a/demos/symphony_knapsack.sce b/demos/symphony_knapsack.sce index e28b7b1..854bf06 100644 --- a/demos/symphony_knapsack.sce +++ b/demos/symphony_knapsack.sce @@ -95,6 +95,8 @@ conLB=repmat(0,nbCon,1); // Upper Bound of constraints conUB=[11927 13727 11551 13056 13460 ]'; +options = ["time_limit" "10"] + // The expected solution : // Output variables @@ -104,7 +106,7 @@ xopt = [0 1 1 0 0 1 0 1 0 1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 1 0 1 1 0 1 0 0 0 0 0 fopt = [ 24381 ] // Calling Symphony -[x,f,iter]= symphony(nbVar,nbCon,p,isInt,lb,ub,conMatrix,conLB,conUB,-1) +[x,f,iter]= symphony(nbVar,nbCon,p,isInt,lb,ub,conMatrix,conLB,conUB,-1,options) //========= E N D === O F === D E M O =========// diff --git a/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS b/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS Binary files differindex 06f9d2a..e03ff0a 100644 --- a/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS +++ b/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS diff --git a/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS.TAB b/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS.TAB Binary files differindex 23b22c7..9aad308 100644 --- a/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS.TAB +++ b/help/en_US/scilab_en_US_help/JavaHelpSearch/DOCS.TAB diff --git a/help/en_US/scilab_en_US_help/JavaHelpSearch/OFFSETS b/help/en_US/scilab_en_US_help/JavaHelpSearch/OFFSETS Binary files differindex 656577e..162c59d 100644 --- a/help/en_US/scilab_en_US_help/JavaHelpSearch/OFFSETS +++ b/help/en_US/scilab_en_US_help/JavaHelpSearch/OFFSETS diff --git a/help/en_US/scilab_en_US_help/JavaHelpSearch/POSITIONS b/help/en_US/scilab_en_US_help/JavaHelpSearch/POSITIONS Binary files differindex 148cf77..525881e 100644 --- a/help/en_US/scilab_en_US_help/JavaHelpSearch/POSITIONS +++ b/help/en_US/scilab_en_US_help/JavaHelpSearch/POSITIONS diff --git a/help/en_US/scilab_en_US_help/JavaHelpSearch/SCHEMA b/help/en_US/scilab_en_US_help/JavaHelpSearch/SCHEMA index 096bb41..5f90db9 100644 --- a/help/en_US/scilab_en_US_help/JavaHelpSearch/SCHEMA +++ b/help/en_US/scilab_en_US_help/JavaHelpSearch/SCHEMA @@ -1,2 +1,2 @@ JavaSearch 1.0 -TMAP bs=2048 rt=1 fl=-1 id1=536 id2=1 +TMAP bs=2048 rt=1 fl=-1 id1=769 id2=1 diff --git a/help/en_US/scilab_en_US_help/JavaHelpSearch/TMAP b/help/en_US/scilab_en_US_help/JavaHelpSearch/TMAP Binary files differindex 98648fa..0257c36 100644 --- a/help/en_US/scilab_en_US_help/JavaHelpSearch/TMAP +++ b/help/en_US/scilab_en_US_help/JavaHelpSearch/TMAP diff --git a/help/en_US/scilab_en_US_help/index.html b/help/en_US/scilab_en_US_help/index.html index 1b0fe8c..3aaf941 100644 --- a/help/en_US/scilab_en_US_help/index.html +++ b/help/en_US/scilab_en_US_help/index.html @@ -30,8 +30,8 @@ <br /><br /> <h3 class="book-title">Symphony Toolbox</h3> <ul class="list-part"><a name="symphony_toolbox_manual"></a><div class="info"></div> -<li><a href="symphony.html" class="part">Symphony</a> -<li><a href="section_19f4f1e5726c01d683e8b82be0a7e910.html" class="part">Symphony API Functions</a> + +<li><a href="section_19f4f1e5726c01d683e8b82be0a7e910.html" class="part">Symphony Toolbox</a> <ul class="list-chapter"><li><a href="sym_addConstr.html" class="refentry">sym_addConstr</a> — <span class="refentry-description">Add a new constraint</span></li> diff --git a/jar/scilab_en_US_help.jar b/jar/scilab_en_US_help.jar Binary files differBinary files differindex 0046f71..22e9445 100644 --- a/jar/scilab_en_US_help.jar +++ b/jar/scilab_en_US_help.jar diff --git a/macros/names b/macros/names index 8f806cf..ad89db2 100644 --- a/macros/names +++ b/macros/names @@ -1,3 +1,4 @@ setOptions symphony symphony_call +symphony_mat diff --git a/macros/setOptions.bin b/macros/setOptions.bin Binary files differindex 14d0467..f591286 100644 --- a/macros/setOptions.bin +++ b/macros/setOptions.bin diff --git a/macros/setOptions.sci b/macros/setOptions.sci index 8bf44a0..9d1be61 100644 --- a/macros/setOptions.sci +++ b/macros/setOptions.sci @@ -13,27 +13,27 @@ function setOptions(varagin) options = varagin(1); nbOpt = size(options,2); - //Check the number of options which should be even - if(pmodulo(nbOpt,2)) then - errmsg = msprintf(gettext("%s: Odd number of arguments, the number should be even"), "setOptions"); - error(errmsg) - end + + + + value = strtod(options) + if (nbOpt~=0) then for i = 1:(nbOpt/2) //Setting the parameters //Check if the given parameter is String - if (type(options(2*i))==10) then - sym_setStrParam(options(2*i - 1),options(2*i)); + if (value(2*i) == %nan ) then + sym_setStrParam(options(2*i - 1),value(2*i)); //Check if the given parameter is Double - elseif(type(options(2*i))==1) then - sym_setDblParam(options(2*i - 1),options(2*i)); + elseif(type(value(2*i))==1) then + sym_setDblParam(options(2*i - 1),value(2*i)); //Check if the given parameter is Integer - elseif(type(options(2*i))==8) + elseif(type(value(2*i))==8) sym_setIntParam(options(2*i - 1),options(2*i)); end diff --git a/macros/symphony.bin b/macros/symphony.bin Binary files differindex 08065bf..d096d76 100644 --- a/macros/symphony.bin +++ b/macros/symphony.bin diff --git a/macros/symphony.sci b/macros/symphony.sci index c90dca2..9b74898 100644 --- a/macros/symphony.sci +++ b/macros/symphony.sci @@ -33,7 +33,7 @@ function [xopt,fopt,iter] = symphony (varargin) // conUB = a m x 1 matrix of doubles, where m is number of constraints, contains upper bounds of the constraints // objSense = The sense (maximization/minimization) of the objective. Use 1(sym_minimize ) or -1 (sym_maximize) here - // xopt = a nx1 matrix of doubles, the computed solution of the optimization problem + // xopt = a 1xn matrix of doubles, the computed solution of the optimization problem // fopt = a 1x1 matrix of doubles, the function value at x // iter = a 1x1 matrix of doubles, contains the number od iterations done by symphony // @@ -91,31 +91,31 @@ function [xopt,fopt,iter] = symphony (varargin) //Check the size of constraint which should equal to the number of constraints - if ( size(LB) ~= nbCon) then + if ( size(conMatrix,1) ~= nbCon) then errmsg = msprintf(gettext("%s: The Lower Bound is not equal to the number of variables"), "Symphony"); error(errmsg); end //Check the size of Lower Bound which should equal to the number of variables - if ( size(LB) ~= nbVar) then + if ( size(LB,2) ~= nbVar) then errmsg = msprintf(gettext("%s: The Lower Bound is not equal to the number of variables"), "Symphony"); error(errmsg); end //Check the size of Upper Bound which should equal to the number of variables - if ( size(UB) ~= nbVar) then + if ( size(UB,2) ~= nbVar) then errmsg = msprintf(gettext("%s: The Upper Bound is not equal to the number of variables"), "Symphony"); error(errmsg); end -//Check the size of Lower Bound which should equal to the number of constraints - if ( size(conLB) ~= nbCon) then +//Check the size of constraints of Lower Bound which should equal to the number of constraints + if ( size(conLB,1) ~= nbCon) then errmsg = msprintf(gettext("%s: The Lower Bound of constraints is not equal to the number of constraints"), "Symphony"); error(errmsg); end -//Check the size of Upper Bound which should equal to the number of constraints - if ( size(conUB) ~= nbCon) then +//Check the size of constraints of Upper Bound which should equal to the number of constraints + if ( size(conUB,1) ~= nbCon) then errmsg = msprintf(gettext("%s: The Upper Bound of constraints is not equal to the number of constraints"), "Symphony"); error(errmsg); end diff --git a/macros/symphony.sci~ b/macros/symphony.sci~ deleted file mode 100644 index 32c3e80..0000000 --- a/macros/symphony.sci~ +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (C) 2015 - IIT Bombay - FOSSEE -// -// Author: Harpreet Singh -// Organization: FOSSEE, IIT Bombay -// Email: harpreet.mertia@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 - -function [xopt,fopt,iter] = symphony (varargin) - - // Solves a mixed integer linear programming constrained optimization problem. - // - // Calling Sequence - // x = symphony(nbVar,nbCon,objCoef,isInt,LB,UB,conMatrix,conLB,conUB) - // x = symphony(nbVar,nbCon,objCoef,isInt,LB,UB,conMatrix,conLB,conUB,objSense) - // x = symphony(nbVar,nbCon,objCoef,isInt,LB,UB,conMatrix,conLB,conUB,objSense,options) - // [xopt,fopt,status,iter] = symphony( ... ) - // - -//To check the number of input and output argument - [lhs , rhs] = argn(); - -//To check the number of argument given by user - if ( rhs < 9 | rhs > 11 ) then - errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while should be in the set [9 10 11]"), "Symphony", rhs); - error(errmsg) - end - - nbVar = varargin(1); - nbCon = varargin(2); - objCoef = varargin(3); - isInt = varargin(4); - LB = varargin(5); - UB = varargin(6); - conMatrix = varargin(7); - conLB = varargin(8); - conUB = varargin(9); - - if ( rhs<10 ) then - objSense = 1; - else - objSense = varargin(10); - end - - if (rhs<11) then - options = []; - else - options = varargin(11); - end - - -//Check the size of Lower Bound which should equal to the number of variables - if ( size(LB) ~= nbVar) then - errmsg = msprintf(gettext("%s: The Lower Bound is not equal to the number of variables"), "Symphony"); - error(errmsg); - end - -//Check the size of Upper Bound which should equal to the number of variables - if ( size(UB) ~= nbVar) then - errmsg = msprintf(gettext("%s: The Upper Bound is not equal to the number of variables"), "Symphony"); - error(errmsg); - end - -//Check the size of Lower Bound which should equal to the number of constraints - if ( size(conLB) ~= nbCon) then - errmsg = msprintf(gettext("%s: The Lower Bound of constraints is not equal to the number of constraints"), "Symphony"); - error(errmsg); - end - -//Check the size of Upper Bound which should equal to the number of constraints - if ( size(conUB) ~= nbCon) then - errmsg = msprintf(gettext("%s: The Upper Bound of constraints is not equal to the number of constraints"), "Symphony"); - error(errmsg); - end - - [xopt,fopt,iter] = symphony_call(nbVar,nbCon,objCoef,isInt,LB,UB,conMatrix,conLB,conUB,objSense,options); - -endfunction diff --git a/macros/symphony_call.sci b/macros/symphony_call.sci index e181b96..36abafc 100644 --- a/macros/symphony_call.sci +++ b/macros/symphony_call.sci @@ -40,6 +40,8 @@ function [xopt,fopt,iter] = symphony_call(nbVar,nbCon,objCoef,isInt,LB,UB,conMat iter = sym_getIterCount(); end + status = sym_getStatus(); + // //Closing Symphony Environment // sym_close(); diff --git a/macros/symphony_mat.bin b/macros/symphony_mat.bin Binary files differnew file mode 100644 index 0000000..fdaf7e6 --- /dev/null +++ b/macros/symphony_mat.bin diff --git a/macros/symphony_mat.sci b/macros/symphony_mat.sci new file mode 100644 index 0000000..377fe90 --- /dev/null +++ b/macros/symphony_mat.sci @@ -0,0 +1,137 @@ +// Copyright (C) 2015 - IIT Bombay - FOSSEE +// +// Author: Harpreet Singh +// Organization: FOSSEE, IIT Bombay +// Email: harpreet.mertia@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 + +function [xopt,fopt,iter] = symphony_mat (varargin) + + + // Solves a mixed integer linear programming constrained optimization problem. + // + // Calling Sequence + // xopt = symphony_mat(f,intcon,A,b) + // xopt = symphony_mat(f,intcon,A,b,Aeq,beq) + // xopt = symphony_mat(f,intcon,A,b,Aeq,beq,lb,ub) + // xopt = symphony_mat(f,intcon,A,b,Aeq,beq,lb,ub,options) + // [xopt,fopt,iter] = symphony_mat( ... ) + // + // Parameters + // f = a nx1 matrix of doubles, + // intcon = + // A = + // b = + // Aeq = + // beq = + // lb = + // ub = + // options = + // + // xopt = a 1xn matrix of doubles, the computed solution of the optimization problem + // fopt = a 1x1 matrix of doubles, the function value at x + // iter = a 1x1 matrix of doubles, contains the number od iterations done by symphony + // + // Description + // + // Search the minimum or maximum of a constrained mixed integer linear programming optimization problem specified by : + // find the minimum or maximum of f(x) such that + // + // <latex> + // \begin{eqnarray} + // \mbox{min}_{x} + // & & f(x) \\ + // & \text{subject to} + // & & conLB \geq C(x) \leq conUB \\ + // & & & lb \geq x \leq ub \\ + // \end{eqnarray} + // </latex> + + +//To check the number of input and output argument + [lhs , rhs] = argn(); + +//To check the number of argument given by user + if ( rhs < 4 | rhs = 5 | rhs = 7 | rhs > 9 ) then + errmsg = msprintf(gettext("%s: Unexpected number of input arguments : %d provided while should be in the set [4 6 8 9]"), "Symphony", rhs); + error(errmsg) + end + + + objCoef = varargin(1) + intcon = varargin(2) + A = varargin(3) + b = varargin(4) + + nbVar = size(f,2); + nbCon = size(A,1); + + if ( rhs<4 ) then + Aeq = [] + beq = [] + else + Aeq = varargin(5); + beq = varargin(6); + + //Check the size of equality constraint which should equal to the number of inequality constraints + if ( size(Aeq,2) ~= nbVar) then + errmsg = msprintf(gettext("%s: The size of equality constraint is not equal to the number of variables"), "Symphony"); + error(errmsg); + end + + //Check the size of upper bound of inequality constraint which should equal to the number of constraints + if ( size(beq,2) ~= size(Aeq,1)) then + errmsg = msprintf(gettext("%s: The equality constraint upper bound is not equal to the number of equality constraint"), "Symphony"); + error(errmsg); + end + + end + + if ( rhs<6 ) then + lb = repmat(-%inf,1,nbVar); + ub = repmat(%inf,1,nbVar); + else + lb = varargin(7); + ub = varargin(8); + end + + if (rhs<9) then + options = []; + else + options = varargin(9); + end + + +//Check the size of lower bound of inequality constraint which should equal to the number of constraints + if ( size(b,2) ~= size(A,1)) then + errmsg = msprintf(gettext("%s: The Lower Bound of inequality constraint is not equal to the number of constraint"), "Symphony"); + error(errmsg); + end + +//Check the size of Lower Bound which should equal to the number of variables + if ( size(lb,2) ~= nbVar) then + errmsg = msprintf(gettext("%s: The Lower Bound is not equal to the number of variables"), "Symphony"); + error(errmsg); + end + +//Check the size of Upper Bound which should equal to the number of variables + if ( size(ub,2) ~= nbVar) then + errmsg = msprintf(gettext("%s: The Upper Bound is not equal to the number of variables"), "Symphony"); + error(errmsg); + end + + //Changing the inputs in symphony's format + conMatrix = [A;Aeq] + nbCon = size(conMatrix,1); + conLB = [repmat(-%inf,1,size(A,1)), beq]'; + conUB = [b,beq]' ; + + objSense = 1; + + [xopt,fopt,iter] = symphony_call(nbVar,nbCon,objCoef,isInt,lb,ub,conMatrix,conLB,conUB,objSense,options); + +endfunction |