<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to formulate a sumproduct difference in the objective line in Proc OptModel? in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/How-to-formulate-a-sumproduct-difference-in-the-objective-line/m-p/755731#M3433</link>
    <description>&lt;P&gt;I think you want this instead:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;min Objective = (sum {s in SSET} abs(sum {j in JSET} a[s,j]*X[s,j] - szone[s])) / (sum {s in SSET} szone[s]);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The ABS introduces nonlinearity, but in this case you can use the LINEARIZE option in SAS Viya to automatically linearize the problem:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;solve linearize;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;After the solve, you can then print the two parts of the numerator:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;print {s in SSET} (sum {j in JSET} a[s,j]*X[s,j]) szone;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The resulting optimal solution has objective value 1/7, and the two PRINT statements yield:&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Optmodel: X" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c b header" colspan="7" scope="colgroup"&gt;X&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="c headerempty" scope="col"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;1&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;2&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;3&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;4&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;5&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;6&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;696455&lt;/TH&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;824801&lt;/TH&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;920946&lt;/TH&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;&lt;A target="_blank" name="IDX137"&gt;&lt;/A&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Optmodel: PrintTable" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt; &lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l b header" scope="col"&gt;[1]&lt;/TH&gt;
&lt;TH class="c headerempty" scope="col"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;szone&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;696455&lt;/TH&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;824801&lt;/TH&gt;
&lt;TD class="r data"&gt;4&lt;/TD&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;920946&lt;/TH&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
    <pubDate>Wed, 21 Jul 2021 19:35:55 GMT</pubDate>
    <dc:creator>RobPratt</dc:creator>
    <dc:date>2021-07-21T19:35:55Z</dc:date>
    <item>
      <title>How to formulate a sumproduct difference in the objective line in Proc OptModel?</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-to-formulate-a-sumproduct-difference-in-the-objective-line/m-p/755729#M3432</link>
      <description>&lt;P&gt;I am setting up a model in SAS based on an excel solver problem.&lt;/P&gt;&lt;P&gt;in SAS I've set this up with Proc Optmodel but I can't seem to calculate the function in the objective statement that's analogous to ABS( SUMPRODUCT(var1..10,var11..20) - szone) to work... The goal is for each row, the difference between each szone and sumproduct should be minimal.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data WORK.sMatrix;&lt;BR /&gt;Infile datalines delimiter='#';&lt;BR /&gt;input s szone var7 var8 var9 var10 var11 var12;&lt;BR /&gt;datalines;&lt;BR /&gt;824801#3#9#4#6#6#6#6&lt;BR /&gt;696455#3#6#6#6#6#6#3&lt;BR /&gt;920946#1#6#1#6#6#6#6&lt;BR /&gt;;&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;proc optmodel;&lt;BR /&gt;set SSET;&lt;BR /&gt;set JSET = 1..6;&lt;BR /&gt;num a {SSET, JSET};&lt;BR /&gt;num szone {SSET};&lt;/P&gt;&lt;P&gt;read data sMatrix into SSET=[s] {j in JSET} &amp;lt;a[s,j] = col('Var'||(j+6))&amp;gt; szone;&lt;/P&gt;&lt;P&gt;print a szone;&lt;/P&gt;&lt;P&gt;var X {SSET, JSET} binary;&lt;/P&gt;&lt;P&gt;min Objective = (sum {s in SSET, j in JSET} a[s,j]*X[s,j] - &lt;STRONG&gt;&lt;FONT size="5" color="#FF0000"&gt;szone&lt;/FONT&gt;&lt;/STRONG&gt;) / (sum {s in SSET} szone[s]);&lt;/P&gt;&lt;P&gt;con OnceChoice {s in SSET}:&lt;BR /&gt;sum {j in JSET} X[s,j] = 1;&lt;/P&gt;&lt;P&gt;solve;&lt;BR /&gt;print X;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 18:57:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-to-formulate-a-sumproduct-difference-in-the-objective-line/m-p/755729#M3432</guid>
      <dc:creator>SASAlex101</dc:creator>
      <dc:date>2021-07-21T18:57:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to formulate a sumproduct difference in the objective line in Proc OptModel?</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-to-formulate-a-sumproduct-difference-in-the-objective-line/m-p/755731#M3433</link>
      <description>&lt;P&gt;I think you want this instead:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;min Objective = (sum {s in SSET} abs(sum {j in JSET} a[s,j]*X[s,j] - szone[s])) / (sum {s in SSET} szone[s]);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The ABS introduces nonlinearity, but in this case you can use the LINEARIZE option in SAS Viya to automatically linearize the problem:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;solve linearize;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;After the solve, you can then print the two parts of the numerator:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;print {s in SSET} (sum {j in JSET} a[s,j]*X[s,j]) szone;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The resulting optimal solution has objective value 1/7, and the two PRINT statements yield:&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Optmodel: X" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c b header" colspan="7" scope="colgroup"&gt;X&lt;/TH&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="c headerempty" scope="col"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;1&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;2&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;3&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;4&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;5&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;6&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;696455&lt;/TH&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;824801&lt;/TH&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;920946&lt;/TH&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;&lt;A target="_blank" name="IDX137"&gt;&lt;/A&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Optmodel: PrintTable" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt; &lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l b header" scope="col"&gt;[1]&lt;/TH&gt;
