<!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>Frepple / SetupMatrix</title> <link rel='stylesheet' href='../styles.css' type='text/css' /> <!--PageHeaderFmt--> </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='Main.html'>Reference Manual</a></h3> <h3><a href='../Main/FAQ.html'>FAQ</a></h3> <h3><a href='../reference/index.html'>C++ API</a></h3> <br/><div> </div> </div> </div> <div id="content"> <br/> <!--PageText--> <div id='wikitext'> <p><a class='wikilink' href='../Main/HomePage.html'>Main</a> > <span class='wikitrail'><a class='wikilink' href='Main.html'>Reference Manual</a> > <a class='wikilink' href='Modeling.html'>Modeling</a> > <a class='selflink' href='ModelingSetupmatrix.html'>SetupMatrix</a></span> </p> <p class='vspace'>A setup matrix defines the time and cost of setup conversions on a resource. Within a setup matrix rules are used to define the changeover cost and duration. </p> <p class='vspace'>To compute the time of a changeover the algorithm will evaluate all rules in sequence (in order of priority).<br />For a rule to match the changeover between the original setup X to a new setup Y, two conditions need to be fulfilled: </p><ul><li>The original setup X must match with the fromsetup of the rule.<br /> If the fromsetup field is empty, it is considered a match. </li><li>The new setup Y must match with the tosetup of the rule.<br /> If the tosetup field is empty, it is considered a match. </li></ul><p>The wildcard characters * and ? can be used in the fromsetup and tosetup fields.<br />As soon as a matching rule is found, it is applied and subsequent rules are not evaluated.<br />If no matching rule is found, the changeover is not allowed. </p> <p class='vspace'>For instance, consider a setup matrix with the following rules: </p> <table border='1' ><tr ><th >Priority</th><th >From</th><th >To</th><th >Duration</th><th >Cost</th></tr> <tr ><td >1</td><td >*green</td><td >*green</td><td >0</td><td >10</td></tr> <tr ><td >2</td><td >*red</td><td >*red</td><td >0</td><td >10</td></tr> <tr ><td >3</td><td >*green</td><td >*red</td><td >1 day</td><td >50</td></tr> <tr ><td >4</td><td >*green</td><td > </td><td >2 day</td><td >50</td></tr> <tr ><td >5</td><td > </td><td > </td><td >3 day</td><td >50</td></tr> </table><p>Based on this matrix: </p><ul><li>A change from "lightgreen" to "darkgreen" takes no time, but costs 10. Rule 1 applies. </li><li>A change from "green" to "black" takes 2 days and costs 50. Rule 4 applies. </li><li>A change from "red" to "black" takes 3 days and costs 50. Rule 5 applies.<br /> Without rule 5 this changeover would not be allowed. </li></ul><div class='vspace'></div><h2>Fields</h2> <table border='1' width="100%" ><tr><td width='20%' valign='top'><strong>Field</strong> </td><td width='20%' valign='top'><strong>Type</strong> </td><td width='60%' valign='top'><strong>Description</strong> </td></tr><tr><td valign='top'>name </td><td valign='top'>non-empty string </td><td valign='top'> <p>Name of the setup matrix.<br />This is the key field and a required attribute. </p></td></tr><tr><td valign='top'>rules </td><td valign='top'>list of setup matrix rules </td><td valign='top'> <p>A read-only list of rules in this matrix. </p></td></tr><tr><td valign='top'>action </td><td valign='top'>A<br />C<br />AC (default)<br />R </td><td valign='top'> <p>Type of action to be executed: </p><ul><li>A: Add an new entity, and report an error if the entity already exists. </li><li>C: Change an existing entity, and report an error if the entity doesn't exist yet. </li><li>AC: Change an entity or create a new one if it doesn't exist yet. </li><li>R: Remove an entity, and report an error if the entity doesn't exist. </li></ul></td></tr></table> <div class='vspace'></div> <table border='1' width='100%' ><tr><td width='30%' valign='top'><strong>Method</strong> </td><td width='70%' valign='top'><strong>Description</strong> </td></tr><tr><td valign='top'>addRule(priority=[integer], fromsetup=[string], tosetup=[string], duration=[timeperiod], cost=[number]) </td><td valign='top'> <p>This method adds a new rule to the matrix.<br />Only the priority keyword is compulsary. The other arguments are optional. </p></td></tr></table> <p class='vspace'><a name='SETUP_RULE' id='SETUP_RULE'></a> </p><h2>Setup Rule</h2> <p>Within a setup matrix rules are used to define the changeover cost and duration. <br />The rules are evaluated in sequence, starting with the lowest priority number. </p> <div class='vspace'></div> <table border='1' width="100%" ><tr><td width='20%' valign='top'><strong>Field</strong> </td><td width='20%' valign='top'><strong>Type</strong> </td><td width='60%' valign='top'><strong>Description</strong> </td></tr><tr><td valign='top'>priority </td><td valign='top'>integer </td><td valign='top'> <p>The priority of the rule. Rules are evaluated in the order of priority - lower numbers first.<br />This is the key field </p></td></tr><tr><td valign='top'>fromsetup </td><td valign='top'>String </td><td valign='top'> <p>The previous setup.<br />If the field is empty the rules applies to any previous setup value.<br />Wildcard characters are allowed in this string: </p><ul><li>* matches a sequence of characters </li><li>? matches a single character </li></ul></td></tr><tr><td valign='top'>tosetup </td><td valign='top'>String </td><td valign='top'> <p>The new setup.<br />If the field is empty the rules applies to any new setup value.<br />Wildcard characters are allowed in this string, similar as in the fromsetup field. </p></td></tr><tr><td valign='top'>duration </td><td valign='top'>timeperiod </td><td valign='top'> <p>Duration of the changeover. </p></td></tr><tr><td valign='top'>cost </td><td valign='top'>double </td><td valign='top'> <p>Cost of the changeover. </p></td></tr></table> <div class='vspace'></div><h2>Example XML structures</h2> <ul><li>Adding or changing setup matrices </li></ul><pre> <plan> <setupmatrtices> <setupmatrix name="Painting line changeover"> <rules> <rule priority="1" fromsetup="green" tosetup="red" duration="P0D" cost="10" /> <rule priority="2" fromsetup="red" tosetup="green" duration="P0D" cost="10" /> <rule priority="3" fromsetup="white" tosetup="black" duration="P10D" cost="50"/> <rule priority="4" fromsetup="black" tosetup="white" duration="P10D" cost="50"/> <rule priority="5" fromsetup="yellow" duration="P2D" cost="20"/> <rule priority="6" tosetup="yellow" duration="P2D" cost="20"/> <rule priority="6" duration="P3D" /> </rules> </setupmatrix> </setupmatrtices> </plan> </pre><div class='vspace'></div><ul><li>Deleting a setup matrix </li></ul><pre> <plan> <setupmatrtices> <setupmatrtix name="changovers" action="R"/> </setupmatrtices> </plan> </pre><div class='vspace'></div><h2>Example Python code</h2> <ul><li>Adding or changing setup matrices </li></ul><pre> matrix = frepple.setupmatrix(name="changeovers for paint line") matrix.addRule(priority=1, fromsetup="*green", cost=10) </pre><div class='vspace'></div><ul><li>Deleting a setup matrix </li></ul><pre> frepple.setupmatrix(name="changeovers for paint line", action="R") </pre><div class='vspace'></div><ul><li>Iterate over setup matrices and setup matrix rules </li></ul><pre> for m in frepple.setupmatrices(): print "Matrix '%s' has the following rules:" % m.name for i in m.rules: print " ", i.priority, i.tosetup, i.fromsetup, print i.duration, i.cost </pre> </div> <!--PageFooterFmt--> <!--HTMLFooter--> </div></div> </body> </html>