<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi James,<div class=""><br class=""></div><span class="">The total demand has to be unequal to the total supply. (You used obviously the expression s[i]*0.8 in your original model to have unequal demands and supplies due to the equal demands and supplies in your Excel sheet):<br class=""></span><span class=""><br class=""></span><div class="">Thanks,</div><div class=""><br class=""></div><div class="">Mike<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">Am 25.11.2017 um 21:51 schrieb James Carlson <<a href="mailto:jddcarlson@gmail.com" class="">jddcarlson@gmail.com</a>>:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class=""><div class="">hey Mike,<br class=""><br class=""></div>Thank you for he prompt reply. As you very accurately stated i am attempting to minimize the under and over delivery (thank you for the clarification). I have implemented your suggestions and it runs in the Solver. It appears the u and o arrays are zero could you suggest how i should define the U and O arrays in CMPL so they are non-zero values? Attached is an updated model ... thank you again for your help!<br class=""><br class=""></div>James<br class=""><br class=""></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sat, Nov 25, 2017 at 10:38 AM, Mike Steglich <span dir="ltr" class=""><<a href="mailto:mike.steglich@berlin.de" target="_blank" class="">mike.steglich@berlin.de</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div link="#0563C1" vlink="#954F72" lang="DE" class=""><div class="m_4196990214122144165WordSection1"><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class="">Hi James,<u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class="">If I am right to assume that you want to minimise the under and over delivery (beside the transportation costs) then I would like to propose the following model:<u class=""></u><u class=""></u></span></p><span class=""><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class=""><u class=""></u> <u class=""></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class="">%data : sources set, destinations set, s[sources], d[destinations], c[sources,destinations] <u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class=""><u class=""></u> <u class=""></u></span></p></span><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class="">parameters:<u class=""></u><u class=""></u></span></p><span class=""><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class=""> { i in sources , j in destinations: <u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class=""> costs[i,j]:= c[i,j]*d[j]; <u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class=""> } <u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class=""> <u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class="">variables:<u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class=""> x[sources,destinations]: binary;<u class=""></u><u class=""></u></span></p></span><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class=""> </span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:red" lang="EN-GB" class="">u[sources]:real[0..];<u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:red" lang="EN-GB" class=""> o[sources]:real[0..];<u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class="">objectives:<u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class=""> #Total_cost: sum{i in sources, j in destinations : #costs[i,j] * x[i,j]} +<u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class=""> </span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:red" lang="EN-GB" class="">sum{i in sources: u[i]+o[i]} ->min;<u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class=""><u class=""></u> <u class=""></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class="">constraints:<u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class=""> </span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:red" lang="EN-GB" class="">supplies {i in sources : sum{j in destinations: d[j]*x[i,j]} +u[i] -o[i] = s[i]*0.8;}<u class=""></u><u class=""></u></span></p><span class=""><p class="MsoNormal" style="text-indent:35.4pt"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class=""> demands {j in destinations : sum{i in sources : x[i,j]} = 1;} <u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class=""><u class=""></u> <u class=""></u></span></p></span><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class="">There are to new vectors of non-negative, continues variables (u for under deliveries and o for over deliveries) to be used in the extended supply constraints. <u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class=""><u class=""></u> <u class=""></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class="">This absolute differences of the actual quantities to the supplies of the sources are to be minimised in the objective function.<u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class=""><u class=""></u> <u class=""></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class="">Cheers,<u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class=""><u class=""></u> <u class=""></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class="">Mike<u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class=""> <u class=""></u><u class=""></u></span></p><p class="MsoNormal"><a name="m_4196990214122144165__MailEndCompose" class=""><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-GB" class=""><u class=""></u> <u class=""></u></span></a></p><p class="MsoNormal"><b class=""><span style="font-size:11.0pt;font-family:"Calibri",sans-serif" class="">Von:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif" class=""> Cmpl [mailto:<a href="mailto:cmpl-bounces@coin-or.org" target="_blank" class="">cmpl-bounces@coin-or.<wbr class="">org</a>] <b class="">Im Auftrag von </b>James Carlson<br class=""><b class="">Gesendet:</b> Samstag, 25. November 2017 04:10<br class=""><b class="">An:</b> <a href="mailto:cmpl@list.coin-or.org" target="_blank" class="">cmpl@list.coin-or.org</a><br class=""><b class="">Betreff:</b> [Cmpl] objective function with a percentage (divisor)<u class=""></u><u class=""></u></span></p><div class=""><div class="h5"><p class="MsoNormal"><u class=""></u> <u class=""></u></p><div class=""><div class=""><div class=""><div class=""><p class="MsoNormal" style="margin-bottom:12.0pt">good evening, I am new to CMPL. I took several LP and combination optimization courses in university - in other words I am very new to this! I have successfully created a model in SolverStudio and the results seem reasonable. I am now attempting to change the objective function so the that difference between the delivered volume versus the demand is a ratio (or absolute). Attached is my model:<br class="">------------------------------<wbr class="">------------------------------<wbr class="">------------------------------<wbr class="">------------------------------<wbr class="">------------------<br class="">%data : sources set, destinations set, s[sources], d[destinations], c[sources,destinations] <br class="">%display nonZeros<br class=""><br class="">parameters:<br class=""> { i in sources , j in destinations: costs[i,j]:= c[i,j]*d[j]; } <br class=""> <br class="">variables:<br class=""> x[sources,destinations]: binary;<br class=""><br class="">objectives:<br class=""> Total_cost: sum{i in sources, j in destinations : costs[i,j] * x[i,j]} +<br class=""> sum{i in sources : sum{j in destinations: d[j]*x[i,j]} - s[i]} ->min;<br class=""><br class="">constraints:<br class=""> supplies {i in sources : sum{j in destinations: d[j]*x[i,j]} >= s[i]*0.8;}<br class=""> demands {j in destinations : sum{i in sources : x[i,j]} = 1;} <br class="">------------------------------<wbr class="">------------------------------<wbr class="">------------------------------<wbr class="">------------------------------<wbr class="">------------------<u class=""></u><u class=""></u></p></div><p class="MsoNormal" style="margin-bottom:12.0pt">I would like to try something like this for my objectives:<br class=""><br class=""> Total_cost: sum{i in sources, j in destinations : costs[i,j] * x[i,j]} +<br class=""> sum{i in sources : sum{j in destinations: d[j]*x[i,j]} - s[i]}<b class="">/s[i]</b> ->min;<u class=""></u><u class=""></u></p></div><p class="MsoNormal">As i mentioned above I am attempting to make the OF minimize the error as a percentage delivered to each destination. This is meant to overcome the problem of an under or over delivery is offset by an equal (negative or positive) amount so the function is not really minimizing the value (it is always almost zero due to aggregation of offsetting positive and negative values). <u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal"><u class=""></u> <u class=""></u></p></div><div class=""><p class="MsoNormal">Attached is an OpenSolver excel model (in a zip file). Please note I have made all the costs equal to 1 to better diagnose the OF's second term.<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal"><u class=""></u> <u class=""></u></p></div><div class=""><p class="MsoNormal">Any suggestions would be appreciated! thank you. <u class=""></u><u class=""></u></p></div><p class="MsoNormal"><u class=""></u> <u class=""></u></p></div></div></div></div></div></blockquote></div><br class=""></div>
<span id="cid:5EB3FDB8-40A2-403F-AC2A-ABD15CF73FCB"><tester-added_Mikes_suggestions.zip></span></div></blockquote></div><br class=""></div></body></html>