<?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: Conditional Constarint in proc optmodel in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Conditional-Constarint-in-proc-optmodel/m-p/504133#M72758</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/239469"&gt;@Vane08&lt;/a&gt;:&amp;nbsp; Just for good housekeeping purposes, mark this topic as solved.&amp;nbsp; I see you've already posted this question in the OR forum, so enter a response on this topic with a link to its twin, and then mark your response as solved.&lt;/P&gt;</description>
    <pubDate>Sun, 14 Oct 2018 21:33:59 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2018-10-14T21:33:59Z</dc:date>
    <item>
      <title>Conditional Constarint in proc optmodel</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Conditional-Constarint-in-proc-optmodel/m-p/503015#M72723</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* II-  PROGRAME OPTMODEL 															*/ 
	/***********************************************************************************/
					proc optmodel; 
						
						/* 0 Tableau des chemins &amp;amp; Marges								*/ 
						/************************************************************/
								/* declaration de paramètre 	*/
						
						Set &amp;lt;string&amp;gt; Vecteur_&amp;amp;Typej._&amp;amp;Heure._&amp;amp;Annee.; 
						Set &amp;lt;string&amp;gt; Marge_&amp;amp;Typej._&amp;amp;Heure._&amp;amp;Annee.; 
						num Tij{Vecteur_&amp;amp;Typej._&amp;amp;Heure._&amp;amp;Annee.};

					    num marges{Marge_&amp;amp;Typej._&amp;amp;Heure._&amp;amp;Annee.};
						num STDMarges{Marge_&amp;amp;Typej._&amp;amp;Heure._&amp;amp;Annee.};
						num Nobs{Marge_&amp;amp;Typej._&amp;amp;Heure._&amp;amp;Annee.};
						num chemin{Vecteur_&amp;amp;Typej._&amp;amp;Heure._&amp;amp;Annee., Marge_&amp;amp;Typej._&amp;amp;Heure._&amp;amp;Annee.};
								
						/* Reading data 													*/ 
						/******************************************************************/

					 	read data Vecteur_&amp;amp;Typej._&amp;amp;Heure._&amp;amp;Annee. into 
							Vecteur_&amp;amp;Typej._&amp;amp;Heure._&amp;amp;Annee. = [Vecteur] Tij; 
						print Tij;

					    read data Marge_&amp;amp;Typej._&amp;amp;Heure._&amp;amp;Annee. into 
							Marge_&amp;amp;Typej._&amp;amp;Heure._&amp;amp;Annee. = [N] 
							marges = marges
							STDMarges = STDMarges
							NObs = Nobs 
							{p in Vecteur_&amp;amp;Typej._&amp;amp;Heure._&amp;amp;Annee.} &amp;lt;chemin[p,N]= col(p)&amp;gt;;
						print  marges STDMarges Nobs chemin;
							

						/* III Resolution  												*/ 
						/*********************************************************************/
							/* V-1) Déclaration de variables */ 
							
							var  X{Vecteur_&amp;amp;Typej._&amp;amp;Heure._&amp;amp;Annee.} &amp;gt;= 0;
							Var  Y{Marge_&amp;amp;Typej._&amp;amp;Heure._&amp;amp;Annee.} &amp;gt;= 0 ; 
							

							/* V-2) La fonction objective : minimisation de la variance */ 

							minimize f = sum{p in Vecteur_&amp;amp;Typej._&amp;amp;Heure._&amp;amp;Annee.} (X[p]-Tij[p])**2/(Tij[p]/3)**2 + sum{r in Marge_&amp;amp;Typej._&amp;amp;Heure._&amp;amp;Annee.} ((Y[r]- Marges[r])**2/(STDMarges[r]**2/Nobs[r]));



							/* V-3) subject to the following constraints */

							Con Bornes{r in Marge_&amp;amp;Typej._&amp;amp;Heure._&amp;amp;Annee.}: sum{p in Vecteur_&amp;amp;Typej._&amp;amp;Heure._&amp;amp;Annee.} chemin[p, r]*X[p] = Y[r];