&lt;TH class="c headerempty" scope="col"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;szone&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;696455&lt;/TH&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;824801&lt;/TH&gt;
&lt;TD class="r data"&gt;4&lt;/TD&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;920946&lt;/TH&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 21 Jul 2021 19:35:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-to-formulate-a-sumproduct-difference-in-the-objective-line/m-p/755731#M3433</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2021-07-21T19:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to formulate a sumproduct difference in the objective line in Proc OptModel?</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-to-formulate-a-sumproduct-difference-in-the-objective-line/m-p/755740#M3434</link>
      <description>&lt;P&gt;Hi Rob. thanks! the suggestion for szone[s] errored. but I think I got this to work:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;min Objective = (sum {s in SSET, j in JSET} a[s,j]*X[s,j]) - (sum{s in SSET} szone[s]) / (sum {s in SSET} szone[s]);&lt;/PRE&gt;&lt;P&gt;You're right the problem is non-linear with ABS, so I also tried with&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;min Objective = ((sum {s in SSET, j in JSET} a[s,j]*X[s,j]) - (sum{s in SSET} szone[s]))^2 / (sum {s in SSET} szone[s]);&lt;/PRE&gt;&lt;P&gt;and SAS didn't like it.&amp;nbsp;&lt;BR /&gt;I then tried the linearize option but it errored. the following code throws an error:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data WORK.sMatrix;
Infile datalines delimiter='#';
input s szone var7 var8 var9 var10 var11 var12;
datalines;
824801#3#9#4#6#6#6#6
696455#3#6#6#6#6#6#3
920946#1#6#1#6#6#6#6
;
Run;

proc optmodel;
ods output PrintTable#3=expt3;

set SSET;
set JSET = 1..6;
num a {SSET, JSET};
num szone {SSET};

read data  sMatrix into SSET=[s] {j in JSET} &amp;lt;a[s,j]=col('Var'||(j+6))&amp;gt; szone;

print a szone;

var X {SSET, JSET} binary;

constraint OnceChoice {s in SSET}: sum {j in JSET} X[s,j] = 1;

min Objective = abs((sum {s in SSET, j in JSET} a[s,j]*X[s,j]) - (sum{s in SSET} szone[s])) / (sum {s in SSET} szone[s]);

solve linearize; 
print X;

quit;&lt;/PRE&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;ERROR 22-322: Syntax error, expecting one of the following: /, OBJECTIVE, WITH.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/FONT&gt;&lt;BR /&gt;I'm using SAS EG 8.2 (8.2.0.1201) (64 bit)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks Rob!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 20:34:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-to-formulate-a-sumproduct-difference-in-the-objective-line/m-p/755740#M3434</guid>
      <dc:creator>SASAlex101</dc:creator>
      <dc:date>2021-07-21T20:34:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to formulate a sumproduct difference in the objective line in Proc OptModel?</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-to-formulate-a-sumproduct-difference-in-the-objective-line/m-p/755748#M3435</link>
      <description>&lt;P&gt;The LINEARIZE option to automatically linearize is available only in SAS Optimization (SAS Viya) and not SAS/OR (SAS 9), but you can manually linearize as follows:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;var Abs {SSET};
con AbsCon1 {s in SSET}:
   Abs[s] &amp;gt;= sum {j in JSET} a[s,j]*X[s,j] - szone[s];
con AbsCon2 {s in SSET}:
   Abs[s] &amp;gt;= -sum {j in JSET} a[s,j]*X[s,j] + szone[s];
