<?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: Cannot Get the Co-efficients to match up - Optimizing the error in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/Cannot-Get-the-Co-efficients-to-match-up-Optimizing-the-error/m-p/674543#M3197</link>
    <description>&lt;P&gt;Reading the entire dataset and then go to SOLVE part.&lt;/P&gt;</description>
    <pubDate>Tue, 04 Aug 2020 20:01:25 GMT</pubDate>
    <dc:creator>david27</dc:creator>
    <dc:date>2020-08-04T20:01:25Z</dc:date>
    <item>
      <title>Cannot Get the Co-efficients to match up - Optimizing the error</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Cannot-Get-the-Co-efficients-to-match-up-Optimizing-the-error/m-p/674347#M3192</link>
      <description>&lt;P&gt;Team &amp;amp;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1636"&gt;@RobPratt&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please look into the below code.&lt;/P&gt;&lt;P&gt;First I am assigning values to w1-w8 and b1-b3.&lt;/P&gt;&lt;P&gt;Then i am verifying that everything is populated in the correct fashion in the &lt;STRONG&gt;verification_dsn&lt;/STRONG&gt; dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am then using proc optmodel to validate if i reach similar/same numbers for w1-w8 and b1-b3.&lt;/P&gt;&lt;P&gt;But everything comes out as 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had this example in excel and then using solver, i reached the numbers for w1-w8 and b1-b3.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;The formulas for minimize function and the constraint are exactly same.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;For example: If a+b=c then c-b=a.&amp;nbsp;&lt;/STRONG&gt;And I am just trying to validate that.&lt;/P&gt;&lt;P&gt;&lt;U&gt;But something is a miss here.&amp;nbsp;&lt;/U&gt;&lt;BR /&gt;Please advise.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank You.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;: Tagging you because I thought you must be interested in the solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data equation;
input y m x c;
datalines;
14 9 1 5
851 9 94 5
473 9 52 5
635 9 70 5
518 9 57 5
257 9 28 5
383 9 42 5
428 9 47 5
356 9 39 5
68 9 7 5
257 9 28 5
248 9 27 5
194 9 21 5
86 9 9 5
761 9 84 5
284 9 31 5
653 9 72 5
356 9 39 5
320 9 35 5
;run;
%let w1=0.094961;
%let w2=0.008734;
%let w3=6.21478;
%let w4=7.002409;
%let w5=0.012339;
%let w6=0.396723;
%let w7=13.94726;
%let w8=1.045836;

%let b1=0;
%let b2=0;
%let b3=0;
data verification_dsn;
	set equation;
w1=0.094961;
w2=0.008734;
w3=6.21478;
w4=7.002409;
w5=0.012339;
w6=0.396723;
w7=13.94726;
w8=1.045836;

b1=0;
b2=0;
b3=0;
	n1h1=x*&amp;amp;w1.-&amp;amp;b1.;
	n2h1=x*&amp;amp;w2.-&amp;amp;b1.;
	n1h2=((x*&amp;amp;w1.-&amp;amp;b1.)*&amp;amp;w3.)+((x*&amp;amp;w2.-&amp;amp;b1.)*&amp;amp;w4.)-&amp;amp;b2.;
	n2h2=(n1h1*&amp;amp;w5.)+(n2h1*&amp;amp;w6.)-&amp;amp;b2.;
	output_network=(n1h2*&amp;amp;w7.)+(n2h2*&amp;amp;w8.)-&amp;amp;b3.;
	sq_diff=(y-output_network)**2;
	minimize_function=(y-(((((x*w1-b1)*w3)+((x*w2-b1)*w4)-b2)*w7)+((((x*w1-b1)*w5)+((x*w2-b1)*w6)-b2)*w8)-b3))**2;
	constraint=abs(((((x*w1-b1)*w3)+((x*w2-b1)*w4)-b2)*w7)+((((x*w1-b1)*w5)+((x*w2-b1)*w6)-b2)*w8)-b3);
run;

