<!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: solverprocure.cpp 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_88117dff2735251a69c8eb9084477714.html">src</a> » <a class="el" href="dir_f53ab566a495928d11ba5681eabceaaf.html">solver</a> </div> </div> <div class="contents"> <h1>solverprocure.cpp</h1><a href="a00246.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/src/solver/solverprocure.cpp $</span> <a name="l00003"></a>00003 <span class="comment"> version : $LastChangedRevision: 1315 $ $LastChangedBy: jdetaeye $</span> <a name="l00004"></a>00004 <span class="comment"> date : $LastChangedDate: 2010-07-17 18:08:53 +0200 (Sat, 17 Jul 2010) $</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-2010 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 <a name="l00028"></a><a class="code" href="a00246.html#a342983a479ae7a921be5face83fdb029">00028</a> <span class="preprocessor">#define FREPPLE_CORE</span> <a name="l00029"></a>00029 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="a00239.html">frepple/solver.h</a>"</span> <a name="l00030"></a>00030 <a name="l00031"></a>00031 <span class="keyword">namespace </span>frepple <a name="l00032"></a>00032 { <a name="l00033"></a>00033 <a name="l00034"></a>00034 <a name="l00035"></a><a class="code" href="a00256.html#a6a424b0200f647afe098772dfb8df980">00035</a> <span class="keywordtype">double</span> <a class="code" href="a00256.html#a6a424b0200f647afe098772dfb8df980">suggestQuantity</a>(<span class="keyword">const</span> <a class="code" href="a00012.html" title="This class models a buffer that is replenish by an external supplier using a reorder-point...">BufferProcure</a>* b, <span class="keywordtype">double</span> f) <a name="l00036"></a>00036 { <a name="l00037"></a>00037 <span class="comment">// Standard answer</span> <a name="l00038"></a>00038 <span class="keywordtype">double</span> order_qty = f; <a name="l00039"></a>00039 <a name="l00040"></a>00040 <span class="comment">// Round to a multiple</span> <a name="l00041"></a>00041 <span class="keywordflow">if</span> (b-><a class="code" href="a00012.html#a118957464c24c66af57cbbae5f7097c6">getSizeMultiple</a>()>0.0) <a name="l00042"></a>00042 { <a name="l00043"></a>00043 <span class="keywordtype">int</span> mult = <span class="keyword">static_cast<</span><span class="keywordtype">int</span><span class="keyword">></span>(order_qty / b-><a class="code" href="a00012.html#a118957464c24c66af57cbbae5f7097c6">getSizeMultiple</a>() + 0.99999999); <a name="l00044"></a>00044 order_qty = mult * b-><a class="code" href="a00012.html#a118957464c24c66af57cbbae5f7097c6">getSizeMultiple</a>(); <a name="l00045"></a>00045 } <a name="l00046"></a>00046 <a name="l00047"></a>00047 <span class="comment">// Respect minimum size</span> <a name="l00048"></a>00048 <span class="keywordflow">if</span> (order_qty < b->getSizeMinimum()) <a name="l00049"></a>00049 { <a name="l00050"></a>00050 order_qty = b-><a class="code" href="a00012.html#a273d7f036ed4fd6b2197c07e71356ece">getSizeMinimum</a>(); <a name="l00051"></a>00051 <span class="comment">// round up to multiple</span> <a name="l00052"></a>00052 <span class="keywordflow">if</span> (b-><a class="code" href="a00012.html#a118957464c24c66af57cbbae5f7097c6">getSizeMultiple</a>()>0.0) <a name="l00053"></a>00053 { <a name="l00054"></a>00054 <span class="keywordtype">int</span> mult = <span class="keyword">static_cast<</span><span class="keywordtype">int</span><span class="keyword">></span>(order_qty / b-><a class="code" href="a00012.html#a118957464c24c66af57cbbae5f7097c6">getSizeMultiple</a>() + 0.99999999); <a name="l00055"></a>00055 order_qty = mult * b-><a class="code" href="a00012.html#a118957464c24c66af57cbbae5f7097c6">getSizeMultiple</a>(); <a name="l00056"></a>00056 } <a name="l00057"></a>00057 <span class="comment">// if now bigger than max -> infeasible</span> <a name="l00058"></a>00058 <span class="keywordflow">if</span> (order_qty > b-><a class="code" href="a00012.html#a7a9884c8c6faa099cbeac64a0e04b1eb">getSizeMaximum</a>()) <a name="l00059"></a>00059 <span class="keywordflow">throw</span> <a class="code" href="a00048.html" title="An exception of this type is thrown when data errors are found.">DataException</a>(<span class="stringliteral">"Inconsistent procurement parameters on buffer '"</span> <a name="l00060"></a>00060 + b-><a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() + <span class="stringliteral">"'"</span>); <a name="l00061"></a>00061 } <a name="l00062"></a>00062 <a name="l00063"></a>00063 <span class="comment">// Respect maximum size</span> <a name="l00064"></a>00064 <span class="keywordflow">if</span> (order_qty > b-><a class="code" href="a00012.html#a7a9884c8c6faa099cbeac64a0e04b1eb">getSizeMaximum</a>()) <a name="l00065"></a>00065 { <a name="l00066"></a>00066 order_qty = b-><a class="code" href="a00012.html#a7a9884c8c6faa099cbeac64a0e04b1eb">getSizeMaximum</a>(); <a name="l00067"></a>00067 <span class="comment">// round down</span> <a name="l00068"></a>00068 <span class="keywordflow">if</span> (b-><a class="code" href="a00012.html#a118957464c24c66af57cbbae5f7097c6">getSizeMultiple</a>()>0.0) <a name="l00069"></a>00069 { <a name="l00070"></a>00070 <span class="keywordtype">int</span> mult = <span class="keyword">static_cast<</span><span class="keywordtype">int</span><span class="keyword">></span>(order_qty / b-><a class="code" href="a00012.html#a118957464c24c66af57cbbae5f7097c6">getSizeMultiple</a>()); <a name="l00071"></a>00071 order_qty = mult * b-><a class="code" href="a00012.html#a118957464c24c66af57cbbae5f7097c6">getSizeMultiple</a>(); <a name="l00072"></a>00072 } <a name="l00073"></a>00073 <span class="comment">// if now smaller than min -> infeasible</span> <a name="l00074"></a>00074 <span class="keywordflow">if</span> (order_qty < b->getSizeMinimum()) <a name="l00075"></a>00075 <span class="keywordflow">throw</span> <a class="code" href="a00048.html" title="An exception of this type is thrown when data errors are found.">DataException</a>(<span class="stringliteral">"Inconsistent procurement parameters on buffer '"</span> <a name="l00076"></a>00076 + b-><a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() + <span class="stringliteral">"'"</span>); <a name="l00077"></a>00077 } <a name="l00078"></a>00078 <a name="l00079"></a>00079 <span class="comment">// Reply</span> <a name="l00080"></a>00080 <span class="keywordflow">return</span> order_qty; <a name="l00081"></a>00081 } <a name="l00082"></a>00082 <a name="l00083"></a>00083 <a name="l00084"></a><a class="code" href="a00173.html#a54b16830f089156c69c901bb44aaf488">00084</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00173.html#aed1d08dd6ece530ed9229d463e31cca3">SolverMRP::solve</a>(<span class="keyword">const</span> <a class="code" href="a00012.html" title="This class models a buffer that is replenish by an external supplier using a reorder-point...">BufferProcure</a>* b, <span class="keywordtype">void</span>* v) <a name="l00085"></a>00085 { <a name="l00086"></a>00086 <a class="code" href="a00174.html" title="This class is a helper class of the SolverMRP class.">SolverMRPdata</a>* data = <span class="keyword">static_cast<</span><a class="code" href="a00174.html" title="This class is a helper class of the SolverMRP class.">SolverMRPdata</a>*<span class="keyword">></span>(v); <a name="l00087"></a>00087 <a name="l00088"></a>00088 <span class="comment">// Call the user exit</span> <a name="l00089"></a>00089 <span class="keywordflow">if</span> (userexit_buffer) userexit_buffer.<a class="code" href="a00152.html#a7f199c39019f133986783dfc6017b640">call</a>(b, <a class="code" href="a00154.html" title="This class handles two-way translation between the data types in C++ and Python.">PythonObject</a>(data->constrainedPlanning)); <a name="l00090"></a>00090 <a name="l00091"></a>00091 <span class="comment">// Message</span> <a name="l00092"></a>00092 <span class="keywordflow">if</span> (data-><a class="code" href="a00174.html#a1d6f62b1c53725b796ea1c4f8843b85d">getSolver</a>()-><a class="code" href="a00171.html#a7331226cd4ef515184dff2d118c43423">getLogLevel</a>()>1) <a name="l00093"></a>00093 <a class="code" href="a00257.html#a4af9f241e955122820c5e81ceb33edb5">logger</a> << <a class="code" href="a00087.html">indent</a>(b-><a class="code" href="a00084.html#a44c879fcf3b6ae9193c393630e25fd13">getLevel</a>()) << <span class="stringliteral">" Procurement buffer '"</span> << b-><a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() <a name="l00094"></a>00094 << <span class="stringliteral">"' is asked: "</span> << data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#adf7c858a404b725f2f2c67648300f89b">q_qty</a> << <span class="stringliteral">" "</span> << data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#a658c5379af8ec535090a96dd969f1fc3">q_date</a> << endl; <a name="l00095"></a>00095 <a name="l00096"></a>00096 <span class="comment">// Standard reply date</span> <a name="l00097"></a>00097 data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#ab56b3877ddc206e8817f04186c0e47a8">a_date</a> = Date::infiniteFuture; <a name="l00098"></a>00098 <a name="l00099"></a>00099 <span class="comment">// Initialize an iterator over reusable existing procurements</span> <a name="l00100"></a>00100 <a class="code" href="a00125.html" title="An operationplan is the key dynamic element of a plan. It represents a certain quantity...">OperationPlan</a> *last_operationplan = NULL; <a name="l00101"></a>00101 <a class="code" href="a00093.html" title="This class models an STL-like iterator that allows us to iterate over the operationplans...">OperationPlan::iterator</a> curProcure(b-><a class="code" href="a00012.html#a403448f5135da4a0199ca43d03e3eb28">getOperation</a>()); <a name="l00102"></a>00102 <span class="keywordflow">while</span> (curProcure != <a class="code" href="a00125.html#a0f9f6ba7d4fe7e20e9b88c765fe24f25">OperationPlan::end</a>() && curProcure->getLocked()) <a name="l00103"></a>00103 ++curProcure; <a name="l00104"></a>00104 set<OperationPlan*> moved; <a name="l00105"></a>00105 <a name="l00106"></a>00106 <span class="comment">// Find the latest locked procurement operation. It is used to know what</span> <a name="l00107"></a>00107 <span class="comment">// the earliest date is for a new procurement.</span> <a name="l00108"></a>00108 <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> earliest_next; <a name="l00109"></a>00109 <span class="keywordflow">for</span> (<a class="code" href="a00093.html" title="This class models an STL-like iterator that allows us to iterate over the operationplans...">OperationPlan::iterator</a> procs(b-><a class="code" href="a00012.html#a403448f5135da4a0199ca43d03e3eb28">getOperation</a>()); <a name="l00110"></a>00110 procs != <a class="code" href="a00085.html#abb9d04973550ac71037718511358f2ff">OperationPlan::end</a>(); ++procs) <a name="l00111"></a>00111 <span class="keywordflow">if</span> (procs->getLocked()) <a name="l00112"></a>00112 earliest_next = procs->getDates().getEnd(); <a name="l00113"></a>00113 <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> latest_next = Date::infiniteFuture; <a name="l00114"></a>00114 <a name="l00115"></a>00115 <span class="comment">// Find constraints on earliest and latest date for the next procurement</span> <a name="l00116"></a>00116 <span class="keywordflow">if</span> (earliest_next && b-><a class="code" href="a00012.html#a8e1343aa1e4e76370356d4a93de47a2b">getMaximumInterval</a>()) <a name="l00117"></a>00117 latest_next = earliest_next + b-><a class="code" href="a00012.html#a8e1343aa1e4e76370356d4a93de47a2b">getMaximumInterval</a>(); <a name="l00118"></a>00118 <span class="keywordflow">if</span> (earliest_next && b-><a class="code" href="a00012.html#ab76ddd340f5507854db8a913afb758b6">getMinimumInterval</a>()) <a name="l00119"></a>00119 earliest_next += b-><a class="code" href="a00012.html#ab76ddd340f5507854db8a913afb758b6">getMinimumInterval</a>(); <a name="l00120"></a>00120 <span class="keywordflow">if</span> (data->constrainedPlanning) <a name="l00121"></a>00121 { <a name="l00122"></a>00122 <span class="keywordflow">if</span> (data-><a class="code" href="a00174.html#a1d6f62b1c53725b796ea1c4f8843b85d">getSolver</a>()-><a class="code" href="a00173.html#a984cf92a5d2fdfbfe91f3d349fd903b2">isLeadtimeConstrained</a>() <a name="l00123"></a>00123 && earliest_next < <a class="code" href="a00132.html#ab297b1f299d472a457784f8022849303">Plan::instance</a>().<a class="code" href="a00132.html#a6a07002deb9c4f380a54a3e3465e487b">getCurrent</a>() + b-><a class="code" href="a00012.html#a6adc5a1e4580c13dfafc9a7f4511a0f9">getLeadtime</a>()) <a name="l00124"></a>00124 earliest_next = <a class="code" href="a00132.html#ab297b1f299d472a457784f8022849303">Plan::instance</a>().<a class="code" href="a00132.html#a6a07002deb9c4f380a54a3e3465e487b">getCurrent</a>() + b-><a class="code" href="a00012.html#a6adc5a1e4580c13dfafc9a7f4511a0f9">getLeadtime</a>(); <a name="l00125"></a>00125 <span class="keywordflow">if</span> (data-><a class="code" href="a00174.html#a1d6f62b1c53725b796ea1c4f8843b85d">getSolver</a>()-><a class="code" href="a00173.html#a1e53acb4eafd521ea81a99f08e8e95ae">isFenceConstrained</a>() <a name="l00126"></a>00126 && earliest_next < <a class="code" href="a00132.html#ab297b1f299d472a457784f8022849303">Plan::instance</a>().<a class="code" href="a00132.html#a6a07002deb9c4f380a54a3e3465e487b">getCurrent</a>() + b-><a class="code" href="a00012.html#a2b36a705f88f52b7a7df0c9d55ef11e4">getFence</a>()) <a name="l00127"></a>00127 earliest_next = <a class="code" href="a00132.html#ab297b1f299d472a457784f8022849303">Plan::instance</a>().<a class="code" href="a00132.html#a6a07002deb9c4f380a54a3e3465e487b">getCurrent</a>() + b-><a class="code" href="a00012.html#a2b36a705f88f52b7a7df0c9d55ef11e4">getFence</a>(); <a name="l00128"></a>00128 } <a name="l00129"></a>00129 <a name="l00130"></a>00130 <span class="comment">// Loop through all flowplans</span> <a name="l00131"></a>00131 <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> current_date; <a name="l00132"></a>00132 <span class="keywordtype">double</span> produced = 0.0; <a name="l00133"></a>00133 <span class="keywordtype">double</span> consumed = 0.0; <a name="l00134"></a>00134 <span class="keywordtype">double</span> current_inventory = 0.0; <a name="l00135"></a>00135 <span class="keyword">const</span> <a class="code" href="a00068.html" title="A flowplan represents a planned material flow in or out of a buffer.">FlowPlan</a>* current_flowplan = NULL; <a name="l00136"></a>00136 <span class="keywordflow">for</span> (Buffer::flowplanlist::const_iterator cur=b-><a class="code" href="a00008.html#ad8189150ceacd114c8cd91346323fa03">getFlowPlans</a>().begin(); <a name="l00137"></a>00137 latest_next != Date::infiniteFuture || cur != b-><a class="code" href="a00008.html#ad8189150ceacd114c8cd91346323fa03">getFlowPlans</a>().end(); ) <a name="l00138"></a>00138 { <a name="l00139"></a>00139 <span class="keywordflow">if</span> (cur==b-><a class="code" href="a00008.html#ad8189150ceacd114c8cd91346323fa03">getFlowPlans</a>().end() || latest_next < cur->getDate()) <a name="l00140"></a>00140 { <a name="l00141"></a>00141 <span class="comment">// Latest procument time is reached</span> <a name="l00142"></a>00142 current_date = latest_next; <a name="l00143"></a>00143 current_flowplan = NULL; <a name="l00144"></a>00144 } <a name="l00145"></a>00145 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (earliest_next && earliest_next < cur->getDate()) <a name="l00146"></a>00146 { <a name="l00147"></a>00147 <span class="comment">// Earliest procument time was reached</span> <a name="l00148"></a>00148 current_date = earliest_next; <a name="l00149"></a>00149 current_flowplan = NULL; <a name="l00150"></a>00150 } <a name="l00151"></a>00151 <span class="keywordflow">else</span> <a name="l00152"></a>00152 { <a name="l00153"></a>00153 <span class="comment">// Date with flowplans found</span> <a name="l00154"></a>00154 <span class="keywordflow">if</span> (current_date && current_date >= cur->getDate()) <a name="l00155"></a>00155 { <a name="l00156"></a>00156 <span class="comment">// When procurements are being moved, it happens that we revisit the</span> <a name="l00157"></a>00157 <span class="comment">// same consuming flowplans twice. This check catches this case.</span> <a name="l00158"></a>00158 cur++; <a name="l00159"></a>00159 <span class="keywordflow">continue</span>; <a name="l00160"></a>00160 } <a name="l00161"></a>00161 current_date = cur->getDate(); <a name="l00162"></a>00162 <span class="keywordtype">bool</span> noConsumers = <span class="keyword">true</span>; <a name="l00163"></a>00163 <span class="keywordflow">do</span> <a name="l00164"></a>00164 { <a name="l00165"></a>00165 <span class="keywordflow">if</span> (cur->getType() != 1) <a name="l00166"></a>00166 { <a name="l00167"></a>00167 cur++; <a name="l00168"></a>00168 <span class="keywordflow">continue</span>; <a name="l00169"></a>00169 } <a name="l00170"></a>00170 current_flowplan = <span class="keyword">static_cast<</span><span class="keyword">const </span><a class="code" href="a00068.html" title="A flowplan represents a planned material flow in or out of a buffer.">FlowPlan</a>*<span class="keyword">></span>(&*(cur++)); <a name="l00171"></a>00171 <span class="keywordflow">if</span> (current_flowplan-><a class="code" href="a00059.html#a665af7bb916d05a8c9a06f1a8170090f">getQuantity</a>() < 0) <a name="l00172"></a>00172 { <a name="l00173"></a>00173 consumed -= current_flowplan-><a class="code" href="a00059.html#a665af7bb916d05a8c9a06f1a8170090f">getQuantity</a>(); <a name="l00174"></a>00174 noConsumers = <span class="keyword">false</span>; <a name="l00175"></a>00175 } <a name="l00176"></a>00176 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (current_flowplan-><a class="code" href="a00068.html#afe1300d2e208fb1420a32caa3568e13d">getOperationPlan</a>()-><a class="code" href="a00125.html#ad76b43eab48c2587255ec1b460f91093">getLocked</a>()) <a name="l00177"></a>00177 produced += current_flowplan-><a class="code" href="a00059.html#a665af7bb916d05a8c9a06f1a8170090f">getQuantity</a>(); <a name="l00178"></a>00178 } <a name="l00179"></a>00179 <span class="comment">// Loop to pick up the last consuming flowplan on the given date</span> <a name="l00180"></a>00180 <span class="keywordflow">while</span> (cur != b-><a class="code" href="a00008.html#ad8189150ceacd114c8cd91346323fa03">getFlowPlans</a>().end() && cur->getDate() == current_date); <a name="l00181"></a>00181 <span class="comment">// No further interest in dates with only producing flowplans.</span> <a name="l00182"></a>00182 <span class="keywordflow">if</span> (noConsumers) <span class="keywordflow">continue</span>; <a name="l00183"></a>00183 } <a name="l00184"></a>00184 <a name="l00185"></a>00185 <span class="comment">// Compute current inventory. The actual onhand in the buffer may be</span> <a name="l00186"></a>00186 <span class="comment">// different since we count only consumers and *locked* producers.</span> <a name="l00187"></a>00187 current_inventory = produced - consumed; <a name="l00188"></a>00188 <a name="l00189"></a>00189 <span class="comment">// Hard limit: respect minimum interval</span> <a name="l00190"></a>00190 <span class="keywordflow">if</span> (current_date < earliest_next) <a name="l00191"></a>00191 { <a name="l00192"></a>00192 <span class="keywordflow">if</span> (current_inventory < -<a class="code" href="a00252.html#a42d90a6275119e1b4ce73c50f1867e60">ROUNDING_ERROR</a> <a name="l00193"></a>00193 && current_date >= data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#a658c5379af8ec535090a96dd969f1fc3">q_date</a> <a name="l00194"></a>00194 && b-><a class="code" href="a00012.html#ab76ddd340f5507854db8a913afb758b6">getMinimumInterval</a>() <a name="l00195"></a>00195 && data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#ab56b3877ddc206e8817f04186c0e47a8">a_date</a> > earliest_next <a name="l00196"></a>00196 && data-><a class="code" href="a00174.html#a1d6f62b1c53725b796ea1c4f8843b85d">getSolver</a>()-><a class="code" href="a00173.html#a8abcb4e32ffb3663bb1cf42d94c96ddc">isMaterialConstrained</a>() <a name="l00197"></a>00197 && data->constrainedPlanning) <a name="l00198"></a>00198 <span class="comment">// The inventory goes negative here and we can't procure more</span> <a name="l00199"></a>00199 <span class="comment">// material because of the minimum interval...</span> <a name="l00200"></a>00200 data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#ab56b3877ddc206e8817f04186c0e47a8">a_date</a> = earliest_next; <a name="l00201"></a>00201 <span class="keywordflow">continue</span>; <a name="l00202"></a>00202 } <a name="l00203"></a>00203 <a name="l00204"></a>00204 <span class="comment">// Now the normal reorder check</span> <a name="l00205"></a>00205 <span class="keywordflow">if</span> (current_inventory >= b-><a class="code" href="a00012.html#a37c714b5271449925c30b0f33c48559d">getMinimumInventory</a>() <a name="l00206"></a>00206 && current_date < latest_next) <a name="l00207"></a>00207 { <a name="l00208"></a>00208 <span class="keywordflow">if</span> (current_date == earliest_next) earliest_next = Date::infinitePast; <a name="l00209"></a>00209 <span class="keywordflow">continue</span>; <a name="l00210"></a>00210 } <a name="l00211"></a>00211 <a name="l00212"></a>00212 <span class="comment">// When we are within the minimum interval, we may need to increase the</span> <a name="l00213"></a>00213 <span class="comment">// size of the latest procurement.</span> <a name="l00214"></a>00214 <span class="keywordflow">if</span> (current_date == earliest_next <a name="l00215"></a>00215 && last_operationplan <a name="l00216"></a>00216 && current_inventory < b->getMinimumInventory()) <a name="l00217"></a>00217 { <a name="l00218"></a>00218 <span class="keywordtype">double</span> origqty = last_operationplan-><a class="code" href="a00125.html#aa32661a65b2309ba7c35576940274687">getQuantity</a>(); <a name="l00219"></a>00219 last_operationplan-><a class="code" href="a00125.html#aa33a70a23ad111e4b2a35ec96757a1fb">setQuantity</a>(<a class="code" href="a00256.html#a6a424b0200f647afe098772dfb8df980">suggestQuantity</a>(b, <a name="l00220"></a>00220 last_operationplan-><a class="code" href="a00125.html#aa32661a65b2309ba7c35576940274687">getQuantity</a>() <a name="l00221"></a>00221 + b-><a class="code" href="a00012.html#a37c714b5271449925c30b0f33c48559d">getMinimumInventory</a>() - current_inventory)); <a name="l00222"></a>00222 produced += last_operationplan-><a class="code" href="a00125.html#aa32661a65b2309ba7c35576940274687">getQuantity</a>() - origqty; <a name="l00223"></a>00223 current_inventory = produced - consumed; <a name="l00224"></a>00224 <span class="keywordflow">if</span> (current_inventory < -<a class="code" href="a00252.html#a42d90a6275119e1b4ce73c50f1867e60">ROUNDING_ERROR</a> <a name="l00225"></a>00225 && data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#ab56b3877ddc206e8817f04186c0e47a8">a_date</a> > earliest_next + b-><a class="code" href="a00012.html#ab76ddd340f5507854db8a913afb758b6">getMinimumInterval</a>() <a name="l00226"></a>00226 && earliest_next + b-><a class="code" href="a00012.html#ab76ddd340f5507854db8a913afb758b6">getMinimumInterval</a>() > data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#a658c5379af8ec535090a96dd969f1fc3">q_date</a> <a name="l00227"></a>00227 && data-><a class="code" href="a00174.html#a1d6f62b1c53725b796ea1c4f8843b85d">getSolver</a>()-><a class="code" href="a00173.html#a8abcb4e32ffb3663bb1cf42d94c96ddc">isMaterialConstrained</a>() <a name="l00228"></a>00228 && data->constrainedPlanning) <a name="l00229"></a>00229 <span class="comment">// Resizing didn't work, and we still have shortage</span> <a name="l00230"></a>00230 data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#ab56b3877ddc206e8817f04186c0e47a8">a_date</a> = earliest_next + b-><a class="code" href="a00012.html#ab76ddd340f5507854db8a913afb758b6">getMinimumInterval</a>(); <a name="l00231"></a>00231 } <a name="l00232"></a>00232 <a name="l00233"></a>00233 <span class="comment">// At this point, we know we need to reorder...</span> <a name="l00234"></a>00234 earliest_next = Date::infinitePast; <a name="l00235"></a>00235 <span class="keywordtype">double</span> order_qty = <a class="code" href="a00256.html#a6a424b0200f647afe098772dfb8df980">suggestQuantity</a>(b, <a name="l00236"></a>00236 b-><a class="code" href="a00012.html#af6e461c261f6fa1100d3ad25577d3d55">getMaximumInventory</a>() - current_inventory); <a name="l00237"></a>00237 <span class="keywordflow">if</span> (order_qty > 0) <a name="l00238"></a>00238 { <a name="l00239"></a>00239 <span class="comment">// Create a procurement or update an existing one</span> <a name="l00240"></a>00240 <span class="keywordflow">if</span> (curProcure == <a class="code" href="a00125.html#a0f9f6ba7d4fe7e20e9b88c765fe24f25">OperationPlan::end</a>()) <a name="l00241"></a>00241 { <a name="l00242"></a>00242 <span class="comment">// No existing procurement can be reused. Create a new one.</span> <a name="l00243"></a>00243 <a class="code" href="a00026.html" title="This command is used to create an operationplan.">CommandCreateOperationPlan</a> *a = <a name="l00244"></a>00244 <span class="keyword">new</span> <a class="code" href="a00026.html" title="This command is used to create an operationplan.">CommandCreateOperationPlan</a>(b-><a class="code" href="a00012.html#a403448f5135da4a0199ca43d03e3eb28">getOperation</a>(), order_qty, <a name="l00245"></a>00245 Date::infinitePast, current_date, data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#a4feb35f2632149a1fa7828750a2f61b5">curDemand</a>); <a name="l00246"></a>00246 last_operationplan = a-><a class="code" href="a00026.html#ab1a9489e2182059cebf9d0fc1606d83d">getOperationPlan</a>(); <a name="l00247"></a>00247 last_operationplan->insertInOperationplanList(); <a name="l00248"></a>00248 produced += last_operationplan->getQuantity(); <a name="l00249"></a>00249 data-><a class="code" href="a00029.html#a0b761c0e2f51f84569de4f242e2cb7b4">add</a>(a); <a name="l00250"></a>00250 } <a name="l00251"></a>00251 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (curProcure->getDates().getEnd() == current_date <a name="l00252"></a>00252 && curProcure->getQuantity() == order_qty) <a name="l00253"></a>00253 { <a name="l00254"></a>00254 <span class="comment">// We can reuse this existing procurement unchanged.</span> <a name="l00255"></a>00255 produced += order_qty; <a name="l00256"></a>00256 last_operationplan = &*curProcure; <a name="l00257"></a>00257 moved.insert(last_operationplan); <a name="l00258"></a>00258 <span class="keywordflow">do</span> <a name="l00259"></a>00259 ++curProcure; <a name="l00260"></a>00260 <span class="keywordflow">while</span> (curProcure != <a class="code" href="a00125.html#a0f9f6ba7d4fe7e20e9b88c765fe24f25">OperationPlan::end</a>() <a name="l00261"></a>00261 && curProcure->getLocked() && moved.find(&*curProcure)!=moved.end()); <a name="l00262"></a>00262 } <a name="l00263"></a>00263 <span class="keywordflow">else</span> <a name="l00264"></a>00264 { <a name="l00265"></a>00265 <span class="comment">// Update an existing procurement to meet current needs</span> <a name="l00266"></a>00266 <a class="code" href="a00031.html" title="This class represents the command of moving an operationplan to a new date and/or...">CommandMoveOperationPlan</a> *a = <a name="l00267"></a>00267 <span class="keyword">new</span> <a class="code" href="a00031.html" title="This class represents the command of moving an operationplan to a new date and/or...">CommandMoveOperationPlan</a>(&*curProcure, Date::infinitePast, current_date, order_qty); <a name="l00268"></a>00268 last_operationplan = a-><a class="code" href="a00031.html#aed800055c540394592b70f71fd181f76">getOperationPlan</a>(); <a name="l00269"></a>00269 moved.insert(last_operationplan); <a name="l00270"></a>00270 data-><a class="code" href="a00029.html#a0b761c0e2f51f84569de4f242e2cb7b4">add</a>(a); <a name="l00271"></a>00271 produced += last_operationplan-><a class="code" href="a00125.html#aa32661a65b2309ba7c35576940274687">getQuantity</a>(); <a name="l00272"></a>00272 <span class="keywordflow">do</span> <a name="l00273"></a>00273 ++curProcure; <a name="l00274"></a>00274 <span class="keywordflow">while</span> (curProcure != <a class="code" href="a00125.html#a0f9f6ba7d4fe7e20e9b88c765fe24f25">OperationPlan::end</a>() <a name="l00275"></a>00275 && curProcure->getLocked() && moved.find(&*curProcure)!=moved.end()); <a name="l00276"></a>00276 } <a name="l00277"></a>00277 <span class="keywordflow">if</span> (b-><a class="code" href="a00012.html#ab76ddd340f5507854db8a913afb758b6">getMinimumInterval</a>()) <a name="l00278"></a>00278 earliest_next = current_date + b-><a class="code" href="a00012.html#ab76ddd340f5507854db8a913afb758b6">getMinimumInterval</a>(); <a name="l00279"></a>00279 } <a name="l00280"></a>00280 <span class="keywordflow">if</span> (b-><a class="code" href="a00012.html#a8e1343aa1e4e76370356d4a93de47a2b">getMaximumInterval</a>()) <a name="l00281"></a>00281 { <a name="l00282"></a>00282 current_inventory = produced - consumed; <a name="l00283"></a>00283 <span class="keywordflow">if</span> (current_inventory >= b-><a class="code" href="a00012.html#af6e461c261f6fa1100d3ad25577d3d55">getMaximumInventory</a>() <a name="l00284"></a>00284 && cur == b-><a class="code" href="a00008.html#ad8189150ceacd114c8cd91346323fa03">getFlowPlans</a>().end()) <a name="l00285"></a>00285 <span class="comment">// Nothing happens any more further in the future.</span> <a name="l00286"></a>00286 <span class="comment">// Abort procuring based on the max inteval</span> <a name="l00287"></a>00287 latest_next = Date::infiniteFuture; <a name="l00288"></a>00288 <span class="keywordflow">else</span> <a name="l00289"></a>00289 latest_next = current_date + b-><a class="code" href="a00012.html#a8e1343aa1e4e76370356d4a93de47a2b">getMaximumInterval</a>(); <a name="l00290"></a>00290 } <a name="l00291"></a>00291 } <a name="l00292"></a>00292 <a name="l00293"></a>00293 <span class="comment">// Get rid of extra procurements that have become redundant</span> <a name="l00294"></a>00294 <span class="keywordflow">while</span> (curProcure != <a class="code" href="a00125.html#a0f9f6ba7d4fe7e20e9b88c765fe24f25">OperationPlan::end</a>()) <a name="l00295"></a>00295 { <a name="l00296"></a>00296 <a class="code" href="a00125.html" title="An operationplan is the key dynamic element of a plan. It represents a certain quantity...">OperationPlan</a> *opplan = &*(curProcure++); <a name="l00297"></a>00297 <span class="keywordflow">if</span> (!opplan-><a class="code" href="a00125.html#ad76b43eab48c2587255ec1b460f91093">getLocked</a>() && moved.find(opplan)!=moved.end()) <a name="l00298"></a>00298 data-><a class="code" href="a00029.html#a0b761c0e2f51f84569de4f242e2cb7b4">add</a>(<span class="keyword">new</span> <a class="code" href="a00027.html" title="This command is used to delete an operationplan.">CommandDeleteOperationPlan</a>(opplan)); <a name="l00299"></a>00299 } <a name="l00300"></a>00300 <a name="l00301"></a>00301 <span class="comment">// Create the answer</span> <a name="l00302"></a>00302 <span class="keywordflow">if</span> (data->constrainedPlanning && (data-><a class="code" href="a00174.html#a1d6f62b1c53725b796ea1c4f8843b85d">getSolver</a>()-><a class="code" href="a00173.html#a1e53acb4eafd521ea81a99f08e8e95ae">isFenceConstrained</a>() <a name="l00303"></a>00303 || data-><a class="code" href="a00174.html#a1d6f62b1c53725b796ea1c4f8843b85d">getSolver</a>()-><a class="code" href="a00173.html#a984cf92a5d2fdfbfe91f3d349fd903b2">isLeadtimeConstrained</a>() <a name="l00304"></a>00304 || data-><a class="code" href="a00174.html#a1d6f62b1c53725b796ea1c4f8843b85d">getSolver</a>()-><a class="code" href="a00173.html#a8abcb4e32ffb3663bb1cf42d94c96ddc">isMaterialConstrained</a>())) <a name="l00305"></a>00305 { <a name="l00306"></a>00306 <span class="comment">// Check if the inventory drops below zero somewhere</span> <a name="l00307"></a>00307 <span class="keywordtype">double</span> shortage = 0; <a name="l00308"></a>00308 <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> startdate; <a name="l00309"></a>00309 <span class="keywordflow">for</span> (Buffer::flowplanlist::const_iterator cur = b-><a class="code" href="a00008.html#ad8189150ceacd114c8cd91346323fa03">getFlowPlans</a>().begin(); <a name="l00310"></a>00310 cur != b-><a class="code" href="a00008.html#ad8189150ceacd114c8cd91346323fa03">getFlowPlans</a>().end(); ++cur) <a name="l00311"></a>00311 <span class="keywordflow">if</span> (cur->getDate() >= data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#a658c5379af8ec535090a96dd969f1fc3">q_date</a> <a name="l00312"></a>00312 && cur->getOnhand() < -<a class="code" href="a00252.html#a42d90a6275119e1b4ce73c50f1867e60">ROUNDING_ERROR</a> <a name="l00313"></a>00313 && cur->getOnhand() < shortage) <a name="l00314"></a>00314 { <a name="l00315"></a>00315 shortage = cur->getOnhand(); <a name="l00316"></a>00316 <span class="keywordflow">if</span> (-shortage >= data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#adf7c858a404b725f2f2c67648300f89b">q_qty</a>) <span class="keywordflow">break</span>; <a name="l00317"></a>00317 <span class="keywordflow">if</span> (startdate == Date::infinitePast) startdate = cur->getDate(); <a name="l00318"></a>00318 } <a name="l00319"></a>00319 <span class="keywordflow">if</span> (shortage < 0) <a name="l00320"></a>00320 { <a name="l00321"></a>00321 <span class="comment">// Answer a shorted quantity</span> <a name="l00322"></a>00322 data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#af34ccc319ed0bd6bb387353e0968e622">a_qty</a> = data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#adf7c858a404b725f2f2c67648300f89b">q_qty</a> + shortage; <a name="l00323"></a>00323 <span class="comment">// Log a constraint</span> <a name="l00324"></a>00324 <span class="keywordflow">if</span> (data->logConstraints) <a name="l00325"></a>00325 data->planningDemand-><a class="code" href="a00051.html#acd06be46dd32eb121e408c5b9e035965">getConstraints</a>().<a class="code" href="a00100.html#add9d396135451bf2efef6527cea7839a">push</a>( <a name="l00326"></a>00326 <a class="code" href="a00146.html#aabbcfbf928d9353d5be6097a1d05942c">ProblemMaterialShortage::metadata</a>, b, startdate, Date::infiniteFuture, <span class="comment">// @todo calculate a better end date</span> <a name="l00327"></a>00327 -shortage); <a name="l00328"></a>00328 <span class="comment">// Nothing to promise...</span> <a name="l00329"></a>00329 <span class="keywordflow">if</span> (data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#af34ccc319ed0bd6bb387353e0968e622">a_qty</a> < 0) data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#af34ccc319ed0bd6bb387353e0968e622">a_qty</a> = 0; <a name="l00330"></a>00330 <span class="comment">// Check the reply date</span> <a name="l00331"></a>00331 <span class="keywordflow">if</span> (data->constrainedPlanning) <a name="l00332"></a>00332 { <a name="l00333"></a>00333 <span class="keywordflow">if</span> (data-><a class="code" href="a00174.html#a1d6f62b1c53725b796ea1c4f8843b85d">getSolver</a>()-><a class="code" href="a00173.html#a1e53acb4eafd521ea81a99f08e8e95ae">isFenceConstrained</a>() <a name="l00334"></a>00334 && data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#a658c5379af8ec535090a96dd969f1fc3">q_date</a> < <a class="code" href="a00132.html#ab297b1f299d472a457784f8022849303">Plan::instance</a>().<a class="code" href="a00132.html#a6a07002deb9c4f380a54a3e3465e487b">getCurrent</a>() + b-><a class="code" href="a00012.html#a2b36a705f88f52b7a7df0c9d55ef11e4">getFence</a>() <a name="l00335"></a>00335 && data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#ab56b3877ddc206e8817f04186c0e47a8">a_date</a> > <a class="code" href="a00132.html#ab297b1f299d472a457784f8022849303">Plan::instance</a>().<a class="code" href="a00132.html#a6a07002deb9c4f380a54a3e3465e487b">getCurrent</a>() + b-><a class="code" href="a00012.html#a2b36a705f88f52b7a7df0c9d55ef11e4">getFence</a>()) <a name="l00336"></a>00336 data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#ab56b3877ddc206e8817f04186c0e47a8">a_date</a> = <a class="code" href="a00132.html#ab297b1f299d472a457784f8022849303">Plan::instance</a>().<a class="code" href="a00132.html#a6a07002deb9c4f380a54a3e3465e487b">getCurrent</a>() + b-><a class="code" href="a00012.html#a2b36a705f88f52b7a7df0c9d55ef11e4">getFence</a>(); <a name="l00337"></a>00337 <span class="keywordflow">if</span> (data-><a class="code" href="a00174.html#a1d6f62b1c53725b796ea1c4f8843b85d">getSolver</a>()-><a class="code" href="a00173.html#a984cf92a5d2fdfbfe91f3d349fd903b2">isLeadtimeConstrained</a>() <a name="l00338"></a>00338 && data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#a658c5379af8ec535090a96dd969f1fc3">q_date</a> < <a class="code" href="a00132.html#ab297b1f299d472a457784f8022849303">Plan::instance</a>().<a class="code" href="a00132.html#a6a07002deb9c4f380a54a3e3465e487b">getCurrent</a>() + b-><a class="code" href="a00012.html#a6adc5a1e4580c13dfafc9a7f4511a0f9">getLeadtime</a>() <a name="l00339"></a>00339 && data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#ab56b3877ddc206e8817f04186c0e47a8">a_date</a> > <a class="code" href="a00132.html#ab297b1f299d472a457784f8022849303">Plan::instance</a>().<a class="code" href="a00132.html#a6a07002deb9c4f380a54a3e3465e487b">getCurrent</a>() + b-><a class="code" href="a00012.html#a6adc5a1e4580c13dfafc9a7f4511a0f9">getLeadtime</a>()) <a name="l00340"></a>00340 data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#ab56b3877ddc206e8817f04186c0e47a8">a_date</a> = <a class="code" href="a00132.html#ab297b1f299d472a457784f8022849303">Plan::instance</a>().<a class="code" href="a00132.html#a6a07002deb9c4f380a54a3e3465e487b">getCurrent</a>() + b-><a class="code" href="a00012.html#a6adc5a1e4580c13dfafc9a7f4511a0f9">getLeadtime</a>(); <a name="l00341"></a>00341 } <a name="l00342"></a>00342 } <a name="l00343"></a>00343 <span class="keywordflow">else</span> <a name="l00344"></a>00344 <span class="comment">// Answer the full quantity</span> <a name="l00345"></a>00345 data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#af34ccc319ed0bd6bb387353e0968e622">a_qty</a> = data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#adf7c858a404b725f2f2c67648300f89b">q_qty</a>; <a name="l00346"></a>00346 } <a name="l00347"></a>00347 <span class="keywordflow">else</span> <a name="l00348"></a>00348 <span class="comment">// Answer the full quantity</span> <a name="l00349"></a>00349 data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#af34ccc319ed0bd6bb387353e0968e622">a_qty</a> = data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#adf7c858a404b725f2f2c67648300f89b">q_qty</a>; <a name="l00350"></a>00350 <a name="l00351"></a>00351 <span class="comment">// Increment the cost</span> <a name="l00352"></a>00352 <span class="keywordflow">if</span> (b-><a class="code" href="a00008.html#ad4c18a30b6a1d8f04cad0435b78bef1c">getItem</a>() && data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#af34ccc319ed0bd6bb387353e0968e622">a_qty</a> > 0.0) <a name="l00353"></a>00353 data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#aa2e444a8091c86f71bbcd6d076c6c574">a_cost</a> += data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#af34ccc319ed0bd6bb387353e0968e622">a_qty</a> * b-><a class="code" href="a00008.html#ad4c18a30b6a1d8f04cad0435b78bef1c">getItem</a>()-><a class="code" href="a00088.html#a20303c6b16c479cf55a353b18886d756">getPrice</a>(); <a name="l00354"></a>00354 <a name="l00355"></a>00355 <span class="comment">// Message</span> <a name="l00356"></a>00356 <span class="keywordflow">if</span> (data-><a class="code" href="a00174.html#a1d6f62b1c53725b796ea1c4f8843b85d">getSolver</a>()-><a class="code" href="a00171.html#a7331226cd4ef515184dff2d118c43423">getLogLevel</a>()>1) <a name="l00357"></a>00357 <a class="code" href="a00257.html#a4af9f241e955122820c5e81ceb33edb5">logger</a> << <a class="code" href="a00087.html">indent</a>(b-><a class="code" href="a00084.html#a44c879fcf3b6ae9193c393630e25fd13">getLevel</a>()) << <span class="stringliteral">" Procurement buffer '"</span> << b <a name="l00358"></a>00358 << <span class="stringliteral">"' answers: "</span> << data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#af34ccc319ed0bd6bb387353e0968e622">a_qty</a> << <span class="stringliteral">" "</span> << data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#ab56b3877ddc206e8817f04186c0e47a8">a_date</a> <a name="l00359"></a>00359 << <span class="stringliteral">" "</span> << data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#aa2e444a8091c86f71bbcd6d076c6c574">a_cost</a> << <span class="stringliteral">" "</span> << data-><a class="code" href="a00174.html#a592e60ca8e03a80e5460bfb1bf973b4e">state</a>-><a class="code" href="a00175.html#ae007a7c0a1074c1fc1dfe9c5eeedcc0e">a_penalty</a> << endl; <a name="l00360"></a>00360 } <a name="l00361"></a>00361 <a name="l00362"></a>00362 <a name="l00363"></a>00363 } </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>