<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.E-MailFormatvorlage17
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=DE link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>Hi James,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>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:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>%data : sources set, destinations set, s[sources], d[destinations], c[sources,destinations] <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>parameters:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>             { i in sources , j in destinations: <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>        costs[i,j]:= c[i,j]*d[j]; <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>    }        <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>             <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>variables:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>             x[sources,destinations]: binary;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>             </span><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:red;mso-fareast-language:EN-US'>u[sources]:real[0..];<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:red;mso-fareast-language:EN-US'>             o[sources]:real[0..];<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>objectives:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>             #Total_cost: sum{i in sources, j in destinations : #costs[i,j] * x[i,j]} +<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>             </span><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:red;mso-fareast-language:EN-US'>sum{i in sources: u[i]+o[i]} ->min;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>constraints:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>             </span><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:red;mso-fareast-language:EN-US'>supplies {i in sources  : sum{j in destinations: d[j]*x[i,j]} +u[i] -o[i] = s[i]*0.8;}<o:p></o:p></span></p><p class=MsoNormal style='text-indent:35.4pt'><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'> demands  {j in destinations : sum{i in sources : x[i,j]} =  1;} <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>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. <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>This absolute differences of the actual quantities to the supplies of the sources are to be minimised in the objective function.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>Cheers,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>Mike<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'> <o:p></o:p></span></p><p class=MsoNormal><a name="_MailEndCompose"><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></a></p><p class=MsoNormal><b><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'>Von:</span></b><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'> Cmpl [mailto:cmpl-bounces@coin-or.org] <b>Im Auftrag von </b>James Carlson<br><b>Gesendet:</b> Samstag, 25. November 2017 04:10<br><b>An:</b> cmpl@list.coin-or.org<br><b>Betreff:</b> [Cmpl] objective function with a percentage (divisor)<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><div><div><div><div><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>------------------------------------------------------------------------------------------------------------------------------------------<br>%data : sources set, destinations set, s[sources], d[destinations], c[sources,destinations] <br>%display nonZeros<br><br>parameters:<br>    { i in sources , j in destinations: costs[i,j]:= c[i,j]*d[j]; }    <br>    <br>variables:<br>    x[sources,destinations]: binary;<br><br>objectives:<br>    Total_cost: sum{i in sources, j in destinations : costs[i,j] * x[i,j]} +<br>                sum{i in sources  : sum{j in destinations: d[j]*x[i,j]} - s[i]}  ->min;<br><br>constraints:<br>    supplies {i in sources  : sum{j in destinations: d[j]*x[i,j]} >= s[i]*0.8;}<br>    demands  {j in destinations : sum{i in sources : x[i,j]} =  1;} <br>------------------------------------------------------------------------------------------------------------------------------------------<o:p></o:p></p></div><p class=MsoNormal style='margin-bottom:12.0pt'>I would like to try something like this for my objectives:<br><br>    Total_cost: sum{i in sources, j in destinations : costs[i,j] * x[i,j]} +<br>                sum{i in sources  : sum{j in destinations: d[j]*x[i,j]} - s[i]}<b>/s[i]</b>  ->min;<o:p></o:p></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).  <o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><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.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Any suggestions would be appreciated!  thank you. <o:p></o:p></p></div><p class=MsoNormal><o:p> </o:p></p></div></div></body></html>