From 33bdd144438436b759bc8d0b0beba715f0e39e5d Mon Sep 17 00:00:00 2001 From: Harpreet Date: Thu, 10 Sep 2015 12:37:16 +0530 Subject: output added --- demos/symphony_knapsack.sce | 4 +- demos/symphony_mat_knapsack.sce | 7 ++- etc/Symphony.start~ | 100 --------------------------------- jar/scilab_en_US_help.jar | Bin 165176 -> 165176 bytes macros/symphony.bin | Bin 42700 -> 42972 bytes macros/symphony.sci | 7 ++- macros/symphony_call.bin | Bin 3592 -> 3932 bytes macros/symphony_call.sci | 14 +++-- macros/symphony_mat.bin | Bin 45340 -> 45392 bytes macros/symphony_mat.sci | 4 +- tests/unit_tests/symphony_base.tst | 7 +-- tests/unit_tests/symphony_mat_base.tst | 7 +-- 12 files changed, 24 insertions(+), 126 deletions(-) delete mode 100644 etc/Symphony.start~ diff --git a/demos/symphony_knapsack.sce b/demos/symphony_knapsack.sce index ff4a904..12a6788 100644 --- a/demos/symphony_knapsack.sce +++ b/demos/symphony_knapsack.sce @@ -1,7 +1,5 @@ mode (-1) -clc - // Reference // // This problem is taken from @@ -106,7 +104,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,options) +[x,f,status,output]= symphony(nbVar,nbCon,p,isInt,lb,ub,conMatrix,conLB,conUB,-1,options) //========= E N D === O F === D E M O =========// diff --git a/demos/symphony_mat_knapsack.sce b/demos/symphony_mat_knapsack.sce index 76fefee..8fa57f9 100644 --- a/demos/symphony_mat_knapsack.sce +++ b/demos/symphony_mat_knapsack.sce @@ -1,7 +1,5 @@ mode (-1) -clc - // Reference // // This problem is taken from @@ -78,11 +76,14 @@ intcon = [] for i = 1:nbVar intcon = [intcon i]; end + +options = ["time_limit" "40"]; + // The expected solution : // Output variables 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 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 1 0 0 1 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 0 1 0 0 1 0] // Optimal value fopt = [ 24381 ] // Calling Symphony -[x,f,iter] = symphony_mat(objCoef,intcon,conMatrix,conUB,[],[],lb,ub); +[x,f,iter] = symphony_mat(objCoef,intcon,conMatrix,conUB,[],[],lb,ub,options); diff --git a/etc/Symphony.start~ b/etc/Symphony.start~ deleted file mode 100644 index 45b97e9..0000000 --- a/etc/Symphony.start~ +++ /dev/null @@ -1,100 +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 - -mprintf("Start Symphony\n"); - -if ( isdef("sym_open") ) then - warning("Library is already loaded"); - return; -end - -etc_tlbx = get_absolute_file_path("Symphony.start"); -etc_tlbx = getshortpathname(etc_tlbx); -root_tlbx = strncpy( etc_tlbx, length(etc_tlbx)-length("\etc\") ); - -//Load functions library -// ============================================================================= -mprintf("\tLoad macros\n"); -pathmacros = pathconvert( root_tlbx ) + "macros" + filesep(); -symphony_lib = lib(pathmacros); -clear pathmacros; - -// load gateways -// ============================================================================= - -mprintf("\tLoad gateways\n"); -[a, opt] = getversion(); -Version = opt(2); -ilib_verbose(0); -if getos()=="Windows" then - error(msprintf(gettext("Module is not for Windows."))); -else -// lib_path = root_tlbx + "/thirdparty/linux/lib/" + Version; -// link(lib_path + "/libcoinblas.so.1.4.2"); -// link(lib_path + "/libcoinlapack.so.1.5.2"); -// link(lib_path + "/libCoinUtils.so.3.10.6"); -// link(lib_path + "/libClp.so.1.13.6"); -// link(lib_path + "/libClpSolver.so.1.13.6"); -// link(lib_path + "/libOsi.so.1.12.4"); -// link(lib_path + "/libOsiCommonTests.so.1.12.4"); -// link(lib_path + "/libOsiClp.so.1.13.6"); -// link(lib_path + "/libCgl.so.1.9.4"); -// link(lib_path + "/libSym.so.3.6.10"); -// link(lib_path + "/libOsiSym.so.3.6.10"); - - lib_path = "/home/harpreet/symphony_work/SYMPHONY-5.6.10/build-debug/lib/"; - link(lib_path + "/libCoinUtils.la"); - link(lib_path + "/libClp.la"); - link(lib_path + "/libClpSolver.la"); - link(lib_path + "/libOsi.la"); - link(lib_path + "/libOsiCommonTests.la"); - link(lib_path + "/libOsiClp.la"); - link(lib_path + "/libCgl.la"); - link(lib_path + "/libSym.la"); - link(lib_path + "/libOsiSym.la"); - -end -exec(pathconvert(root_tlbx + filesep() + "sci_gateway" + filesep() + "loader_gateway.sce",%f)); - - - - -// Load and add help chapter -// ============================================================================= -if ( %t ) then -if or(getscilabmode() == ["NW";"STD"]) then - mprintf("\tLoad help\n"); - path_addchapter = pathconvert(root_tlbx+"/jar"); - if ( isdir(path_addchapter) <> [] ) then - add_help_chapter("Symphony", path_addchapter, %F); - clear add_help_chapter; - end - clear path_addchapter; -end -end - -// add demos -// ============================================================================= - -if ( %t ) then -if or(getscilabmode() == ["NW";"STD"]) then - mprintf("\tLoad demos\n"); - pathdemos = pathconvert(root_tlbx+"/demos/sci_symphony.dem.gateway.sce",%f,%t); - add_demo("Symphony",pathdemos); - clear pathdemos ; -end -end - -// ============================================================================= - -clear root_tlbx; -clear etc_tlbx; - diff --git a/jar/scilab_en_US_help.jar b/jar/scilab_en_US_help.jar index 7007aa0..8429d78 100644 Binary files a/jar/scilab_en_US_help.jar and b/jar/scilab_en_US_help.jar differ diff --git a/macros/symphony.bin b/macros/symphony.bin index 3d3d03a..e82e907 100644 Binary files a/macros/symphony.bin and b/macros/symphony.bin differ diff --git a/macros/symphony.sci b/macros/symphony.sci index 01c93e1..18ab5e1 100644 --- a/macros/symphony.sci +++ b/macros/symphony.sci @@ -9,7 +9,7 @@ // are also available at // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt -function [xopt,fopt,iter] = symphony (varargin) +function [xopt,fopt,status,output] = symphony (varargin) // Solves a mixed integer linear programming constrained optimization problem. // // Calling Sequence @@ -32,7 +32,8 @@ function [xopt,fopt,iter] = symphony (varargin) // options : a 1xq marix of string, provided to set the paramters in symphony // 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 + // status : status flag from symphony + // output : The output data structure contains detailed informations about the optimization process. // // Description // Search the minimum or maximum of a constrained mixed integer linear programming optimization problem specified by : @@ -220,7 +221,7 @@ function [xopt,fopt,iter] = symphony (varargin) error(errmsg); end - [xopt,fopt,iter] = symphony_call(nbVar,nbCon,objCoef,isInt,LB,UB,conMatrix,conLB,conUB,objSense,options); + [xopt,fopt,status,output] = 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 index 742ccd5..b95e887 100644 Binary files a/macros/symphony_call.bin and b/macros/symphony_call.bin differ diff --git a/macros/symphony_call.sci b/macros/symphony_call.sci index 843ad6a..ea5f34f 100644 --- a/macros/symphony_call.sci +++ b/macros/symphony_call.sci @@ -9,7 +9,7 @@ // 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) +function [xopt,fopt,status,output] = symphony_call(nbVar,nbCon,objCoef,isInt,LB,UB,conMatrix,conLB,conUB,objSense,options) //Opening Symphony environment sym_open(); @@ -32,17 +32,21 @@ function [xopt,fopt,iter] = symphony_call(nbVar,nbCon,objCoef,isInt,LB,UB,conMat xopt = []; fopt = []; status = []; - iter = []; + output = []; if (~op) then xopt = sym_getVarSoln(); + // Symphony gives a row matrix converting it to column matrix + xopt = xopt'; + fopt = sym_getObjVal(); - iter = sym_getIterCount(); end status = sym_getStatus(); + + output = struct("Iterations" , []); + + output.Iterations = sym_getIterCount(); - //Closing Symphony Environment - sym_close(); endfunction diff --git a/macros/symphony_mat.bin b/macros/symphony_mat.bin index 56e69e8..bcc2d01 100644 Binary files a/macros/symphony_mat.bin and b/macros/symphony_mat.bin differ diff --git a/macros/symphony_mat.sci b/macros/symphony_mat.sci index 747edff..dc11101 100644 --- a/macros/symphony_mat.sci +++ b/macros/symphony_mat.sci @@ -9,7 +9,7 @@ // are also available at // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt -function [xopt,fopt,iter] = symphony_mat (varargin) +function [xopt,fopt,status,iter] = symphony_mat (varargin) // Solves a mixed integer linear programming constrained optimization problem in intlinprog format. // // Calling Sequence @@ -236,6 +236,6 @@ function [xopt,fopt,iter] = symphony_mat (varargin) objSense = 1; - [xopt,fopt,iter] = symphony_call(nbVar,nbCon,objCoef,isInt,lb,ub,conMatrix,conLB,conUB,objSense,options); + [xopt,fopt,status,iter] = symphony_call(nbVar,nbCon,objCoef,isInt,lb,ub,conMatrix,conLB,conUB,objSense,options); endfunction diff --git a/tests/unit_tests/symphony_base.tst b/tests/unit_tests/symphony_base.tst index fd11db0..a1f9e2b 100644 --- a/tests/unit_tests/symphony_base.tst +++ b/tests/unit_tests/symphony_base.tst @@ -76,12 +76,9 @@ conub = [ 25; 1.25; 1.25] isInt = [repmat(%t,1,4) repmat(%f,1,4)]; // Calling Symphony -[x,f,iter] = symphony(8,3,c,isInt,lb,ub,conMatrix,conlb,conub,1); +[x,f,status,output] = symphony(8,3,c,isInt,lb,ub,conMatrix,conlb,conub,1); -//In Symphony Library for optimal solution status = 227 -status = sym_getStatus(); - -assert_close ( x , [1 1 0 1 7.25 0 0.25 3.5] , 1.e-7 ); +assert_close ( x , [1 1 0 1 7.25 0 0.25 3.5]' , 1.e-7 ); assert_close ( f , [ 8495] , 1.e-7 ); assert_checkequal( status , 227 ); diff --git a/tests/unit_tests/symphony_mat_base.tst b/tests/unit_tests/symphony_mat_base.tst index 3bf286d..629039b 100644 --- a/tests/unit_tests/symphony_mat_base.tst +++ b/tests/unit_tests/symphony_mat_base.tst @@ -72,12 +72,9 @@ beq = [ 25, 1.25, 1.25] intcon = [1 2 3 4]; // Calling Symphony -[x,f,iter] = symphony_mat(c,intcon,[],[],Aeq,beq,lb,ub); +[x,f,status,output] = symphony_mat(c,intcon,[],[],Aeq,beq,lb,ub); -//In Symphony Library for optimal solution status = 227 -status = sym_getStatus(); - -assert_close ( x , [1 1 0 1 7.25 0 0.25 3.5] , 1.e-7 ); +assert_close ( x , [1 1 0 1 7.25 0 0.25 3.5]' , 1.e-7 ); assert_close ( f , [ 8495] , 1.e-7 ); assert_checkequal( status , 227 ); -- cgit