min Objective = (sum {s in SSET} Abs[s]) / (sum {s in SSET} szone[s]);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Jul 2021 20:57:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-to-formulate-a-sumproduct-difference-in-the-objective-line/m-p/755748#M3435</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2021-07-21T20:57:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to formulate a sumproduct difference in the objective line in Proc OptModel?</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-to-formulate-a-sumproduct-difference-in-the-objective-line/m-p/755752#M3436</link>
      <description>thanks Rob. this seemed to work. Can you provide any resources that you learned from on how to linearize non linear problems? Your help is much appreciated.&lt;BR /&gt;&lt;BR /&gt;I'd also like your take on this approach that I tried... but it took a while to calculate. If you remove the binary condition on the X variable and put two constraints&lt;BR /&gt;constraint XlowerBound {s in SSET}: max {j in JSET} X[s,j] = 1;&lt;BR /&gt;constraint XupperBound {s in SSET}: Min {j in JSET} X[s,j] = 0;&lt;BR /&gt;this allows the variables to 'buldge' a bit and then one would just take the value in the X matrix closest to 1 and consider any small numbers as 0?&lt;BR /&gt;696455 (0.0000448520) (0.0000855790) 0.0003038620 (0.0000649350) (0.0001077940) 1.0000031530&lt;BR /&gt;824801 0.0000962030 0.9997714850 (0.0001034780) 0.0001833090 0.0003918160 (0.0001043860)&lt;BR /&gt;920946 0.0002939980 1.0000106140 0.0000202700 (0.0001121620) (0.0001144810) (0.0001099790)&lt;BR /&gt;&lt;BR /&gt;seems to be the same solution?&lt;BR /&gt;&lt;BR /&gt;thanks Rob;&lt;BR /&gt;</description>
      <pubDate>Wed, 21 Jul 2021 21:09:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-to-formulate-a-sumproduct-difference-in-the-objective-line/m-p/755752#M3436</guid>
      <dc:creator>SASAlex101</dc:creator>
      <dc:date>2021-07-21T21:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to formulate a sumproduct difference in the objective line in Proc OptModel?</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-to-formulate-a-sumproduct-difference-in-the-objective-line/m-p/755757#M3437</link>
      <description>Thanks Rob. I'd love your take on an alternate solution that seemed to go quite a bit slower but yeilded the same result (kinda)&lt;BR /&gt;remove the binary type on the X variable&lt;BR /&gt;constraints:&lt;BR /&gt;constraint OnceChoice {s in SSET}: sum {j in JSET} X[s,j] = 1;&lt;BR /&gt;constraint XlowerBound {s in SSET}: max {j in JSET} X[s,j] = 1;&lt;BR /&gt;constraint XupperBound {s in SSET}: Min {j in JSET} X[s,j] = 0;&lt;BR /&gt;&lt;BR /&gt;then the result is real numbers that seem are almost exact and one can just pick the one closest to 1 and call small numbers 0. What do you think of this approach?&lt;BR /&gt;&lt;BR /&gt;Also I'd love to know any resources on linearization that you may have used to gain your knowledge.&lt;BR /&gt;&lt;BR /&gt;Thanks Rob;</description>
      <pubDate>Wed, 21 Jul 2021 21:28:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-to-formulate-a-sumproduct-difference-in-the-objective-line/m-p/755757#M3437</guid>
      <dc:creator>SASAlex101</dc:creator>
      <dc:date>2021-07-21T21:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to formulate a sumproduct difference in the objective line in Proc OptModel?</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-to-formulate-a-sumproduct-difference-in-the-objective-line/m-p/755767#M3438</link>
      <description>&lt;P&gt;Relaxing integrality on X is a reasonable approach to try for cases when you cannot linearize, but it is not guaranteed to yield anything close to an integer solution, so you were a bit lucky here.&amp;nbsp; Also, the MIN and MAX operators introduce additional nonlinearity that you should avoid.&amp;nbsp; To relax integrality, the simplest change is instead to use the RELAXINT option:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;solve relaxint;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Alternatively, you can change the declaration of X:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;var X {SSET, JSET} &amp;gt;= 0 &amp;lt;= 1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Another way is to set the .LB and .UB suffixes:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;var {SSET, JSET};
