summaryrefslogtreecommitdiff
path: root/macros
diff options
context:
space:
mode:
authorHarpreet2015-08-27 02:32:30 +0530
committerHarpreet2015-08-27 02:32:30 +0530
commitf9afc284ce324fa3c13606ad90895beec507c249 (patch)
treea1680fec3342c4eb00b73cd056ff9fad519c5877 /macros
downloadFOSSEE-Optimization-toolbox-f9afc284ce324fa3c13606ad90895beec507c249.tar.gz
FOSSEE-Optimization-toolbox-f9afc284ce324fa3c13606ad90895beec507c249.tar.bz2
FOSSEE-Optimization-toolbox-f9afc284ce324fa3c13606ad90895beec507c249.zip
Master File
Diffstat (limited to 'macros')
-rw-r--r--macros/buildmacros.sce15
-rw-r--r--macros/libbin0 -> 408 bytes
-rw-r--r--macros/names3
-rw-r--r--macros/setOptions.binbin0 -> 3988 bytes
-rw-r--r--macros/setOptions.sci45
-rw-r--r--macros/symphony.binbin0 -> 9840 bytes
-rw-r--r--macros/symphony.sci80
-rw-r--r--macros/symphony_call.binbin0 -> 3488 bytes
-rw-r--r--macros/symphony_call.sci46
9 files changed, 189 insertions, 0 deletions
diff --git a/macros/buildmacros.sce b/macros/buildmacros.sce
new file mode 100644
index 0000000..656ff4a
--- /dev/null
+++ b/macros/buildmacros.sce
@@ -0,0 +1,15 @@
+// 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
+
+tbx_build_macros("Symphony", get_absolute_file_path("buildmacros.sce"));
+
+clear tbx_build_macros;
+
diff --git a/macros/lib b/macros/lib
new file mode 100644
index 0000000..70449c8
--- /dev/null
+++ b/macros/lib
Binary files differ
diff --git a/macros/names b/macros/names
new file mode 100644
index 0000000..8f806cf
--- /dev/null
+++ b/macros/names
@@ -0,0 +1,3 @@
+setOptions
+symphony
+symphony_call
diff --git a/macros/setOptions.bin b/macros/setOptions.bin
new file mode 100644
index 0000000..14d0467
--- /dev/null
+++ b/macros/setOptions.bin
Binary files differ
diff --git a/macros/setOptions.sci b/macros/setOptions.sci
new file mode 100644
index 0000000..8bf44a0
--- /dev/null
+++ b/macros/setOptions.sci
@@ -0,0 +1,45 @@
+// 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 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
+
+ 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));
+
+ //Check if the given parameter is Double
+ elseif(type(options(2*i))==1) then
+ sym_setDblParam(options(2*i - 1),options(2*i));
+
+ //Check if the given parameter is Integer
+ elseif(type(options(2*i))==8)
+ sym_setIntParam(options(2*i - 1),options(2*i));
+ end
+
+ end
+ end
+
+
+endfunction
+
diff --git a/macros/symphony.bin b/macros/symphony.bin
new file mode 100644
index 0000000..08065bf
--- /dev/null
+++ b/macros/symphony.bin
Binary files differ
diff --git a/macros/symphony.sci b/macros/symphony.sci
new file mode 100644
index 0000000..f0a0618
--- /dev/null
+++ b/macros/symphony.sci
@@ -0,0 +1,80 @@
+// 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 linearily 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.bin b/macros/symphony_call.bin
new file mode 100644
index 0000000..27d7f4a
--- /dev/null
+++ b/macros/symphony_call.bin
Binary files differ
diff --git a/macros/symphony_call.sci b/macros/symphony_call.sci
new file mode 100644
index 0000000..e181b96
--- /dev/null
+++ b/macros/symphony_call.sci
@@ -0,0 +1,46 @@
+// 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_call(nbVar,nbCon,objCoef,isInt,LB,UB,conMatrix,conLB,conUB,objSense,options)
+
+ //Opening Symphony environment
+ sym_open();
+
+ //Choosing to launch basic or advanced version
+ if(~issparse(conMatrix)) then
+ sym_loadProblemBasic(nbVar,nbCon,LB,UB,objCoef,isInt,objSense,conMatrix,conLB,conUB);
+ else
+ // Changing to Constraint Matrix into sparse matrix
+ conMatrix_advanced=sparse(conMatrix);
+ sym_loadProblem(nbVar,nbCon,LB,UB,objCoef,isInt,objSense,conMatrix_advanced,conLB,conUB);
+ end
+
+
+ //Setting Options for the Symphpony
+ setOptions(options);
+
+ op = sym_solve();
+
+ xopt = [];
+ fopt = [];
+ status = [];
+ iter = [];
+
+ if (~op) then
+ xopt = sym_getVarSoln();
+ fopt = sym_getObjVal();
+ iter = sym_getIterCount();
+ end
+
+// //Closing Symphony Environment
+// sym_close();
+
+endfunction