<?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 Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/Conditional-Constarint-in-proc-optmodel/m-p/503259#M2437</link>
    <description>&lt;P&gt;If I understand correctly, you should include the following two additional statements:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   con YSum: Y['N16'] = Y['N17'] + Y['N18'];
   for {r in /N17 N18/} Y[r].lb = 1e-3;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first statement declares your new constraint, and the second statement changes the lower bounds on Y['N17'] and Y['N18'] from 0 to 1e-3.&amp;nbsp; Here, 1e-3 is just an example.&amp;nbsp; You have to decide for yourself how large Y[r] must be for you to consider it to be positive.&lt;/P&gt;</description>
    <pubDate>Wed, 10 Oct 2018 21:56:18 GMT</pubDate>
    <dc:creator>RobPratt</dc:creator>
    <dc:date>2018-10-10T21:56:18Z</dc:date>
    <item>
      <title>Conditional Constarint in proc optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Conditional-Constarint-in-proc-optmodel/m-p/503061#M2436</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;SPAN&gt;&amp;nbsp;&lt;/SPAN&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;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Thank you in advance for your response&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1636"&gt;@RobPratt&lt;/a&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 13:00:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Conditional-Constarint-in-proc-optmodel/m-p/503061#M2436</guid>
      <dc:creator>Vane08</dc:creator>
      <dc:date>2018-10-10T13:00:07Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Constarint in proc optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Conditional-Constarint-in-proc-optmodel/m-p/503259#M2437</link>
      <description>&lt;P&gt;If I understand correctly, you should include the following two additional statements:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   con YSum: Y['N16'] = Y['N17'] + Y['N18'];
   for {r in /N17 N18/} Y[r].lb = 1e-3;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first statement declares your new constraint, and the second statement changes the lower bounds on Y['N17'] and Y['N18'] from 0 to 1e-3.&amp;nbsp; Here, 1e-3 is just an example.&amp;nbsp; You have to decide for yourself how large Y[r] must be for you to consider it to be positive.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 21:56:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Conditional-Constarint-in-proc-optmodel/m-p/503259#M2437</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2018-10-10T21:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Constarint in proc optmodel</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Conditional-Constarint-in-proc-optmodel/m-p/504214#M2444</link>
      <description>&lt;P&gt;Thank you for your response ! It gives me the syntax for a condition but I think that I need changing something in my resolution programm.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 06:43:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Conditional-Constarint-in-proc-optmodel/m-p/504214#M2444</guid>
      <dc:creator>Vane08</dc:creator>
      <dc:date>2018-10-15T06:43:47Z</dc:date>
    </item>
  </channel>
</rss>

