<?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: what's wrong with this code in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/what-s-wrong-with-this-code/m-p/474317#M2292</link>
    <description>&lt;P&gt;Hi Rob,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much for you response. I did not get all values of 1.01 for T, but most of them are, which is still problematic. Did you get different values for each observations or the variation is not that much? I think my SAS version is 9.3..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not expect the solutions are always with zero error.&lt;/P&gt;&lt;P&gt;I only need to bound T greater than one, nothing else.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been running the code PROC OPTMODEL that you wrote for hours and it is still running. Is that what also happens to you?&lt;/P&gt;</description>
    <pubDate>Fri, 29 Jun 2018 01:10:22 GMT</pubDate>
    <dc:creator>OceanDream</dc:creator>
    <dc:date>2018-06-29T01:10:22Z</dc:date>
    <item>
      <title>what's wrong with this code</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/what-s-wrong-with-this-code/m-p/472865#M2282</link>
      <description>&lt;P&gt;I am using the following code to solve two unknown variables (T and delta) with two equations. If I do not use "bounds t&amp;gt;1" AND "optimize" option, it gives me value of T close to zero to all the observations. However, if I add these two codes, the results for all observations are 1.01 for T. I checked proc model code with simple quadratic equation to get only negative results. It worked fine. Anyone could please help me? What is wrong with my current code for this more complex equations??? I am in urgent need to solve this. Please help!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Additional information: I got the following information when running the code. It seems that the code did not even iterate once to solve the equations and gave error of zero?? That does not seem right.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: Optimal.&lt;BR /&gt;NOTE: Objective = 0.4636390687.&lt;BR /&gt;NOTE: The NLP solver is called.&lt;BR /&gt;NOTE: The Interior Point algorithm is used.&lt;BR /&gt;Objective Optimality&lt;BR /&gt;Iter&amp;nbsp; &amp;nbsp; Value&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Infeasibility&amp;nbsp; &amp;nbsp; &amp;nbsp; Error&lt;BR /&gt;0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0.49897143&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; 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"proc model data=HAVE noprint out=NEED;&lt;BR /&gt;bounds t&amp;gt;1;&lt;BR /&gt;eq.one = (1-PD) - (probnorm((-log(PD)-(s - 0.5*(delta*delta))*T)/(delta*sqrt(T)))&lt;BR /&gt;-PD*exp(s*T)* probnorm((-log(PD)-(s - 0.5*(delta*delta))*T)/(delta*sqrt(T))- delta*sqrt(T)));&lt;BR /&gt;eq.two = delta_E*(1-PD) - delta*probnorm((-log(PD)-(s - 0.5*(delta*delta))*T)/(delta*sqrt(T)));&lt;BR /&gt;solve delta T /optimize solveprint ;&lt;BR /&gt;id companyid&amp;nbsp;date pd s delta_e;&lt;BR /&gt;run;"&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jun 2018 04:29:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/what-s-wrong-with-this-code/m-p/472865#M2282</guid>
      <dc:creator>OceanDream</dc:creator>
      <dc:date>2018-06-25T04:29:40Z</dc:date>
    </item>
    <item>
      <title>Re: what's wrong with this code</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/what-s-wrong-with-this-code/m-p/473020#M2283</link>
      <description>&lt;P&gt;PROC MODEL is part of SAS/ETS, and I see that you have already posted in the SAS Forecasting and Econometrics community.&amp;nbsp; You could also use PROC OPTMODEL to solve your equations.&amp;nbsp; Can you please share your data?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jun 2018 14:41:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/what-s-wrong-with-this-code/m-p/473020#M2283</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2018-06-25T14:41:07Z</dc:date>
    </item>
    <item>
      <title>Re: what's wrong with this code</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/what-s-wrong-with-this-code/m-p/473031#M2284</link>
      <description>&lt;P&gt;Hi Rob,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your reply. Attached is my data. I could not attach my file to the reply. It says " the contents of the attachment doesn't match its file type". Do you know what is wrong? If you don't mind, I can email you my data. Thank you so much for your help!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"proc model data=bl.decomp5 noprint out=decomp6;&lt;BR /&gt;endo delta T;&lt;BR /&gt;bounds T&amp;gt;0.1;&lt;BR /&gt;eq.one = (1-PD) - (probnorm((-log(PD)-(s - 0.5*(delta*delta))*T)/(delta*sqrt(T)))&lt;BR /&gt;-PD*exp(s*T)* probnorm((-log(PD)-(s - 0.5*(delta*delta))*T)/(delta*sqrt(T))- delta*sqrt(T)));&lt;BR /&gt;eq.two = delta_E*(1-PD) - delta*probnorm((-log(PD)-(s - 0.5*(delta*delta))*T)/(delta*sqrt(T)));&lt;BR /&gt;solve delta T /optimize solveprint ;&lt;BR /&gt;id gvkey dealactivedate facilityid pd s delta_e beta;&lt;BR /&gt;run;"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jun 2018 15:03:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/what-s-wrong-with-this-code/m-p/473031#M2284</guid>
      <dc:creator>OceanDream</dc:creator>
      <dc:date>2018-06-25T15:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: what's wrong with this code</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/what-s-wrong-with-this-code/m-p/473137#M2285</link>
      <description>&lt;P&gt;Please try to attach a CSV or ZIP file instead.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jun 2018 19:34:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/what-s-wrong-with-this-code/m-p/473137#M2285</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2018-06-25T19:34:25Z</dc:date>
    </item>
    <item>
      <title>Re: what's wrong with this code</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/what-s-wrong-with-this-code/m-p/473213#M2286</link>
      <description>&lt;P&gt;Hi Rob,&lt;/P&gt;&lt;P&gt;Please see attached dataset. Thanks again for your help!&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jun 2018 01:13:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/what-s-wrong-with-this-code/m-p/473213#M2286</guid>
      <dc:creator>OceanDream</dc:creator>
      <dc:date>2018-06-26T01:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: what's wrong with this code</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/what-s-wrong-with-this-code/m-p/473894#M2288</link>
      <description>&lt;P&gt;Is beta supposed to be used anywhere?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 19:40:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/what-s-wrong-with-this-code/m-p/473894#M2288</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2018-06-27T19:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: what's wrong with this code</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/what-s-wrong-with-this-code/m-p/473947#M2290</link>
      <description>&lt;P&gt;Thanks for checking it, Rob!&lt;/P&gt;&lt;P&gt;No. For my question, beta is not needed.&lt;/P&gt;&lt;P&gt;Did you find anything wrong with my data or the code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2018 01:09:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/what-s-wrong-with-this-code/m-p/473947#M2290</guid>
      <dc:creator>OceanDream</dc:creator>
      <dc:date>2018-06-28T01:09:40Z</dc:date>
    </item>
    <item>
      <title>Re: what's wrong with this code</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/what-s-wrong-with-this-code/m-p/474106#M2291</link>
      <description>&lt;P&gt;I don't see the same behavior in the latest release (SAS 9.4M5).&amp;nbsp; I get various values for T, not all 1.01.&amp;nbsp; What version are you running?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I add the OUTOBJVALS option, I see that the sum of squared errors is positive, meaning that the equations are not satisfied exactly.&amp;nbsp; Do you know that there is always a solution with zero error?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you know other bounds on delta and T besides T &amp;gt; 0.1 (or did you want T &amp;gt; 1)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might also want to specify a good initial solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a way to minimize the sum of squared errors for the same equations with PROC OPTMODEL in SAS/OR:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc optmodel printlevel=0;
   set OBS;
   str gvkey {OBS};
   num dealactivedate {OBS}, facilityid {OBS}, pd {OBS}, s {OBS}, delta_e {OBS}, beta {OBS};   
   read data decomp5 into OBS=[_N_] gvkey dealactivedate facilityid pd s delta_e beta;   

   num pd_this, s_this, delta_e_this;
   var delta init 1;
   var T &amp;gt;= 0.1 &amp;lt;= 9 init 1;
   var error {1..2};
   min sse = sum {i in 1..2} error[i]^2;
   con eqone: error[1] = (1-pd_this) - (probnorm((-log(pd_this)-(s_this - 0.5*(delta*delta))*T)/(delta*sqrt(T)))
      -pd_this*exp(s_this*T)* probnorm((-log(pd_this)-(s_this - 0.5*(delta*delta))*T)/(delta*sqrt(T))- delta*sqrt(T)));
   con eqtwo: error[2] = delta_e_this*(1-pd_this) - delta*probnorm((-log(pd_this)-(s_this - 0.5*(delta*delta))*T)/(delta*sqrt(T)));

   num delta_sol {OBS}, T_sol {OBS}, obj {OBS};
   option nonotes;
   cofor {i in OBS} do;
      put i=;
      pd_this = pd[i];
      s_this = s[i];
      delta_e_this = delta_e[i];
      solve with nlp / ms;
      delta_sol[i] = delta.sol;
      T_sol[i] = T.sol;
      obj[i] = _OBJ_.sol;
   end;
   option notes;
   create data optmodel_out from [i] gvkey dealactivedate facilityid pd s delta_e beta delta=delta_sol T=T_sol obj;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The upper bound of 9 on T is to prevent overflow in the exponential function.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2018 15:04:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/what-s-wrong-with-this-code/m-p/474106#M2291</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2018-06-28T15:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: what's wrong with this code</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/what-s-wrong-with-this-code/m-p/474317#M2292</link>
      <description>&lt;P&gt;Hi Rob,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much for you response. I did not get all values of 1.01 for T, but most of them are, which is still problematic. Did you get different values for each observations or the variation is not that much? I think my SAS version is 9.3..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not expect the solutions are always with zero error.&lt;/P&gt;&lt;P&gt;I only need to bound T greater than one, nothing else.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been running the code PROC OPTMODEL that you wrote for hours and it is still running. Is that what also happens to you?&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jun 2018 01:10:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/what-s-wrong-with-this-code/m-p/474317#M2292</guid>
      <dc:creator>OceanDream</dc:creator>
      <dc:date>2018-06-29T01:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: what's wrong with this code</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/what-s-wrong-with-this-code/m-p/474439#M2295</link>
      <description>&lt;P&gt;I got a wide variety of T values, but none of them had zero error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I ran on a busy 100-node grid, and it took 12 minutes.&amp;nbsp; You can speed things up but might find worse solutions by omitting the multistart option.&amp;nbsp; That is, replace...&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;solve with nlp / ms;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;...with...&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;solve;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But I would also recommend upgrading.&amp;nbsp; The last SAS 9.3 release came out in 2012, and the subsequent releases all contain performance improvements.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jun 2018 14:04:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/what-s-wrong-with-this-code/m-p/474439#M2295</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2018-06-29T14:04:57Z</dc:date>
    </item>
    <item>
      <title>Re: what's wrong with this code</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/what-s-wrong-with-this-code/m-p/474496#M2296</link>
      <description>&lt;P&gt;My school only provides 9.3 version of SAS.&lt;/P&gt;&lt;P&gt;If it is not too much to ask, could you share me with the results from running PROC MODEL using your 9.4 version?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I replaced&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token function"&gt;solve&lt;/SPAN&gt; with &lt;SPAN class="token procnames"&gt;nlp&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt; ms&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;with&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token function"&gt;solve&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;using PROC OPTMODEL, but the values for T&amp;nbsp; seem reasonable, but most values for delta are one, which is not reasonable...&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jun 2018 16:45:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/what-s-wrong-with-this-code/m-p/474496#M2296</guid>
      <dc:creator>OceanDream</dc:creator>
      <dc:date>2018-06-29T16:45:26Z</dc:date>
    </item>
  </channel>
</rss>