proc optmodel;
	var w1 ,w2 ,w3 ,w4 ,w5 ,w6 ,w7 ,w8 ,b1 ,b2 ,b3;
	number x ,y;
	read data equation into x y;
	min sq_diff=(y-(((((x*w1-b1)*w3)+((x*w2-b1)*w4)-b2)*w7)+((((x*w1-b1)*w5)+((x*w2-b1)*w6)-b2)*w8)-b3))**2;
	con y = abs(((((x*w1-b1)*w3)+((x*w2-b1)*w4)-b2)*w7)+((((x*w1-b1)*w5)+((x*w2-b1)*w6)-b2)*w8)-b3);
	solve;
	print w1 w2 w3 w4 w5 w6 w7 w8 b1 b2 b3;
	expand / iis;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 14:26:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Cannot-Get-the-Co-efficients-to-match-up-Optimizing-the-error/m-p/674347#M3192</guid>
      <dc:creator>david27</dc:creator>
      <dc:date>2020-08-04T14:26:25Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Get the Co-efficients to match up - Optimizing the error</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Cannot-Get-the-Co-efficients-to-match-up-Optimizing-the-error/m-p/674405#M3193</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1636"&gt;@RobPratt&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I &lt;U&gt;&lt;STRONG&gt;think&lt;/STRONG&gt;&lt;/U&gt;, it is just reading the first observation of the dataset and solving the first row only.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I see in the log---&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;NOTE: There were 1 observations read from the data set WORK.EQUATION.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;This is not intended.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want optmodel to read in the entire dataset and then come up with the parameters.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 15:47:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Cannot-Get-the-Co-efficients-to-match-up-Optimizing-the-error/m-p/674405#M3193</guid>
      <dc:creator>david27</dc:creator>
      <dc:date>2020-08-04T15:47:18Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Get the Co-efficients to match up - Optimizing the error</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Cannot-Get-the-Co-efficients-to-match-up-Optimizing-the-error/m-p/674412#M3194</link>
      <description>&lt;P&gt;As indicated in the log, you were reading only one observation:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;NOTE: There were 1 observations read from the data set WORK.EQUATION.
&lt;/PRE&gt;
&lt;P&gt;If you add a PRINT statement after the READ DATA, you can see that only the first observation was read:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;print x y;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&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;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r b header" scope="col"&gt;x&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;y&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;14&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead, you need an index set for the observations:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set OBS;
number x {OBS}, y {OBS};
read data equation into OBS=[_N_] x y;
print x y;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&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="r b header" scope="col"&gt;x&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;y&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;1&lt;/TH&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;14&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;2&lt;/TH&gt;
&lt;TD class="r data"&gt;94&lt;/TD&gt;
&lt;TD class="r data"&gt;851&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;3&lt;/TH&gt;
&lt;TD class="r data"&gt;52&lt;/TD&gt;
&lt;TD class="r data"&gt;473&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;4&lt;/TH&gt;
&lt;TD class="r data"&gt;70&lt;/TD&gt;
&lt;TD class="r data"&gt;635&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;5&lt;/TH&gt;
&lt;TD class="r data"&gt;57&lt;/TD&gt;
&lt;TD class="r data"&gt;518&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;6&lt;/TH&gt;
&lt;TD class="r data"&gt;28&lt;/TD&gt;
&lt;TD class="r data"&gt;257&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;7&lt;/TH&gt;
&lt;TD class="r data"&gt;42&lt;/TD&gt;
&lt;TD class="r data"&gt;383&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;8&lt;/TH&gt;
&lt;TD class="r data"&gt;47&lt;/TD&gt;
&lt;TD class="r data"&gt;428&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;9&lt;/TH&gt;
&lt;TD class="r data"&gt;39&lt;/TD&gt;
&lt;TD class="r data"&gt;356&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;10&lt;/TH&gt;
&lt;TD class="r data"&gt;7&lt;/TD&gt;
&lt;TD class="r data"&gt;68&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;11&lt;/TH&gt;
&lt;TD class="r data"&gt;28&lt;/TD&gt;
&lt;TD class="r data"&gt;257&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;12&lt;/TH&gt;
&lt;TD class="r data"&gt;27&lt;/TD&gt;
&lt;TD class="r data"&gt;248&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;13&lt;/TH&gt;
&lt;TD class="r data"&gt;21&lt;/TD&gt;
&lt;TD class="r data"&gt;194&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;14&lt;/TH&gt;
&lt;TD class="r data"&gt;9&lt;/TD&gt;
&lt;TD class="r data"&gt;86&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;15&lt;/TH&gt;
&lt;TD class="r data"&gt;84&lt;/TD&gt;
&lt;TD class="r data"&gt;761&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;16&lt;/TH&gt;
&lt;TD class="r data"&gt;31&lt;/TD&gt;
&lt;TD class="r data"&gt;284&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;17&lt;/TH&gt;
&lt;TD class="r data"&gt;72&lt;/TD&gt;
&lt;TD class="r data"&gt;653&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;18&lt;/TH&gt;
&lt;TD class="r data"&gt;39&lt;/TD&gt;
&lt;TD class="r data"&gt;356&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;19&lt;/TH&gt;
&lt;TD class="r data"&gt;35&lt;/TD&gt;
&lt;TD class="r data"&gt;320&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similarly, the objective function needs to sum over the observations:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;min sq_diff = sum{i in OBS}(y[i]-(((((x[i]*w[1]-b[1])*w[3])+((x[i]*w[2]-b[1])*w[4])-b[2])*w[7])+((((x[i]*w[1]-b[1])*w[5])+((x[i]*w[2]-b[1])*w[6])-b[2])*w[8])-b[3]))**2;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;From your solution, it looks like you wanted w and b to be &amp;gt;= 0.&amp;nbsp; Here's a compact way to declare that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;var w {1..8} &amp;gt;= 0, b {1..3} &amp;gt;= 0;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;By default, decision variables have infinite lower and upper bounds.&amp;nbsp; If you do not specify &amp;gt;= 0, it turns out the solver actually finds an optimal objective value of 0 for this problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not sure what you intended with EXPAND / IIS because you are not using the IIS solver option.&amp;nbsp; But EXPAND by itself will show you the full problem as a sanity check.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problem appears to be nonconvex, so I recommend using the MULTISTART (or MS) option to try to avoid getting stuck in a local minimum.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Putting it all together:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc optmodel;
   var w {1..8} &amp;gt;= 0, b {1..3} &amp;gt;= 0;
   set OBS;
   number x {OBS}, y {OBS};
   read data equation into OBS=[_N_] x y;
   print x y;
   min sq_diff = sum{i in OBS}(y[i]-(((((x[i]*w[1]-b[1])*w[3])+((x[i]*w[2]-b[1])*w[4])-b[2])*w[7])+((((x[i]*w[1]-b[1])*w[5])+((x[i]*w[2]-b[1])*w[6])-b[2])*w[8])-b[3]))**2;
   expand;
   solve with nlp / ms;
   print w b;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;TABLE class="systitleandfootercontainer" border="0" summary="Page Layout" width="100%" frame="void" rules="none" cellspacing="1" cellpadding="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="c systemtitle"&gt;The SAS System&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;BR /&gt;