for {s in SSET, j in JSET} do;
   X[s,j].lb = 0;
   X[s,j].ub = 1;
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Yet another way is to impose explicit constraints:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* two constraints */
con XlowerBound {s in SSET, j in JSET}:
   X[s,j] &amp;gt;= 0;
con XupperBound {s in SSET, j in JSET}:
   X[s,j] &amp;lt;= 1;

/* one range constraint */
con XBound {s in SSET, j in JSET}:
   0 &amp;lt;= X[s,j] &amp;lt;= 1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The presolver will replace such constraints with bounds, anyway, so I recommend just using RELAXINT here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding manual linearization, you can find numerous examples in &lt;A href="https://go.documentation.sas.com/doc/en/ormpex/15.2/titlepage.htm" target="_self"&gt;this book&lt;/A&gt;.&amp;nbsp; &amp;nbsp;Look for "linearization" in the Subject Index in the pdf.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The new automatic linearization techniques are discussed &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_015/casmopt/casmopt_optmodel_details57.htm" target="_self"&gt;here&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 22:15:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-to-formulate-a-sumproduct-difference-in-the-objective-line/m-p/755767#M3438</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2021-07-21T22:15:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to formulate a sumproduct difference in the objective line in Proc OptModel?</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-to-formulate-a-sumproduct-difference-in-the-objective-line/m-p/755787#M3439</link>
      <description>Thanks Rob. This is very helpful. Last question if you had the time, I mapped out the constraints and I'm not fully understanding how it represents an abs() function...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;con AbsCon1 {s in SSET}:&lt;BR /&gt;Abs[s] &amp;gt;= sum {j in JSET} a[s,j]*X[s,j] - szone[s];&lt;BR /&gt;&lt;BR /&gt;con AbsCon2 {s in SSET}:&lt;BR /&gt;Abs[s] &amp;gt;= -sum {j in JSET} a[s,j]*X[s,j] + szone[s];&lt;BR /&gt;&lt;BR /&gt;min Objective = (sum {s in SSET} Abs[s]) / (sum {s in SSET} szone[s]);&lt;BR /&gt;&lt;BR /&gt;for one particular row we would have szone =4 and some choices 1 2 3 4 and 5.&lt;BR /&gt;&lt;BR /&gt;szone&amp;nbsp; choice&amp;nbsp;&amp;nbsp;&amp;nbsp; AbsCon1&amp;nbsp;&amp;nbsp; AbsCon2&amp;nbsp;&amp;nbsp; met&lt;BR /&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; yes&lt;BR /&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; no&lt;BR /&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; no&lt;BR /&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; yes&lt;BR /&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; yes&lt;BR /&gt;&lt;BR /&gt;min (-1, -1, 0) = -1&amp;nbsp; either -1 or -1 corresponding to choice 3 or 5. Shouldnt the correct answer be 0? corresponding to a choice of 4?</description>
      <pubDate>Wed, 21 Jul 2021 23:38:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-to-formulate-a-sumproduct-difference-in-the-objective-line/m-p/755787#M3439</guid>
      <dc:creator>SASAlex101</dc:creator>
      <dc:date>2021-07-21T23:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to formulate a sumproduct difference in the objective line in Proc OptModel?</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-to-formulate-a-sumproduct-difference-in-the-objective-line/m-p/755820#M3440</link>
      <description>&lt;P&gt;The two columns labeled AbsCon1 and AbsCon2 in your table should always have opposite signs.&amp;nbsp; When you correct the table, I think you will see that Abs[s] &amp;gt;= 0.&amp;nbsp; You can also deduce that by adding the two constraints: everything on the right-hand side cancels in pairs, yielding 2*Abs[s] &amp;gt;= 0, equivalently, Abs[s] &amp;gt;= 0.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jul 2021 02:17:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-to-formulate-a-sumproduct-difference-in-the-objective-line/m-p/755820#M3440</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2021-07-22T02:17:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to formulate a sumproduct difference in the objective line in Proc OptModel?</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/How-to-formulate-a-sumproduct-difference-in-the-objective-line/m-p/755960#M3441</link>
      <description>&lt;P&gt;You're right. My mistake. Thanks so much Rob.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jul 2021 14:39:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/How-to-formulate-a-sumproduct-difference-in-the-objective-line/m-p/755960#M3441</guid>
      <dc:creator>SASAlex101</dc:creator>
      <dc:date>2021-07-22T14:39:17Z</dc:date>
    </item>
  </channel>
</rss>

