<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>C++ API frePPLe: lpsolver.h Source File</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> <link href="../styles.css" rel="stylesheet" type="text/css"> </head> <body> <div id="container"> <div id="menubar"> <div id="logo" align="center"> <br/><img src='../frepple.bmp' alt="frepple" /><br/> <a href='http://www.frepple.com/'> <strong>a Free<br/>Production Planning<br/>Library</strong> </a> </div> <div id="menu"> <br/> <h3><a href='../Main/HomePage.html'>Main</a></h3> <h3><a href='../UI/Main.html'>User Manual</a></h3> <h3><a href='../Tutorial/Main.html'>Tutorial</a></h3> <h3><a href='../Frepple/Main.html'>Reference Manual</a></h3> <h3><a href='../Main/FAQ.html'>FAQ</a></h3> <h3><a href='index.html'>C++ API</a></h3> <br/> </div> </div> <div id="content"> <br/> <!-- Generated by Doxygen 1.6.1 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div class="navpath"><a class="el" href="dir_cfc6129efafb4deb1379318d01a4b532.html">modules</a> » <a class="el" href="dir_12a803726e29de82a20f2c57bbc957ca.html">lp_solver</a> </div> </div> <div class="contents"> <h1>lpsolver.h</h1><a href="a00216.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/***************************************************************************</span> <a name="l00002"></a>00002 <span class="comment"> file : $URL: https://frepple.svn.sourceforge.net/svnroot/frepple/trunk/modules/lp_solver/lpsolver.h $</span> <a name="l00003"></a>00003 <span class="comment"> version : $LastChangedRevision: 1108 $ $LastChangedBy: jdetaeye $</span> <a name="l00004"></a>00004 <span class="comment"> date : $LastChangedDate: 2009-12-06 18:54:18 +0100 (Sun, 06 Dec 2009) $</span> <a name="l00005"></a>00005 <span class="comment"> ***************************************************************************/</span> <a name="l00006"></a>00006 <a name="l00007"></a>00007 <span class="comment">/***************************************************************************</span> <a name="l00008"></a>00008 <span class="comment"> * *</span> <a name="l00009"></a>00009 <span class="comment"> * Copyright (C) 2007 by Johan De Taeye *</span> <a name="l00010"></a>00010 <span class="comment"> * *</span> <a name="l00011"></a>00011 <span class="comment"> * This library is free software; you can redistribute it and/or modify it *</span> <a name="l00012"></a>00012 <span class="comment"> * under the terms of the GNU Lesser General Public License as published *</span> <a name="l00013"></a>00013 <span class="comment"> * by the Free Software Foundation; either version 2.1 of the License, or *</span> <a name="l00014"></a>00014 <span class="comment"> * (at your option) any later version. *</span> <a name="l00015"></a>00015 <span class="comment"> * *</span> <a name="l00016"></a>00016 <span class="comment"> * This library is distributed in the hope that it will be useful, *</span> <a name="l00017"></a>00017 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of *</span> <a name="l00018"></a>00018 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *</span> <a name="l00019"></a>00019 <span class="comment"> * General Public License for more details. *</span> <a name="l00020"></a>00020 <span class="comment"> * *</span> <a name="l00021"></a>00021 <span class="comment"> * You should have received a copy of the GNU Lesser General Public *</span> <a name="l00022"></a>00022 <span class="comment"> * License along with this library; if not, write to the Free Software *</span> <a name="l00023"></a>00023 <span class="comment"> * Foundation Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 *</span> <a name="l00024"></a>00024 <span class="comment"> * USA *</span> <a name="l00025"></a>00025 <span class="comment"> * *</span> <a name="l00026"></a>00026 <span class="comment"> ***************************************************************************/</span> <a name="l00027"></a>00027 <span class="comment"></span> <a name="l00028"></a>00028 <span class="comment">/** @file lpsolver.h</span> <a name="l00029"></a>00029 <span class="comment"> * @brief Header file for the module lp_solver.</span> <a name="l00030"></a>00030 <span class="comment"> *</span> <a name="l00031"></a>00031 <span class="comment"> * @namespace module_lp_solver</span> <a name="l00032"></a>00032 <span class="comment"> * @brief A solver module based on a linear programming algorithm.</span> <a name="l00033"></a>00033 <span class="comment"> *</span> <a name="l00034"></a>00034 <span class="comment"> * The solver is intended primarly for prototyping purposes. Cleaner and</span> <a name="l00035"></a>00035 <span class="comment"> * more performant alternatives are recommended for real production use.</span> <a name="l00036"></a>00036 <span class="comment"> *</span> <a name="l00037"></a>00037 <span class="comment"> * The module uses the "Gnu Linear Programming Kit" library (aka GLPK) to</span> <a name="l00038"></a>00038 <span class="comment"> * solve the LP model.<br></span> <a name="l00039"></a>00039 <span class="comment"> * The solver works as follows:</span> <a name="l00040"></a>00040 <span class="comment"> * - The solver expects a <b>model file</b> and a <b>data file</b> as input.<br></span> <a name="l00041"></a>00041 <span class="comment"> * The model file represents the mathematical representation of the</span> <a name="l00042"></a>00042 <span class="comment"> * problem to solve.<br></span> <a name="l00043"></a>00043 <span class="comment"> * The data file holds the data to be loaded into the problem. If no</span> <a name="l00044"></a>00044 <span class="comment"> * data file is specified, the data section in the model file is used</span> <a name="l00045"></a>00045 <span class="comment"> * instead.<br></span> <a name="l00046"></a>00046 <span class="comment"> * The user is responsible for creating these files. See the unit test</span> <a name="l00047"></a>00047 <span class="comment"> * lp_solver1 for an example.</span> <a name="l00048"></a>00048 <span class="comment"> * - The solver solves for a number of objectives in sequence.<br></span> <a name="l00049"></a>00049 <span class="comment"> * After solving an objective's optimal value, the solver freezes the</span> <a name="l00050"></a>00050 <span class="comment"> * value as a constraint and start for the next objective. Subsequent</span> <a name="l00051"></a>00051 <span class="comment"> * objectives can thus never yield a solution that is suboptimal for the</span> <a name="l00052"></a>00052 <span class="comment"> * previous objectives.</span> <a name="l00053"></a>00053 <span class="comment"> * - After solving for all objectives the solution is written to a solution</span> <a name="l00054"></a>00054 <span class="comment"> * file.<br></span> <a name="l00055"></a>00055 <span class="comment"> * The user is responsible for all processing of this solution file.</span> <a name="l00056"></a>00056 <span class="comment"> *</span> <a name="l00057"></a>00057 <span class="comment"> * The XML schema extension enabled by this module is (see mod_lpsolver.xsd):</span> <a name="l00058"></a>00058 <span class="comment"> * <PRE></span> <a name="l00059"></a>00059 <span class="comment"> * <xsd:complexType name="solver_lp"></span> <a name="l00060"></a>00060 <span class="comment"> * <xsd:complexContent></span> <a name="l00061"></a>00061 <span class="comment"> * <xsd:extension base="solver"></span> <a name="l00062"></a>00062 <span class="comment"> * <xsd:choice minOccurs="0" maxOccurs="unbounded"></span> <a name="l00063"></a>00063 <span class="comment"> * <xsd:element name="loglevel" type="loglevel" /></span> <a name="l00064"></a>00064 <span class="comment"> * <xsd:element name="minimum" type="xsd:boolean" /></span> <a name="l00065"></a>00065 <span class="comment"> * <xsd:element name="modelfile" type="xsd:normalizedString" /></span> <a name="l00066"></a>00066 <span class="comment"> * <xsd:element name="datafile" type="xsd:normalizedString" /></span> <a name="l00067"></a>00067 <span class="comment"> * <xsd:element name="solutionfile" type="xsd:normalizedString" /></span> <a name="l00068"></a>00068 <span class="comment"> * <xsd:element name="objective" type="xsd:normalizedString" /></span> <a name="l00069"></a>00069 <span class="comment"> * </xsd:choice></span> <a name="l00070"></a>00070 <span class="comment"> * <xsd:attribute name="loglevel" type="loglevel" /></span> <a name="l00071"></a>00071 <span class="comment"> * <xsd:attribute name="minimum" type="xsd:boolean" /></span> <a name="l00072"></a>00072 <span class="comment"> * <xsd:attribute name="modelfile" type="xsd:normalizedString" /></span> <a name="l00073"></a>00073 <span class="comment"> * <xsd:attribute name="datafile" type="xsd:normalizedString" /></span> <a name="l00074"></a>00074 <span class="comment"> * <xsd:attribute name="solutionfile" type="xsd:normalizedString" /></span> <a name="l00075"></a>00075 <span class="comment"> * <xsd:attribute name="objective" type="xsd:normalizedString" /></span> <a name="l00076"></a>00076 <span class="comment"> * </xsd:extension></span> <a name="l00077"></a>00077 <span class="comment"> * </xsd:complexContent></span> <a name="l00078"></a>00078 <span class="comment"> * </xsd:complexType></span> <a name="l00079"></a>00079 <span class="comment"> * </PRE></span> <a name="l00080"></a>00080 <span class="comment"> */</span> <a name="l00081"></a>00081 <a name="l00082"></a>00082 <span class="preprocessor">#include "<a class="code" href="a00206.html" title="Public header file for C++.">frepple.h</a>"</span> <a name="l00083"></a>00083 <span class="keyword">using namespace </span>frepple; <a name="l00084"></a>00084 <a name="l00085"></a>00085 <span class="keyword">extern</span> <span class="stringliteral">"C"</span> <a name="l00086"></a>00086 { <a name="l00087"></a>00087 <span class="preprocessor">#if defined HAVE_GLPK_H || !defined HAVE_GLPK_GLPK_H</span> <a name="l00088"></a>00088 <span class="preprocessor"></span><span class="preprocessor">#include "glpk.h"</span> <a name="l00089"></a>00089 <span class="preprocessor">#else</span> <a name="l00090"></a>00090 <span class="preprocessor"></span><span class="preprocessor">#ifdef HAVE_GLPK_GLPK_H</span> <a name="l00091"></a>00091 <span class="preprocessor"></span><span class="preprocessor">#include "glpk/glpk.h"</span> <a name="l00092"></a>00092 <span class="preprocessor">#endif</span> <a name="l00093"></a>00093 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00094"></a>00094 <span class="preprocessor"></span>} <a name="l00095"></a>00095 <a name="l00096"></a>00096 <span class="keyword">namespace </span>module_lp_solver <a name="l00097"></a>00097 { <a name="l00098"></a>00098 <span class="comment"></span> <a name="l00099"></a>00099 <span class="comment">/** Initialization routine for the library. */</span> <a name="l00100"></a>00100 <a class="code" href="a00252.html#a49d85811d1043ff1f3d7df4be3d90138">MODULE_EXPORT</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="a00259.html#a23b340fb5d3b4805500e466be4745537">initialize</a>(<span class="keyword">const</span> <a class="code" href="a00030.html#abed9d8d8563f8322df35b7b9723d6f4f">CommandLoadLibrary::ParameterList</a>& z); <a name="l00101"></a>00101 <span class="comment"></span> <a name="l00102"></a>00102 <span class="comment">/** @brief This class is a prototype of an Linear Programming (LP) Solver for</span> <a name="l00103"></a>00103 <span class="comment"> * the planning problem or a subset of it.</span> <a name="l00104"></a>00104 <span class="comment"> *</span> <a name="l00105"></a>00105 <span class="comment"> * The solver is intended primarly for prototyping purposes. Cleaner and</span> <a name="l00106"></a>00106 <span class="comment"> * more performant alternatives are recommended for real production use.</span> <a name="l00107"></a>00107 <span class="comment"> */</span> <a name="l00108"></a><a class="code" href="a00112.html">00108</a> <span class="keyword">class </span><a class="code" href="a00112.html" title="This class is a prototype of an Linear Programming (LP) Solver for the planning problem...">LPSolver</a> : <span class="keyword">public</span> <a class="code" href="a00171.html" title="This class is an implementation of the &quot;visitor&quot; design pattern. It is...">Solver</a> <a name="l00109"></a>00109 { <a name="l00110"></a>00110 <span class="keyword">public</span>:<span class="comment"></span> <a name="l00111"></a>00111 <span class="comment"> /** This method creates a new column in the model for every demand. It's</span> <a name="l00112"></a>00112 <span class="comment"> * value represents the planned quantity of that demand.</span> <a name="l00113"></a>00113 <span class="comment"> * @exception DataException Generated when no calendar has been specified.</span> <a name="l00114"></a>00114 <span class="comment"> */</span> <a name="l00115"></a>00115 <span class="keywordtype">void</span> <a class="code" href="a00112.html#ae17238aac24456062ecf2939201e5b74">solve</a>(<span class="keywordtype">void</span>* = NULL); <a name="l00116"></a>00116 <span class="comment"></span> <a name="l00117"></a>00117 <span class="comment"> /** Return the name of the GNU MathProg model file. */</span> <a name="l00118"></a><a class="code" href="a00112.html#a05fb54b8f285cd3f6843c9febde8864d">00118</a> <span class="keywordtype">string</span> <a class="code" href="a00112.html#a05fb54b8f285cd3f6843c9febde8864d">getModelFile</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> modelfilename;} <a name="l00119"></a>00119 <span class="comment"></span> <a name="l00120"></a>00120 <span class="comment"> /** Update the name of the GNU MathProg model file. */</span> <a name="l00121"></a><a class="code" href="a00112.html#ac225e17c08274edccba96f31b18f22c3">00121</a> <span class="keywordtype">void</span> <a class="code" href="a00112.html#ac225e17c08274edccba96f31b18f22c3">setModelFile</a>(<span class="keyword">const</span> <span class="keywordtype">string</span>& c) {modelfilename = c;} <a name="l00122"></a>00122 <span class="comment"></span> <a name="l00123"></a>00123 <span class="comment"> /** Return the name of the GNU MathProg data file. */</span> <a name="l00124"></a><a class="code" href="a00112.html#aa06224f89b9a520d833f04e329d69b0f">00124</a> <span class="keywordtype">string</span> <a class="code" href="a00112.html#aa06224f89b9a520d833f04e329d69b0f">getDataFile</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> datafilename;} <a name="l00125"></a>00125 <span class="comment"></span> <a name="l00126"></a>00126 <span class="comment"> /** Update the name of the GNU MathProg data file. */</span> <a name="l00127"></a><a class="code" href="a00112.html#af708b6aa075482fc0a15156101cf764a">00127</a> <span class="keywordtype">void</span> <a class="code" href="a00112.html#af708b6aa075482fc0a15156101cf764a">setDataFile</a>(<span class="keyword">const</span> <span class="keywordtype">string</span>& c) {datafilename = c;} <a name="l00128"></a>00128 <span class="comment"></span> <a name="l00129"></a>00129 <span class="comment"> /** Return the name of the solution file. */</span> <a name="l00130"></a><a class="code" href="a00112.html#a8adb53e496e6355e86909fef0df5729b">00130</a> <span class="keywordtype">string</span> <a class="code" href="a00112.html#a8adb53e496e6355e86909fef0df5729b">getSolutionFile</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> solutionfilename;} <a name="l00131"></a>00131 <span class="comment"></span> <a name="l00132"></a>00132 <span class="comment"> /** Update the name of the solution file. <br></span> <a name="l00133"></a>00133 <span class="comment"> * After running the solver the solution is written to this flat file.</span> <a name="l00134"></a>00134 <span class="comment"> */</span> <a name="l00135"></a><a class="code" href="a00112.html#a14bae3e7e9bf5a5dc57e3f7e75bdb868">00135</a> <span class="keywordtype">void</span> <a class="code" href="a00112.html#a14bae3e7e9bf5a5dc57e3f7e75bdb868">setSolutionFile</a>(<span class="keyword">const</span> <span class="keywordtype">string</span>& c) {solutionfilename = c;} <a name="l00136"></a>00136 <span class="comment"></span> <a name="l00137"></a>00137 <span class="comment"> /** Returns true when the solver needs to minimize the objective(s).<br></span> <a name="l00138"></a>00138 <span class="comment"> * Returns false when the solver needs to maximize the objective(s).</span> <a name="l00139"></a>00139 <span class="comment"> */</span> <a name="l00140"></a><a class="code" href="a00112.html#a644e361a095800c4db61a532cfb13ff9">00140</a> <span class="keywordtype">bool</span> <a class="code" href="a00112.html#a644e361a095800c4db61a532cfb13ff9">getMinimum</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> minimum;} <a name="l00141"></a>00141 <span class="comment"></span> <a name="l00142"></a>00142 <span class="comment"> /** Update the solver direction: minimization or maximization. */</span> <a name="l00143"></a><a class="code" href="a00112.html#a6401173b7600ee08b35322dd8078bc53">00143</a> <span class="keywordtype">void</span> <a class="code" href="a00112.html#a6401173b7600ee08b35322dd8078bc53">setMinimum</a>(<span class="keywordtype">bool</span> m) {minimum = m;} <a name="l00144"></a>00144 <span class="comment"></span> <a name="l00145"></a>00145 <span class="comment"> /** Append a new objective to the list. */</span> <a name="l00146"></a><a class="code" href="a00112.html#a48fc88567e5e4ce858dd72ddfb0f9aed">00146</a> <span class="keywordtype">void</span> <a class="code" href="a00112.html#a48fc88567e5e4ce858dd72ddfb0f9aed">addObjective</a>(<span class="keyword">const</span> <span class="keywordtype">string</span>& c) {objectives.push_back(c);} <a name="l00147"></a>00147 <span class="comment"></span> <a name="l00148"></a>00148 <span class="comment"> /** Return a reference to the list of objectives. */</span> <a name="l00149"></a><a class="code" href="a00112.html#ae57e697cc8bcc4dcacfbf2c64e203f5e">00149</a> <span class="keyword">const</span> list<string>& <a class="code" href="a00112.html#ae57e697cc8bcc4dcacfbf2c64e203f5e">getObjectives</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> objectives;} <a name="l00150"></a>00150 <a name="l00151"></a>00151 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="a00112.html#a85c8ba00f73569c997bb002970764aab">writeElement</a>(<a class="code" href="a00189.html" title="Base class for writing XML formatted data to an output stream.">XMLOutput</a>*, <span class="keyword">const</span> <a class="code" href="a00096.html" title="This class defines a keyword for the frePPLe data model.">Keyword</a>&, <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398">mode</a>=<a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a976ad2abb9fd10ca7e48fdff6bef2341">DEFAULT</a>) <span class="keyword">const</span>; <a name="l00152"></a>00152 <span class="keywordtype">void</span> <a class="code" href="a00112.html#a1efedc96cb52751b3b3efca56401fd30">endElement</a>(<a class="code" href="a00186.html" title="This class will read in an XML-file and call the appropriate handler functions of...">XMLInput</a>& pIn, <span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>& pAttr, <span class="keyword">const</span> <a class="code" href="a00047.html" title="This abstract class represents a attribute and value pair for updating objects in...">DataElement</a>& pElement); <a name="l00153"></a>00153 <span class="keyword">virtual</span> PyObject* <a class="code" href="a00112.html#a05c791c87438080ee3dccf793d1d7e51">getattro</a>(<span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>&); <a name="l00154"></a>00154 <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="a00112.html#a4717526cb4db2ca217646e8af799de8b">setattro</a>(<span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>&, <span class="keyword">const</span> <a class="code" href="a00154.html" title="This class handles two-way translation between the data types in C++ and Python.">PythonObject</a>&); <a name="l00155"></a>00155 <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="a00112.html#a5b351b4d36fa31bd2ef24c6691b16e13">initialize</a>(); <a name="l00156"></a>00156 <span class="comment"></span> <a name="l00157"></a>00157 <span class="comment"> /** Constructor. */</span> <a name="l00158"></a><a class="code" href="a00112.html#a7ae2a4192cdcb2a06a1d43ef995269d3">00158</a> <a class="code" href="a00112.html#a7ae2a4192cdcb2a06a1d43ef995269d3">LPSolver</a>(<span class="keyword">const</span> <span class="keywordtype">string</span>& n) : <a class="code" href="a00171.html" title="This class is an implementation of the &quot;visitor&quot; design pattern. It is...">Solver</a>(n), minimum(true) {<a class="code" href="a00151.html#ae5f2cd7cfa5367e07b3de396fe98fbfd">initType</a>(<a class="code" href="a00112.html#a06fe14f0a32d32564b39e14933b8dcc1">metadata</a>);} <a name="l00159"></a>00159 <span class="comment"></span> <a name="l00160"></a>00160 <span class="comment"> /** Destructor. */</span> <a name="l00161"></a><a class="code" href="a00112.html#a5438100a3aa05ad1f4171d466beb6bca">00161</a> <a class="code" href="a00112.html#a5438100a3aa05ad1f4171d466beb6bca">~LPSolver</a>() {}; <a name="l00162"></a>00162 <a name="l00163"></a><a class="code" href="a00112.html#a59e80bd6c085f2b987c9382d7e78354d">00163</a> <span class="keyword">virtual</span> <span class="keyword">const</span> <a class="code" href="a00115.html" title="This class stores metadata about the classes in the library. The stored information...">MetaClass</a>& <a class="code" href="a00112.html#a59e80bd6c085f2b987c9382d7e78354d">getType</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> *<a class="code" href="a00112.html#a06fe14f0a32d32564b39e14933b8dcc1">metadata</a>;} <a name="l00164"></a><a class="code" href="a00112.html#a06fe14f0a32d32564b39e14933b8dcc1">00164</a> <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="a00115.html" title="This class stores metadata about the classes in the library. The stored information...">MetaClass</a> *<a class="code" href="a00112.html#a06fe14f0a32d32564b39e14933b8dcc1">metadata</a>; <a name="l00165"></a><a class="code" href="a00112.html#ab57d0c62de3123a51ac9c147f10a7ad4">00165</a> <span class="keyword">virtual</span> <span class="keywordtype">size_t</span> <a class="code" href="a00112.html#ab57d0c62de3123a51ac9c147f10a7ad4">getSize</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <span class="keyword">sizeof</span>(<a class="code" href="a00112.html" title="This class is a prototype of an Linear Programming (LP) Solver for the planning problem...">LPSolver</a>);} <a name="l00166"></a>00166 <a name="l00167"></a>00167 <span class="keyword">private</span>:<span class="comment"></span> <a name="l00168"></a>00168 <span class="comment"> /** This is an auxilary function. GLPK requires names to contain only</span> <a name="l00169"></a>00169 <span class="comment"> * "graphic" characters. A space isn't one of those. Since our model</span> <a name="l00170"></a>00170 <span class="comment"> * can contain HasHierarchy names with a space, we call this function to</span> <a name="l00171"></a>00171 <span class="comment"> * replace the spaces with underscores.<br></span> <a name="l00172"></a>00172 <span class="comment"> * Note however that we can't garantuee that the updated strings are</span> <a name="l00173"></a>00173 <span class="comment"> * all unique after the replacement!</span> <a name="l00174"></a>00174 <span class="comment"> */</span> <a name="l00175"></a>00175 <span class="keyword">static</span> <span class="keywordtype">string</span> replaceSpaces(<span class="keyword">const</span> <span class="keywordtype">string</span>&); <a name="l00176"></a>00176 <span class="comment"></span> <a name="l00177"></a>00177 <span class="comment"> /** This object is the interface with the GLPK structures. */</span> <a name="l00178"></a>00178 LPX* lp; <a name="l00179"></a>00179 <span class="comment"></span> <a name="l00180"></a>00180 <span class="comment"> /** Storing simplex configuration paramters. */</span> <a name="l00181"></a>00181 glp_smcp parameters; <a name="l00182"></a>00182 <span class="comment"></span> <a name="l00183"></a>00183 <span class="comment"> /** A list of model columns to use as objectives. */</span> <a name="l00184"></a>00184 list<string> objectives; <a name="l00185"></a>00185 <span class="comment"></span> <a name="l00186"></a>00186 <span class="comment"> /** Direction of the solver: minimization or maximization. */</span> <a name="l00187"></a>00187 <span class="keywordtype">bool</span> minimum; <a name="l00188"></a>00188 <span class="comment"></span> <a name="l00189"></a>00189 <span class="comment"> /** Name of the model file.<br></span> <a name="l00190"></a>00190 <span class="comment"> * This field is required.*/</span> <a name="l00191"></a>00191 <span class="keywordtype">string</span> modelfilename; <a name="l00192"></a>00192 <span class="comment"></span> <a name="l00193"></a>00193 <span class="comment"> /** Name of the data file.<br></span> <a name="l00194"></a>00194 <span class="comment"> * If the field is left empty, the data section in the model file is</span> <a name="l00195"></a>00195 <span class="comment"> * used instead.</span> <a name="l00196"></a>00196 <span class="comment"> */</span> <a name="l00197"></a>00197 <span class="keywordtype">string</span> datafilename; <a name="l00198"></a>00198 <span class="comment"></span> <a name="l00199"></a>00199 <span class="comment"> /** Name of the solution file.<br></span> <a name="l00200"></a>00200 <span class="comment"> * If the field is left empty, the solution is not exported.</span> <a name="l00201"></a>00201 <span class="comment"> */</span> <a name="l00202"></a>00202 <span class="keywordtype">string</span> solutionfilename; <a name="l00203"></a>00203 <span class="comment"></span> <a name="l00204"></a>00204 <span class="comment"> /** A hook to intercept the terminal output of the solver library, and</span> <a name="l00205"></a>00205 <span class="comment"> * redirect it into the frePPLe log file.</span> <a name="l00206"></a>00206 <span class="comment"> */</span> <a name="l00207"></a>00207 <span class="keyword">static</span> <span class="keywordtype">int</span> solveroutputredirect(<span class="keywordtype">void</span>* info, <span class="keyword">const</span> <span class="keywordtype">char</span>* msg) <a name="l00208"></a>00208 { <a name="l00209"></a>00209 <a class="code" href="a00257.html#a4af9f241e955122820c5e81ceb33edb5">logger</a> << msg; <a name="l00210"></a>00210 <a class="code" href="a00257.html#a4af9f241e955122820c5e81ceb33edb5">logger</a>.flush(); <a name="l00211"></a>00211 <span class="keywordflow">return</span> 1; <a name="l00212"></a>00212 } <a name="l00213"></a>00213 <span class="comment"></span> <a name="l00214"></a>00214 <span class="comment"> /** Solve for a goal in a hierarchical sequence. */</span> <a name="l00215"></a>00215 <span class="keywordtype">void</span> solveObjective(<span class="keyword">const</span> <span class="keywordtype">string</span>&); <a name="l00216"></a>00216 }; <a name="l00217"></a>00217 <a name="l00218"></a>00218 } <span class="comment">// End namespace</span> </pre></div></div> <hr size="1"/><address style="align: right;"><small>Documentation generated for frePPLe by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"/></a></small></address> </div> </div> </body> </html>