&lt;DIV class="c proctitle"&gt;The OPTMODEL Procedure&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Optmodel: Problem Summary" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c b header" colspan="2" scope="colgroup"&gt;Problem Summary&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Objective Sense&lt;/TH&gt;
&lt;TD class="r data"&gt;Minimization&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Objective Function&lt;/TH&gt;
&lt;TD class="r data"&gt;sq_diff&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Objective Type&lt;/TH&gt;
&lt;TD class="r data"&gt;Nonlinear&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TD class="r data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Number of Variables&lt;/TH&gt;
&lt;TD class="r data"&gt;11&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Bounded Above&lt;/TH&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;Bounded Below&lt;/TH&gt;
&lt;TD class="r data"&gt;11&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Bounded Below and Above&lt;/TH&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;Free&lt;/TH&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;Fixed&lt;/TH&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;&amp;nbsp;&lt;/TH&gt;
&lt;TD class="r data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Number of Constraints&lt;/TH&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;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR size="3" /&gt;
&lt;P&gt;&lt;A name="IDX78" target="_blank"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;TABLE class="systitleandfootercontainer" border="0" summary="Page Layout" width="100%" frame="void" rules="none" cellspacing="1" cellpadding="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="c systemtitle"&gt;The SAS System&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="c proctitle"&gt;The OPTMODEL Procedure&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Optmodel: Solution Summary" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="c b header" colspan="2" scope="colgroup"&gt;Solution Summary&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Solver&lt;/TH&gt;
&lt;TD class="r data"&gt;Multistart NLP&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Algorithm&lt;/TH&gt;
&lt;TD class="r data"&gt;Interior Point Direct&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Objective Function&lt;/TH&gt;
&lt;TD class="r data"&gt;sq_diff&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Solution Status&lt;/TH&gt;
&lt;TD class="r data"&gt;Optimal&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Objective Value&lt;/TH&gt;
&lt;TD class="r data"&gt;126.64605979&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;&amp;nbsp;&lt;/TH&gt;
&lt;TD class="r data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Number of Starts&lt;/TH&gt;
&lt;TD class="r data"&gt;100&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Number of Sample Points&lt;/TH&gt;
&lt;TD class="r data"&gt;1600&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Number of Distinct Optima&lt;/TH&gt;
&lt;TD class="r data"&gt;30&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Random Seed Used&lt;/TH&gt;
&lt;TD class="r data"&gt;1679670&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Optimality Error&lt;/TH&gt;
&lt;TD class="r data"&gt;3.1111693E-8&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Infeasibility&lt;/TH&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;&amp;nbsp;&lt;/TH&gt;
&lt;TD class="r data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Presolve Time&lt;/TH&gt;
&lt;TD class="r data"&gt;0.00&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;Solution Time&lt;/TH&gt;
&lt;TD class="r data"&gt;0.55&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;BR /&gt;&lt;A name="IDX79" target="_blank"&gt;&lt;/A&gt;&lt;/P&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="r b header" scope="col"&gt;w&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;b&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;1&lt;/TH&gt;
&lt;TD class="r data"&gt;43.23150674&lt;/TD&gt;
&lt;TD class="r data"&gt;-.0000000021&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;2&lt;/TH&gt;
&lt;TD class="r data"&gt;34.96859624&lt;/TD&gt;
&lt;TD class="r data"&gt;0.0000017686&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;3&lt;/TH&gt;
&lt;TD class="r data"&gt;102.26490433&lt;/TD&gt;
&lt;TD class="r data"&gt;-.0000000082&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;4&lt;/TH&gt;
&lt;TD class="r data"&gt;80.22402775&lt;/TD&gt;
&lt;TD class="r data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;5&lt;/TH&gt;
&lt;TD class="r data"&gt;180.63897324&lt;/TD&gt;
&lt;TD class="r data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;6&lt;/TH&gt;
&lt;TD class="r data"&gt;97.11066371&lt;/TD&gt;
&lt;TD class="r data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;7&lt;/TH&gt;
&lt;TD class="r data"&gt;0.00055746&lt;/TD&gt;
&lt;TD class="r data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;8&lt;/TH&gt;
&lt;TD class="r data"&gt;0.00045163&lt;/TD&gt;
&lt;TD class="r data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-align-left"&gt;&lt;SPAN style="font-family: inherit;"&gt;The resulting solution is different than what you expected, but the optimal objective value matches, so this looks like a case of multiple optimal solutions.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 04 Aug 2020 15:58:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Cannot-Get-the-Co-efficients-to-match-up-Optimizing-the-error/m-p/674412#M3194</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2020-08-04T15:58:04Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Get the Co-efficients to match up - Optimizing the error</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Cannot-Get-the-Co-efficients-to-match-up-Optimizing-the-error/m-p/674505#M3195</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1636"&gt;@RobPratt&lt;/a&gt;&amp;nbsp;:: You THE Boss.&lt;/P&gt;&lt;P&gt;Thank You very much for that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I read this link numerous times but was not able to comprehend the part that you showed.&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.sas.com/documentation/onlinedoc/or/132/optmodel.pdf" target="_blank"&gt;https://support.sas.com/documentation/onlinedoc/or/132/optmodel.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What you showed here in the example-- where is that in this documentation of OPTMODEL?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 18:54:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Cannot-Get-the-Co-efficients-to-match-up-Optimizing-the-error/m-p/674505#M3195</guid>
      <dc:creator>david27</dc:creator>
      <dc:date>2020-08-04T18:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Get the Co-efficients to match up - Optimizing the error</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Cannot-Get-the-Co-efficients-to-match-up-Optimizing-the-error/m-p/674531#M3196</link>
      <description>&lt;P&gt;Glad to help.&amp;nbsp; Which part do you mean?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 19:32:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Cannot-Get-the-Co-efficients-to-match-up-Optimizing-the-error/m-p/674531#M3196</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2020-08-04T19:32:09Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Get the Co-efficients to match up - Optimizing the error</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Cannot-Get-the-Co-efficients-to-match-up-Optimizing-the-error/m-p/674543#M3197</link>
      <description>&lt;P&gt;Reading the entire dataset and then go to SOLVE part.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 20:01:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Cannot-Get-the-Co-efficients-to-match-up-Optimizing-the-error/m-p/674543#M3197</guid>
      <dc:creator>david27</dc:creator>
      <dc:date>2020-08-04T20:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Get the Co-efficients to match up - Optimizing the error</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Cannot-Get-the-Co-efficients-to-match-up-Optimizing-the-error/m-p/674609#M3198</link>
      <description>&lt;P&gt;The READ DATA statement is documented &lt;A href="https://go.documentation.sas.com/?docsetId=ormpug&amp;amp;docsetTarget=ormpug_optmodel_syntax11.htm&amp;amp;docsetVersion=15.1&amp;amp;locale=en#ormpug.optmodel.npxreadstmt" target="_self"&gt;here&lt;/A&gt;&amp;nbsp;and is also illustrated in most of the &lt;A href="https://go.documentation.sas.com/?docsetId=ormpug&amp;amp;docsetTarget=ormpug_optmodel_examples.htm&amp;amp;docsetVersion=15.1&amp;amp;locale=en" target="_self"&gt;end-of-chapter examples&lt;/A&gt;.&amp;nbsp; You might also be interested in &lt;A href="https://go.documentation.sas.com/?docsetId=ormpex&amp;amp;docsetTarget=titlepage.htm&amp;amp;docsetVersion=15.1&amp;amp;locale=en" target="_self"&gt;this book of 29 examples&lt;/A&gt;, almost all of which use the READ DATA statement.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 22:33:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Cannot-Get-the-Co-efficients-to-match-up-Optimizing-the-error/m-p/674609#M3198</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2020-08-04T22:33:48Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Get the Co-efficients to match up - Optimizing the error</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Cannot-Get-the-Co-efficients-to-match-up-Optimizing-the-error/m-p/676822#M3200</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1636"&gt;@RobPratt&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the above example i did put a constraint:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;con y = abs(((((x*w1-b1)*w3)+((x*w2-b1)*w4)-b2)*w7)+((((x*w1-b1)*w5)+((x*w2-b1)*w6)-b2)*w8)-b3);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is the way I put the constraint correct or it also has to be array?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;con y[i]=(((((x[i]*w[1]-b[1])*w[3])+((x[i]*w[2]-b[1])*w[4])-b[2])*w[7])+((((x[i]*w[1]-b[1])*w[5])+((x[i]*w[2]-b[1])*w[6])-b[2])*w[8])-b[3]);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will have to add a constraint here where y for each observation is equal to value coming out of formula.&lt;/P&gt;&lt;P&gt;Because, if i don't do that, then Solver calculates a mean value that satisfies the solver condition and as a result the value is same for all rows.&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Aug 2020 18:05:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Cannot-Get-the-Co-efficients-to-match-up-Optimizing-the-error/m-p/676822#M3200</guid>
      <dc:creator>david27</dc:creator>
      <dc:date>2020-08-14T18:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Get the Co-efficients to match up - Optimizing the error</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Cannot-Get-the-Co-efficients-to-match-up-Optimizing-the-error/m-p/676831#M3201</link>
      <description>&lt;P&gt;Correct syntax is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;con c {i in OBS}: y[i] = ((((x[i]*w[1]-b[1])*w[3])+((x[i]*w[2]-b[1])*w[4])-b[2])*w[7])+((((x[i]*w[1]-b[1])*w[5])+((x[i]*w[2]-b[1])*w[6])-b[2])*w[8])-b[3];
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But a best practice is to use an implicit variable if the same long expression appears more than once:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;impvar yhat {i in OBS} = ((((x[i]*w[1]-b[1])*w[3])+((x[i]*w[2]-b[1])*w[4])-b[2])*w[7])+((((x[i]*w[1]-b[1])*w[5])+((x[i]*w[2]-b[1])*w[6])-b[2])*w[8])-b[3];
min sq_diff = sum{i in OBS}(y[i]-yhat[i])**2;
con c {i in OBS}: y[i] = yhat[i];
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Aug 2020 18:45:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Cannot-Get-the-Co-efficients-to-match-up-Optimizing-the-error/m-p/676831#M3201</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2020-08-14T18:45:53Z</dc:date>
    </item>
  </channel>
</rss>