/* Con Condtion1{r in Marge_&amp;amp;Typej._&amp;amp;Heure._&amp;amp;Annee. :}: If r = 17 then sum{p in Vecteur_&amp;amp;Typej._&amp;amp;Heure._&amp;amp;Annee.} chemin[p, r]*X[p] &amp;gt; 0;
Con Condtion1{r in Marge_&amp;amp;Typej._&amp;amp;Heure._&amp;amp;Annee. :}: If r = 16 then sum{p in Vecteur_&amp;amp;Typej._&amp;amp;Heure._&amp;amp;Annee.} chemin[p, r]*X[p] &amp;gt; 0;*/
							
						
							
						 solve ;
						print X;
						Print Y;
						
						
						create data Vecteur_est_&amp;amp;Typej._&amp;amp;Heure._&amp;amp;Annee. from [p] Tij&amp;amp;Annee. = X ;
						create data Marge_est_&amp;amp;Typej._&amp;amp;Heure._&amp;amp;Annee. from [r]  Marges&amp;amp;Annee. = Y ;
						&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Good morning,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to make conditions in my constraint because in the solutions of X and Y, I need some sum in the line of&amp;nbsp;Y like :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1) In the first solution Y: (Marge_est_&amp;amp;Typel.&amp;amp;Heure._&amp;amp;Annee.&lt;/STRONG&gt; )&lt;STRONG&gt;&amp;nbsp;with Y[r]&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;==&amp;gt; I need that&amp;nbsp; Y[16] = Y[17] +Y[18&lt;/STRONG&gt;]&amp;nbsp; &amp;nbsp;with Y[17]#0 and Y[18] #0&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(there is some case like those lines but not all the line in the table, it is a transportation problem..)&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;and in the same time&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;2)&lt;STRONG&gt; I have the constraint that the sum in line of&amp;nbsp; X[1...52]*chemin[52, 31]&amp;nbsp;&lt;/STRONG&gt;&amp;nbsp;&lt;STRONG&gt;is equal at the sum of Y[1..31]&amp;nbsp;&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for example : for the first line of Y&amp;nbsp; &amp;nbsp;: [1...52]*chemin[1..52, 1] = Y[1] ; I have no problem to write this second constraint "con" like in the code I sent here in Pj.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;==&amp;gt;The origin of this problem is that in my&amp;nbsp;&amp;nbsp;real data set in the table&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Marge_&amp;amp;Typel.&amp;amp;Heure._&amp;amp;Annee.&amp;nbsp; :&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;the line 17 = 0 , the line 18 = 0 so the QP affect s100% of Y[16] in just one of Y[18] or Y[17]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;==&amp;gt;So I thought that the solutions were&amp;nbsp;:&amp;nbsp;making&amp;nbsp; some condition contraint to estimates line in this case to have in the estimation not Y[16] =&amp;nbsp;&lt;/STRONG&gt;&lt;STRONG&gt;&amp;nbsp;Y[17]&amp;nbsp; +0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; with Y[18] = 0 &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;but Y [16] = Y[17] +Y[16]&amp;nbsp; &amp;nbsp;with Y[18] #0 and Y[17] #0&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 09:36:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Conditional-Constarint-in-proc-optmodel/m-p/503015#M72723</guid>
      <dc:creator>Vane08</dc:creator>
      <dc:date>2018-10-10T09:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Constarint in proc optmodel</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Conditional-Constarint-in-proc-optmodel/m-p/503057#M72725</link>
      <description>&lt;P&gt;You should post it at OR forum. Calling&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1636"&gt;@RobPratt&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 12:50:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Conditional-Constarint-in-proc-optmodel/m-p/503057#M72725</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-10-10T12:50:14Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Constarint in proc optmodel</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Conditional-Constarint-in-proc-optmodel/m-p/503058#M72726</link>
      <description>You're right ! Thank you</description>
      <pubDate>Wed, 10 Oct 2018 12:56:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Conditional-Constarint-in-proc-optmodel/m-p/503058#M72726</guid>
      <dc:creator>Vane08</dc:creator>
      <dc:date>2018-10-10T12:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Constarint in proc optmodel</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Conditional-Constarint-in-proc-optmodel/m-p/504133#M72758</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/239469"&gt;@Vane08&lt;/a&gt;:&amp;nbsp; Just for good housekeeping purposes, mark this topic as solved.&amp;nbsp; I see you've already posted this question in the OR forum, so enter a response on this topic with a link to its twin, and then mark your response as solved.&lt;/P&gt;</description>
      <pubDate>Sun, 14 Oct 2018 21:33:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Conditional-Constarint-in-proc-optmodel/m-p/504133#M72758</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-10-14T21:33:59Z</dc:date>
    </item>
  </channel>
</rss>

