<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<id>tag:old.nabble.com,2006:forum-15731</id>
	<title>Nabble - AMPL</title>
	<updated>2009-11-26T20:00:08Z</updated>
	<link rel="self" type="application/atom+xml" href="http://old.nabble.com/AMPL-f15731.xml" />
	<link rel="alternate" type="text/html" href="http://old.nabble.com/AMPL-f15731.html" />
	<subtitle type="html">A discussion and help group for &lt;a href=&quot;http://www.ampl.com/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;AMPL&lt;/a&gt;, an algebraic modeling language for optimization problems of many kinds. &amp;nbsp;AMPL lets people use common notation and familiar concepts to formulate models and examine solutions, while the computer manages communication with appropriate solvers.</subtitle>
	
<entry>
	<id>tag:old.nabble.com,2006:post-26537710</id>
	<title>[AMPL 3042] Re: a problem</title>
	<published>2009-11-26T20:00:08Z</published>
	<updated>2009-11-26T20:00:08Z</updated>
	<author>
		<name>Nilu</name>
	</author>
	<content type="html">here is the code and when i use option solver knitroampl it just stops
&lt;br&gt;responding .....and with minos ( after having lower bounds) it exits
&lt;br&gt;like the one mentioned above...........any suggestions ???????
&lt;br&gt;&lt;br&gt;&lt;br&gt;param N integer;
&lt;br&gt;&lt;br&gt;set Instruments := {1..N+1};
&lt;br&gt;&lt;br&gt;param B_D;
&lt;br&gt;param B_I;
&lt;br&gt;param sigma;
&lt;br&gt;param D;
&lt;br&gt;set States := {1..2^(N+1)};
&lt;br&gt;param a { 2..N+1};
&lt;br&gt;param k;
&lt;br&gt;param alpha {2..N+1};
&lt;br&gt;param gamma {2..N+1};
&lt;br&gt;param theta_G {Instruments};
&lt;br&gt;param theta_B {Instruments};
&lt;br&gt;param epsilon {Instruments};
&lt;br&gt;param capgamma {2..N+1};
&lt;br&gt;param tau_max ;
&lt;br&gt;param omega;
&lt;br&gt;param theta {Instruments, States};
&lt;br&gt;param si {States};
&lt;br&gt;&lt;br&gt;#### Variables #####
&lt;br&gt;var e {Instruments} &amp;gt;= 0;
&lt;br&gt;var T;
&lt;br&gt;var tau {States};
&lt;br&gt;var L {i in Instruments,j in States} &amp;nbsp; ;
&lt;br&gt;var R {i in Instruments,j in States} &amp;nbsp; ;
&lt;br&gt;var S {i in 2..N+1, j in States} ;
&lt;br&gt;var beta {i in 2..N+1, j in States};
&lt;br&gt;var capdelta {States};
&lt;br&gt;var W {j in States} = (sum {i in 2..N+1} (a[i] * S[i,j]^((k-1)/k)))^k/
&lt;br&gt;(k-1);
&lt;br&gt;###### Objective function####
&lt;br&gt;maximize Objective : sum {j in States} (si[j] * (W[j] + sigma *
&lt;br&gt;capdelta[j])) ;
&lt;br&gt;&lt;br&gt;###### Constraints #####
&lt;br&gt;subject to Constraint_12 {i in 2..N+1, j in States}: &amp;nbsp;S[i,j] - (gamma
&lt;br&gt;[i] * L[i,j]^alpha[i] * R[i,j]^beta[i,j]) &amp;lt;= 0;
&lt;br&gt;subject to Constraint_13 {i in 2..N+1, j in States}: &amp;nbsp;S[i,j] &amp;gt;=
&lt;br&gt;capgamma[i];
&lt;br&gt;subject to Constraint_16 {i in 2..N+1, j in States}: beta[i,j] - (1-
&lt;br&gt;alpha[i])*(1- theta[i,j]/(theta[i,j] + e[i])) = 0 ;
&lt;br&gt;subject to Constraint_17 {j in States}: R[1,j] - tau[j]* L[1,j]^omega
&lt;br&gt;= 0 ;
&lt;br&gt;subject to Constraint_18 {j in States}: tau[j] - tau_max * (1 - theta
&lt;br&gt;[1,j]/(theta[1,j] + e[1])) = 0 ;
&lt;br&gt;subject to Constraint_19 {j in States}: R[1,j] - sum{i in 2..N+1} R
&lt;br&gt;[i,j] &amp;gt;= 0;
&lt;br&gt;subject to Constraint_20 : B_D - T - e[1] - sum{i in 2..N+1} e[i] &amp;gt;=
&lt;br&gt;0;
&lt;br&gt;subject to Constraint_21 {j in States}: B_I + T - L[1,j] - sum{i in
&lt;br&gt;2..N+1} L[i,j] - capdelta[j] &amp;gt;= 0 ;
&lt;br&gt;subject to Constraint_23 : T &amp;gt;= 0;
&lt;br&gt;&lt;br&gt;&lt;br&gt;problem SOLVE: Objective, e, T, tau, L, R, S, beta, capdelta,
&lt;br&gt;Constraint_12, Constraint_13, Constraint_16, Constraint_17,
&lt;br&gt;Constraint_18, Constraint_19, Constraint_20, Constraint_21,
&lt;br&gt;Constraint_23 ;
&lt;br&gt;&lt;br&gt;&lt;br&gt;On Nov 26, 8:42 pm, Nilu &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26537710&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;nilu8...@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; hi i am trying to solve a non linear problem and I have given lower
&lt;br&gt;&amp;gt; bounds to the variables which may cause problems but after all these
&lt;br&gt;&amp;gt; things when i execute the solve command I get this:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Presolve eliminates 1 constraint.
&lt;br&gt;&amp;gt; Substitution eliminates 8 variables.
&lt;br&gt;&amp;gt; Adjusted problem:
&lt;br&gt;&amp;gt; 100 variables:
&lt;br&gt;&amp;gt;         83 nonlinear variables
&lt;br&gt;&amp;gt;         17 linear variables
&lt;br&gt;&amp;gt; 65 constraints; 204 linear nonzeros
&lt;br&gt;&amp;gt;         48 nonlinear constraints
&lt;br&gt;&amp;gt;         17 linear constraints
&lt;br&gt;&amp;gt; 1 nonlinear objective; 24 nonzeros.
&lt;br&gt;&amp;gt; MINOS 5.5: exit code 3221225477
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Can you suggest any reason for the problem ???.......It seems there is
&lt;br&gt;&amp;gt; some problem in calculating the objective.....any ideas ????
&lt;/div&gt;&lt;br&gt;--
&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26537710&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26537710&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=en&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=en&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/-AMPL-3041--a-problem-tp26537328p26537710.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26537328</id>
	<title>[AMPL 3041] a problem</title>
	<published>2009-11-26T18:42:28Z</published>
	<updated>2009-11-26T18:42:28Z</updated>
	<author>
		<name>Nilu</name>
	</author>
	<content type="html">hi i am trying to solve a non linear problem and I have given lower
&lt;br&gt;bounds to the variables which may cause problems but after all these
&lt;br&gt;things when i execute the solve command I get this:
&lt;br&gt;&lt;br&gt;Presolve eliminates 1 constraint.
&lt;br&gt;Substitution eliminates 8 variables.
&lt;br&gt;Adjusted problem:
&lt;br&gt;100 variables:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 83 nonlinear variables
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 17 linear variables
&lt;br&gt;65 constraints; 204 linear nonzeros
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 48 nonlinear constraints
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 17 linear constraints
&lt;br&gt;1 nonlinear objective; 24 nonzeros.
&lt;br&gt;MINOS 5.5: exit code 3221225477
&lt;br&gt;&lt;br&gt;Can you suggest any reason for the problem ???.......It seems there is
&lt;br&gt;some problem in calculating the objective.....any ideas ????
&lt;br&gt;&lt;br&gt;--
&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26537328&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26537328&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=en&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=en&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/-AMPL-3041--a-problem-tp26537328p26537328.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26532715</id>
	<title>[AMPL 3040] String expressions in read table commands</title>
	<published>2009-11-26T09:34:09Z</published>
	<updated>2009-11-26T09:34:09Z</updated>
	<author>
		<name>marie-35</name>
	</author>
	<content type="html">Hello!
&lt;br&gt;&lt;br&gt;I would like to use data from different excel files and solve my
&lt;br&gt;problem for each of them. I use this code (Tt is not defined in
&lt;br&gt;mono.dat):
&lt;br&gt;&lt;br&gt;model mono.mod;
&lt;br&gt;data mono.dat;
&lt;br&gt;set CASES= 1..2;
&lt;br&gt;for {i in CASES}
&lt;br&gt;&amp;nbsp; &amp;nbsp; {reset data Tt;
&lt;br&gt;table flow IN &amp;quot;ODBC&amp;quot; (&amp;quot;flow_sce\scenario&amp;quot; &amp; i &amp; &amp;quot;.xls&amp;quot;): [TIME], Tt;
&lt;br&gt;read table flow;
&lt;br&gt;solve;
&lt;br&gt;display P;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}
&lt;br&gt;&lt;br&gt;This code is not working and I got the following error messages:
&lt;br&gt;&amp;quot;Abandoning compound command to accept declaration of flow.
&lt;br&gt;Rejecting declaration because it uses loop dummy i.&amp;quot;
&lt;br&gt;&lt;br&gt;Could you help me to formulate this right?
&lt;br&gt;&lt;br&gt;Thanks,
&lt;br&gt;Marie
&lt;br&gt;&lt;br&gt;--
&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26532715&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26532715&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=en&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=en&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/-AMPL-3040--String-expressions-in-read-table-commands-tp26532715p26532715.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26522109</id>
	<title>[AMPL 3039] Re: write table command error</title>
	<published>2009-11-25T15:25:38Z</published>
	<updated>2009-11-25T15:25:38Z</updated>
	<author>
		<name>Mangotree</name>
	</author>
	<content type="html">Dear Bob,
&lt;br&gt;&lt;br&gt;Thanks for the explanation!
&lt;br&gt;&lt;br&gt;I did find a workaround. I think it is my fault.
&lt;br&gt;When declare the table, I actually assign a condition.
&lt;br&gt;The structure of my code is:
&lt;br&gt;&lt;br&gt;1. table example OUT: {i in NAME, j in TIME: condition[i,j] = 1} -&amp;gt;
&lt;br&gt;[NAME,TIME], Value;
&lt;br&gt;2. &amp;quot;code to assign values to parameter condition[i,j]&amp;quot;
&lt;br&gt;3. write table example;
&lt;br&gt;&lt;br&gt;When moved table declaration after the code section, the error
&lt;br&gt;disappeared.
&lt;br&gt;The structure of new code is:
&lt;br&gt;1. &amp;quot;code to assign values to parameter condition[i,j]&amp;quot;
&lt;br&gt;2. table example OUT: {i in NAME, j in TIME: condition[i,j] = 1} -&amp;gt;
&lt;br&gt;[NAME,TIME], Value;
&lt;br&gt;3. write table example;
&lt;br&gt;&lt;br&gt;Therefore I believe I should always use the second structure. For the
&lt;br&gt;first one, ampl sometimes does not complain. I don't know why.
&lt;br&gt;&lt;br&gt;Thanks for the help and have a nice holiday!
&lt;br&gt;&lt;br&gt;Feng
&lt;br&gt;&lt;br&gt;&lt;br&gt;On Nov 24, 8:57 am, &amp;quot;Robert Fourer&amp;quot; &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26522109&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;4...@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; This error message suggests that you might have run up against an obscure
&lt;br&gt;&amp;gt; bug of some kind.  Can you provide the files that you used, so that I can
&lt;br&gt;&amp;gt; try to reproduce the problem?  Then we can get it fixed but in the mean time
&lt;br&gt;&amp;gt; there may be a simple workaround.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Bob Fourer
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26522109&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;4...@...&lt;/a&gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; -----Original Message-----
&lt;br&gt;&amp;gt; &amp;gt; From: Mangotree [mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26522109&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;mangotree...@...&lt;/a&gt;]
&lt;br&gt;&amp;gt; &amp;gt; Sent: Monday, November 23, 2009 5:57 PM
&lt;br&gt;&amp;gt; &amp;gt; To: AMPL Modeling Language
&lt;br&gt;&amp;gt; &amp;gt; Subject: [AMPL 3035] write table command error
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; Dear AMPL guru,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;          When using write table command, ampl gave me an error
&lt;br&gt;&amp;gt; &amp;gt; message:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; 'Error executing &amp;quot;write_table&amp;quot; command:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;         1 contexts remain open after compile!'
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; The table is defined as: table example OUT: {i in NAME, j in TIME} -&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; [NAME,TIME], Value;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; where: Value is defined over 2 sets Name &amp; Time.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;          Can someone advise me where the issue is? What is the exact
&lt;br&gt;&amp;gt; &amp;gt; meaning of the error message? Thanks!
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; Feng
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; --
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; You received this message because you are subscribed to the Google Groups
&lt;br&gt;&amp;gt; &amp;gt; &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;&amp;gt; &amp;gt; To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26522109&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;&amp;gt; &amp;gt; To unsubscribe from this group, send email to
&lt;br&gt;&amp;gt; &amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26522109&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;&amp;gt; &amp;gt; For more options, visit this group at
&lt;br&gt;&amp;gt; &amp;gt;&lt;a href=&quot;http://groups.google.com/group/ampl?hl=.-&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=.-&lt;/a&gt;&amp;nbsp;Hide quoted text -
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; - Show quoted text -
&lt;/div&gt;&lt;br&gt;--
&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26522109&amp;i=5&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26522109&amp;i=6&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=en&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=en&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/-AMPL-3035--write-table-command-error-tp26488331p26522109.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26508812</id>
	<title>Re: [AMPL 3038] Re: calculating runlength</title>
	<published>2009-11-25T00:03:23Z</published>
	<updated>2009-11-25T00:03:23Z</updated>
	<author>
		<name>msaqib</name>
	</author>
	<content type="html">&lt;div&gt;To report my sudden unexpected success late last night. Turns out that changing constraint runlength6 to:&lt;/div&gt;
&lt;div&gt;subject to runlength6{i in S24s, j in LOCATIONS, k in COMP_TIMES}: (1-runmap[i, j, k])*(1+LENGTH)+ run[i, j, k] &amp;gt;= PERSISTENCE_THRESHOLD;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;caused the model to become linear. The presolve and the CPLEX solver now accept the problem and find a valid optimal solution.&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Thanks and best regards&lt;br&gt;&lt;br&gt;&lt;/div&gt;
&lt;div class=&quot;gmail_quote&quot;&gt;On Tue, Nov 24, 2009 at 6:03 PM, Saqib Ilyas &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26508812&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;msaqib@...&lt;/a&gt;&amp;gt;&lt;/span&gt; wrote:&lt;br&gt;
&lt;blockquote style=&quot;BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex&quot; class=&quot;gmail_quote&quot;&gt;
&lt;div&gt;I am now able to correctly compute the runlength as I desire. However, the problem now has nonlinear constraints. Do you think I might be able to somehow express the same in a linear fashion? Also, abusufyan, I didn&amp;#39;t get your question.&lt;/div&gt;

&lt;div&gt; &lt;/div&gt;
&lt;div&gt;set LOCATIONS;&lt;br&gt;param Gamma &amp;gt;= 0;&lt;br&gt;param gamma &amp;gt;= 0;&lt;br&gt;param lambda &amp;gt;= 0;&lt;br&gt;param Lambda &amp;gt;= 0;&lt;br&gt;set COMP_TIMES = 1 .. (Gamma*gamma/lambda);&lt;br&gt;set PWR_TIMES = 1 .. (Gamma*gamma);&lt;br&gt;param pwr_price{LOCATIONS, PWR_TIMES} &amp;gt;= 0;&lt;br&gt;
param workload{COMP_TIMES} &amp;gt;= 0;&lt;br&gt;param workloadPerS24 &amp;gt;= 0;&lt;br&gt;param total_S24s &amp;gt;= 0;&lt;br&gt;set S24s = 1..total_S24s;&lt;br&gt;param s24_capacity{LOCATIONS} integer &amp;gt;= 0;&lt;br&gt;param DCPower &amp;gt;=0;&lt;br&gt;param LENGTH = Gamma*gamma/lambda;&lt;/div&gt;

&lt;div&gt;var runlength{S24s, LOCATIONS} integer &amp;gt;= 0;&lt;/div&gt;
&lt;div&gt;var z {S24s, LOCATIONS, COMP_TIMES} binary;&lt;/div&gt;
&lt;div&gt;var run{S24s, LOCATIONS, COMP_TIMES} integer &amp;lt;= LENGTH + 1;&lt;/div&gt;
&lt;div class=&quot;im&quot;&gt;
&lt;div&gt;var S24_Map{S24s, j in LOCATIONS, COMP_TIMES} binary ;&lt;/div&gt;&lt;/div&gt;
&lt;div&gt;var active_S24s { i in LOCATIONS, j in COMP_TIMES} = sum{k in S24s} S24_Map[k, i, j];&lt;/div&gt;
&lt;div&gt;var temp_Required_Pwr {i in LOCATIONS, j in COMP_TIMES} = (sum{k in S24s} S24_Map[k, i, j]) * DCPower / s24_capacity[i];&lt;/div&gt;
&lt;div&gt;var Required_Pwr{i in LOCATIONS, j in PWR_TIMES} = sum {k in j*gamma/lambda .. (j+1)*gamma/lambda-1} temp_Required_Pwr[i, k] &lt;/div&gt;
&lt;div&gt;; &lt;/div&gt;
&lt;div&gt;var tCost{i in LOCATIONS, j in PWR_TIMES} = Required_Pwr[i, j]*pwr_price[i,j];&lt;/div&gt;
&lt;div&gt;var runmap{S24s, LOCATIONS, COMP_TIMES} binary;&lt;/div&gt;
&lt;div&gt;minimize Cost: sum{i in LOCATIONS} (sum{j in PWR_TIMES} tCost[i,j]);&lt;/div&gt;
&lt;div&gt;subject to Workload {i in COMP_TIMES}: &lt;br&gt; workload[i] &amp;lt;= (sum {j in LOCATIONS} active_S24s[j, i])*workloadPerS24;&lt;/div&gt;
&lt;div&gt;subject to saneS24s {i in LOCATIONS, j in COMP_TIMES}: active_S24s[i, j] &amp;lt;= s24_capacity[i];&lt;/div&gt;
&lt;div class=&quot;im&quot;&gt;
&lt;div&gt;subject to runlength1 {i in S24s, j in LOCATIONS, k in COMP_TIMES: k &amp;gt; 1}: run[i, j, k] &amp;lt;= run[i, j, k-1] + 1;&lt;/div&gt;
&lt;div&gt;subject to runlength2 {i in S24s, j in LOCATIONS, k in COMP_TIMES: k &amp;gt; 1}: run[i, j, k] &amp;gt;= run[i, j, k-1] + 1 - LENGTH * (1 - &lt;/div&gt;&lt;/div&gt;
&lt;div&gt;S24_Map[i, j, k]);&lt;/div&gt;
&lt;div&gt;subject to runlength4 {i in S24s, j in LOCATIONS, k in COMP_TIMES: k &amp;gt; 1}: run[i, j, k] &amp;gt;= 0;&lt;/div&gt;
&lt;div&gt;subject to runlength5 {i in S24s, j in LOCATIONS, k in COMP_TIMES: k &amp;gt; 1}: run[i, j, k] &amp;lt;= S24_Map[i, j, k]*(1+LENGTH);&lt;/div&gt;
&lt;div&gt;subject to runlength3{i in S24s, j in LOCATIONS}: run[i, j, 1] = S24_Map[i, j, 1];&lt;/div&gt;
&lt;div&gt;subject to runmap1{i in S24s, j in LOCATIONS, k in COMP_TIMES: k &amp;lt; LENGTH}: runmap[i, j, k] &amp;gt;= S24_Map[i, j, k] - S24_Map[i, j, k+1];&lt;/div&gt;
&lt;div&gt;subject to runmap2{i in S24s, j in LOCATIONS, k in COMP_TIMES: k &amp;lt; LENGTH}: 2*runmap[i, j, k] &amp;lt;= S24_Map[i, j, k] + 1 - S24_Map[i, j, k+1];&lt;/div&gt;
&lt;div&gt;subject to runmap3{i in S24s, j in LOCATIONS}: runmap[i, j, LENGTH] = S24_Map[i, j, LENGTH];&lt;/div&gt;
&lt;div&gt;subject to runlength6{i in S24s, j in LOCATIONS}: runlength[i, j] = min{k in COMP_TIMES} ((1-runmap[i, j, k])*(1+LENGTH)+run[i, j, k]);&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div class=&quot;h5&quot;&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div class=&quot;gmail_quote&quot;&gt;On Sat, Nov 21, 2009 at 10:50 PM, abusufiyan p .. &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26508812&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;sufiyanponani@...&lt;/a&gt;&amp;gt;&lt;/span&gt; wrote:&lt;br&gt;
&lt;blockquote style=&quot;BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex&quot; class=&quot;gmail_quote&quot;&gt;mr: saqib,i would like to more information about lenear programming problem 
&lt;div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;br&gt;
&lt;div&gt;&lt;span class=&quot;gmail_quote&quot;&gt;On 11/21/09, &lt;b class=&quot;gmail_sendername&quot;&gt;Saqib Ilyas&lt;/b&gt; &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26508812&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;msaqib@...&lt;/a&gt;&amp;gt; wrote:&lt;/span&gt; 
&lt;blockquote style=&quot;BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex&quot; class=&quot;gmail_quote&quot;&gt;
&lt;div&gt;Firstly, thanks for your reply and taking out time for this implementation. Paul, I would love an integer linear problem. Thanks for your clever linearization of the model. I spent some time trying to digest it and implement it in my model. The model is slightly different from what you&amp;#39;ve interpreted. &lt;/div&gt;

&lt;div&gt;First, I am (now) interested in the number of consecutive 1s. That is 1100011010 has three runs of length 2, 2, and 1 respectively, whereas 00111100 has one run of length 4. Secondly, I am interested in constraining the length of the smallest runs. I tried to adapt your approach to my problem and implemented the following (Yea, well, I had some 3 dimensional variables and didn&amp;#39;t want to make any mistakes while trying to adapt it for posting on the lsit):&lt;/div&gt;

&lt;div&gt; &lt;/div&gt;
&lt;div&gt;var runlength integer &amp;gt;= 0;&lt;/div&gt;
&lt;div&gt;var z {COMP_TIMES} binary;&lt;/div&gt;
&lt;div&gt;var run{S24s, LOCATIONS, COMP_TIMES} &amp;lt;= LENGTH + 1;&lt;/div&gt;
&lt;div&gt;var S24_Map{S24s, j in LOCATIONS, COMP_TIMES} binary ;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;subject to runlength1 {i in S24s, j in LOCATIONS, k in COMP_TIMES: k &amp;gt; 1}: run[i, j, k] &amp;lt;= run[i, j, k-1] + 1;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;subject to runlength2 {i in S24s, j in LOCATIONS, k in COMP_TIMES: k &amp;gt; 1}: run[i, j, k] &amp;gt;= run[i, j, k-1] + 1 - LENGTH * (1 - S24_Map[i, j, k-1]);&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;subject to runlength3{i in S24s, j in LOCATIONS}: run[i, j, 1] = 1 - LENGTH*(1-S24_Map[i, j, 1]);&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;subject to PickOne: sum{i in COMP_TIMES} z[i] &amp;lt;= 1;&lt;/div&gt;
&lt;div&gt;subject to MinCondition{i in S24s, j in LOCATIONS, k in COMP_TIMES}: runlength &amp;lt;= run[i, j, k];&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;subject to Limit{i in S24s, j in LOCATIONS, k in COMP_TIMES}: runlength &amp;lt;= run[i, j, k] + LENGTH*(1-run[i, j, k]);&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;#subject to MinRun: runlength &amp;gt;= 2;&lt;br&gt;&lt;br&gt;I&amp;#39;ve still got the run length constraint commented out and yet the problem doesn&amp;#39;t seem to be solvable and I get impossible deduced bounds in presolve. Given my modified requirements, is there some error in the above constraints that you can see? Otherwise, I can post the complete model and data files for you and others to run and try.&lt;/div&gt;

&lt;div&gt;&lt;span&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div class=&quot;gmail_quote&quot;&gt;On Thu, Nov 19, 2009 at 5:27 AM, Paul &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26508812&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;rubin@...&lt;/a&gt;&amp;gt;&lt;/span&gt; wrote:&lt;br&gt;
&lt;blockquote style=&quot;BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex&quot; class=&quot;gmail_quote&quot;&gt;You haven&amp;#39;t specified whether your model is linear or not, so I&amp;#39;m&lt;br&gt;going to assume it&amp;#39;s an integer linear program.  I&amp;#39;m inferring from&lt;br&gt;
your examples that (a) the length of a run includes the bounding 1&lt;br&gt;bits (e.g., 1001 is a run of length 4) and (b) when you refer to the&lt;br&gt;run length of a bit sequence you mean the length of the longest run in&lt;br&gt;the sequence.  That leaves open the question of whether a bit sequence&lt;br&gt;
that starts/ends with a zero has an initial/final run (i.e., is there&lt;br&gt;an implicit one before/after a sequence).  For instance, would 000000&lt;br&gt;be considered a single run of six zeros or considered to have no runs&lt;br&gt;at all?&lt;br&gt;
&lt;br&gt;Assuming you want a linear model and there must be an explicit one bit&lt;br&gt;at each end of a run, something like the following might work.  I&lt;br&gt;won&amp;#39;t swear it&amp;#39;s the most efficient possible formulation, though.  I&amp;#39;m&lt;br&gt;
adopting the convention that no runs equates to run length 0.&lt;br&gt;&lt;br&gt;param LENGTH integer &amp;gt; 0;  # length of a bit sequence -- I assume they&lt;br&gt;all have the same length&lt;br&gt;set POSITION := 1..LENGTH;  # index set&lt;br&gt;var bit {POSITION} binary;   # variables that will yield a bit&lt;br&gt;
sequence&lt;br&gt;var runlength integer &amp;gt;= 0;  # maximum run length&lt;br&gt;var r {POSITION};  # helper variable that maps each bit to the length&lt;br&gt;of the run containing it -- NOT nonnegative and not explicitly&lt;br&gt;declared integer&lt;br&gt;
var y {POSITION} binary;  # helper variable that maps a bit to 0 if it&lt;br&gt;is part of an ongoing run and 1 if not&lt;br&gt;var z {POSITION} binary;  # helper variable that points to the end bit&lt;br&gt;of the longest run&lt;br&gt;&lt;br&gt;# the next three constraints determine y&lt;br&gt;
s.t. Ongoing1 {k in POSITION : k &amp;gt; 1}: y[k] &amp;gt;= bit[k-1] + bit[k] - 1;&lt;br&gt;s.t. Ongoing2 {k in POSITION : k &amp;gt; 1}: 2*y[k] &amp;lt;= bit[k-1] + bit[k];&lt;br&gt;s.t. Start: y[1] = 0;  # the first bit cannot be part of an &amp;quot;ongoing&amp;quot;&lt;br&gt;
run (it could start one)&lt;br&gt;# if bit[k] and bit[k-1] are both 1, y[k] = 1; otherwise y[k] = 0&lt;br&gt;&lt;br&gt;# the following constraints compute the length of any ongoing run at&lt;br&gt;each position&lt;br&gt;s.t. RunUpperLimit {k in POSITION}: r[k] &amp;lt;= r[k-1] + 1;  # run length&lt;br&gt;
increases at most 1 as you advance one bit&lt;br&gt;s.t. InRun1 {k in POSITION : k &amp;gt; 1}: r[k] &amp;gt;= r[k-1] + 1 - LENGTH*y&lt;br&gt;[k];  # if y[k] = 0 (position k is part of a run), r[k] must equal r&lt;br&gt;[k-1] + 1&lt;br&gt;s.t. InRun2 {k in POSITION : k &amp;gt; 1}: r[k] &amp;lt;= 1 + LENGTH*(1 - y[k]);  #&lt;br&gt;
if y[k] = 0 (position k is part of a run), this is vacuous; otherwise&lt;br&gt;it forces r[k] &amp;lt;= 1 (bit[k] could be the initial 1 of a run, or it&lt;br&gt;could be part of a non-run)&lt;br&gt;s.t. InitLength: r[1] = 1 - LENGTH*(1-bit[1]);  # if bit[1] = 1, r[1]&lt;br&gt;
= 1; otherwise r[1] is negative (sequence starts with 0, so the&lt;br&gt;initial &amp;quot;run&amp;quot; doesn&amp;#39;t count)&lt;br&gt;&lt;br&gt;# the next constraint says we&amp;#39;ll select at most a single bit position&lt;br&gt;as the terminus of the maximum run&lt;br&gt;
s.t. PickOne: sum {k in POSIITION} z[k] &amp;lt;= 1;  # the sum is zero --&lt;br&gt;all z[k] are 0 -- iff there is no run&lt;br&gt;&lt;br&gt;# finally, we need constraints to define the maximum run length&lt;br&gt;s.t. MaxCondition {k in POSITION}: runlength &amp;gt;= r[k];  # the run&lt;br&gt;
length is at least as large as the ongoing run length at every&lt;br&gt;position&lt;br&gt;s.t. Limit {k in POSITION}: runlength &amp;lt;= r[k] + LENGTH*(1 - z[k]);  #&lt;br&gt;limits the runlength to r[k] if k is the position that terminates the&lt;br&gt;
longest run&lt;br&gt;&lt;br&gt;You really need to check that mess; it&amp;#39;s not beyond the bounds of&lt;br&gt;possibility that I booted something.&lt;br&gt;&lt;font color=&quot;#888888&quot;&gt;&lt;br&gt;/Paul&lt;br&gt;&lt;/font&gt;
&lt;div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;msaqib wrote:&lt;br&gt;&amp;gt; My case is &amp;quot;c&amp;quot;, the bits are model variables and the run length should be&lt;br&gt;&amp;gt; computed and it factors in the objective function.&lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt; Paul-432 wrote:&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;&amp;gt; &amp;gt; I can interpret this three different ways:&lt;br&gt;&amp;gt; &amp;gt;&lt;br&gt;&amp;gt; &amp;gt; a) the bits are parameters of the model;&lt;br&gt;&amp;gt; &amp;gt; b) the bits are model variables (unknown when the model is&lt;br&gt;&amp;gt; &amp;gt; formulated), and you need to compute the run length of the final&lt;br&gt;
&amp;gt; &amp;gt; solution after the solution is obtained; or&lt;br&gt;&amp;gt; &amp;gt; c) the bits are model variables and so is the run length, and the run&lt;br&gt;&amp;gt; &amp;gt; length is used within the model.&lt;br&gt;&amp;gt; &amp;gt;&lt;br&gt;&amp;gt; &amp;gt; The first two can be handled by looping; the third requires additional&lt;br&gt;
&amp;gt; &amp;gt; model constructs (constraints and probability some auxiliary&lt;br&gt;&amp;gt; &amp;gt; variables).&lt;br&gt;&amp;gt; &amp;gt;&lt;br&gt;&amp;gt; &amp;gt; /Paul&lt;br&gt;&amp;gt; &amp;gt;&lt;br&gt;&amp;gt; &amp;gt; On Nov 16, 8:24 am, msaqib &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26508812&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;msa...@...&lt;/a&gt;&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; Hi all&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; In a model, I need to calculate the runlength of a sequence of binary&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; (0/1)&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; numbers. In other words, I need to count the number of zeros between a&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; pair&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; of ones. For example, the runlength in 0010001110010 is 5, and that for&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; 0010000110010 is 6. I&amp;#39;m not sure how to represent this mathematically in&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; an&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; AMPL model. We typically do this iteratively in other programming&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; languages.&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; Any clues?&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; Thanks and best regards&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; --&lt;br&gt;&amp;gt; &amp;gt;&lt;br&gt;&amp;gt; --&lt;br&gt;
&amp;gt; View this message in context: &lt;a href=&quot;http://old.nabble.com/calculating-runlength-tp26371837p26385781.html&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://old.nabble.com/calculating-runlength-tp26371837p26385781.html&lt;/a&gt;&lt;br&gt;&amp;gt; Sent from the AMPL mailing list archive at Nabble.com.&lt;br&gt;
&lt;br&gt;--&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26508812&amp;i=5&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.&lt;br&gt;
To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26508812&amp;i=6&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl%2Bunsubscribe@...&lt;/a&gt;.&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;&lt;br&gt; &lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;br clear=&quot;all&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;/div&gt;&lt;span&gt;-- &lt;br&gt;Muhammad Saqib Ilyas&lt;br&gt;PhD Student, Computer Science and Engineering&lt;br&gt;Lahore University of Management Sciences&lt;/span&gt; 
&lt;div&gt;&lt;span&gt;&lt;br&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;--&lt;/p&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26508812&amp;i=7&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.&lt;br&gt;
To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26508812&amp;i=8&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl%2Bunsubscribe@...&lt;/a&gt;.&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.&lt;br&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;--&lt;/p&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26508812&amp;i=9&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.&lt;br&gt;
To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26508812&amp;i=10&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl%2Bunsubscribe@...&lt;/a&gt;.&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.&lt;br&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;br clear=&quot;all&quot;&gt;&lt;br&gt;-- &lt;br&gt;Muhammad Saqib Ilyas&lt;br&gt;PhD Student, Computer Science and Engineering&lt;br&gt;Lahore University of Management Sciences&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;br clear=&quot;all&quot;&gt;
&lt;br&gt;-- &lt;br&gt;Muhammad Saqib Ilyas&lt;br&gt;PhD Student, Computer Science and Engineering&lt;br&gt;Lahore University of Management Sciences&lt;br&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;--&lt;/p&gt;

You received this message because you are subscribed to the Google Groups &quot;AMPL Modeling Language&quot; group.&lt;br /&gt;

To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26508812&amp;i=11&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.&lt;br /&gt;

To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26508812&amp;i=12&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.&lt;br /&gt;

For more options, visit this group at http://groups.google.com/group/ampl?hl=en.&lt;br /&gt;

</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/calculating-runlength-tp26371837p26508812.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26499507</id>
	<title>RE: [AMPL 3037] write table command error</title>
	<published>2009-11-24T08:57:50Z</published>
	<updated>2009-11-24T08:57:50Z</updated>
	<author>
		<name>Robert Fourer-2</name>
	</author>
	<content type="html">&lt;br&gt;This error message suggests that you might have run up against an obscure
&lt;br&gt;bug of some kind. &amp;nbsp;Can you provide the files that you used, so that I can
&lt;br&gt;try to reproduce the problem? &amp;nbsp;Then we can get it fixed but in the mean time
&lt;br&gt;there may be a simple workaround.
&lt;br&gt;&lt;br&gt;Bob Fourer
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26499507&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;4er@...&lt;/a&gt;
&lt;br&gt;&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; -----Original Message-----
&lt;br&gt;&amp;gt; From: Mangotree [mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26499507&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;mangotree.gf@...&lt;/a&gt;]
&lt;br&gt;&amp;gt; Sent: Monday, November 23, 2009 5:57 PM
&lt;br&gt;&amp;gt; To: AMPL Modeling Language
&lt;br&gt;&amp;gt; Subject: [AMPL 3035] write table command error
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Dear AMPL guru,
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;When using write table command, ampl gave me an error
&lt;br&gt;&amp;gt; message:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 'Error executing &amp;quot;write_table&amp;quot; command:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 contexts remain open after compile!'
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; The table is defined as: table example OUT: {i in NAME, j in TIME} -&amp;gt;
&lt;br&gt;&amp;gt; [NAME,TIME], Value;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; where: Value is defined over 2 sets Name &amp; Time.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Can someone advise me where the issue is? What is the exact
&lt;br&gt;&amp;gt; meaning of the error message? Thanks!
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Feng
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; You received this message because you are subscribed to the Google Groups
&lt;br&gt;&amp;gt; &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;&amp;gt; To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26499507&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;&amp;gt; To unsubscribe from this group, send email to
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26499507&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;&amp;gt; For more options, visit this group at
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.
&lt;br&gt;&amp;gt; 
&lt;/div&gt;&lt;br&gt;&lt;br&gt;--
&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26499507&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26499507&amp;i=5&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=en&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=en&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/-AMPL-3035--write-table-command-error-tp26488331p26499507.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26495499</id>
	<title>Re: [AMPL 3036] Re: calculating runlength</title>
	<published>2009-11-24T05:03:59Z</published>
	<updated>2009-11-24T05:03:59Z</updated>
	<author>
		<name>msaqib</name>
	</author>
	<content type="html">&lt;div&gt;I am now able to correctly compute the runlength as I desire. However, the problem now has nonlinear constraints. Do you think I might be able to somehow express the same in a linear fashion? Also, abusufyan, I didn&amp;#39;t get your question.&lt;/div&gt;

&lt;div&gt; &lt;/div&gt;
&lt;div&gt;set LOCATIONS;&lt;br&gt;param Gamma &amp;gt;= 0;&lt;br&gt;param gamma &amp;gt;= 0;&lt;br&gt;param lambda &amp;gt;= 0;&lt;br&gt;param Lambda &amp;gt;= 0;&lt;br&gt;set COMP_TIMES = 1 .. (Gamma*gamma/lambda);&lt;br&gt;set PWR_TIMES = 1 .. (Gamma*gamma);&lt;br&gt;param pwr_price{LOCATIONS, PWR_TIMES} &amp;gt;= 0;&lt;br&gt;
param workload{COMP_TIMES} &amp;gt;= 0;&lt;br&gt;param workloadPerS24 &amp;gt;= 0;&lt;br&gt;param total_S24s &amp;gt;= 0;&lt;br&gt;set S24s = 1..total_S24s;&lt;br&gt;param s24_capacity{LOCATIONS} integer &amp;gt;= 0;&lt;br&gt;param DCPower &amp;gt;=0;&lt;br&gt;param LENGTH = Gamma*gamma/lambda;&lt;/div&gt;

&lt;div&gt;var runlength{S24s, LOCATIONS} integer &amp;gt;= 0;&lt;/div&gt;
&lt;div&gt;var z {S24s, LOCATIONS, COMP_TIMES} binary;&lt;/div&gt;
&lt;div&gt;var run{S24s, LOCATIONS, COMP_TIMES} integer &amp;lt;= LENGTH + 1;&lt;/div&gt;
&lt;div&gt;var S24_Map{S24s, j in LOCATIONS, COMP_TIMES} binary ;&lt;/div&gt;
&lt;div&gt;var active_S24s { i in LOCATIONS, j in COMP_TIMES} = sum{k in S24s} S24_Map[k, i, j];&lt;/div&gt;
&lt;div&gt;var temp_Required_Pwr {i in LOCATIONS, j in COMP_TIMES} = (sum{k in S24s} S24_Map[k, i, j]) * DCPower / s24_capacity[i];&lt;/div&gt;
&lt;div&gt;var Required_Pwr{i in LOCATIONS, j in PWR_TIMES} = sum {k in j*gamma/lambda .. (j+1)*gamma/lambda-1} temp_Required_Pwr[i, k] &lt;/div&gt;
&lt;div&gt;; &lt;/div&gt;
&lt;div&gt;var tCost{i in LOCATIONS, j in PWR_TIMES} = Required_Pwr[i, j]*pwr_price[i,j];&lt;/div&gt;
&lt;div&gt;var runmap{S24s, LOCATIONS, COMP_TIMES} binary;&lt;/div&gt;
&lt;div&gt;minimize Cost: sum{i in LOCATIONS} (sum{j in PWR_TIMES} tCost[i,j]);&lt;/div&gt;
&lt;div&gt;subject to Workload {i in COMP_TIMES}: &lt;br&gt; workload[i] &amp;lt;= (sum {j in LOCATIONS} active_S24s[j, i])*workloadPerS24;&lt;/div&gt;
&lt;div&gt;subject to saneS24s {i in LOCATIONS, j in COMP_TIMES}: active_S24s[i, j] &amp;lt;= s24_capacity[i];&lt;/div&gt;
&lt;div&gt;subject to runlength1 {i in S24s, j in LOCATIONS, k in COMP_TIMES: k &amp;gt; 1}: run[i, j, k] &amp;lt;= run[i, j, k-1] + 1;&lt;/div&gt;
&lt;div&gt;subject to runlength2 {i in S24s, j in LOCATIONS, k in COMP_TIMES: k &amp;gt; 1}: run[i, j, k] &amp;gt;= run[i, j, k-1] + 1 - LENGTH * (1 - &lt;/div&gt;
&lt;div&gt;S24_Map[i, j, k]);&lt;/div&gt;
&lt;div&gt;subject to runlength4 {i in S24s, j in LOCATIONS, k in COMP_TIMES: k &amp;gt; 1}: run[i, j, k] &amp;gt;= 0;&lt;/div&gt;
&lt;div&gt;subject to runlength5 {i in S24s, j in LOCATIONS, k in COMP_TIMES: k &amp;gt; 1}: run[i, j, k] &amp;lt;= S24_Map[i, j, k]*(1+LENGTH);&lt;/div&gt;
&lt;div&gt;subject to runlength3{i in S24s, j in LOCATIONS}: run[i, j, 1] = S24_Map[i, j, 1];&lt;/div&gt;
&lt;div&gt;subject to runmap1{i in S24s, j in LOCATIONS, k in COMP_TIMES: k &amp;lt; LENGTH}: runmap[i, j, k] &amp;gt;= S24_Map[i, j, k] - S24_Map[i, j, k+1];&lt;/div&gt;
&lt;div&gt;subject to runmap2{i in S24s, j in LOCATIONS, k in COMP_TIMES: k &amp;lt; LENGTH}: 2*runmap[i, j, k] &amp;lt;= S24_Map[i, j, k] + 1 - S24_Map[i, j, k+1];&lt;/div&gt;
&lt;div&gt;subject to runmap3{i in S24s, j in LOCATIONS}: runmap[i, j, LENGTH] = S24_Map[i, j, LENGTH];&lt;/div&gt;
&lt;div&gt;subject to runlength6{i in S24s, j in LOCATIONS}: runlength[i, j] = min{k in COMP_TIMES} ((1-runmap[i, j, k])*(1+LENGTH)+run[i, j, k]);&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div class=&quot;gmail_quote&quot;&gt;On Sat, Nov 21, 2009 at 10:50 PM, abusufiyan p .. &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26495499&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;sufiyanponani@...&lt;/a&gt;&amp;gt;&lt;/span&gt; wrote:&lt;br&gt;
&lt;blockquote style=&quot;BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex&quot; class=&quot;gmail_quote&quot;&gt;mr: saqib,i would like to more information about lenear programming problem 
&lt;div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;br&gt;
&lt;div&gt;&lt;span class=&quot;gmail_quote&quot;&gt;On 11/21/09, &lt;b class=&quot;gmail_sendername&quot;&gt;Saqib Ilyas&lt;/b&gt; &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26495499&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;msaqib@...&lt;/a&gt;&amp;gt; wrote:&lt;/span&gt; 
&lt;blockquote style=&quot;BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex&quot; class=&quot;gmail_quote&quot;&gt;
&lt;div&gt;Firstly, thanks for your reply and taking out time for this implementation. Paul, I would love an integer linear problem. Thanks for your clever linearization of the model. I spent some time trying to digest it and implement it in my model. The model is slightly different from what you&amp;#39;ve interpreted. &lt;/div&gt;

&lt;div&gt;First, I am (now) interested in the number of consecutive 1s. That is 1100011010 has three runs of length 2, 2, and 1 respectively, whereas 00111100 has one run of length 4. Secondly, I am interested in constraining the length of the smallest runs. I tried to adapt your approach to my problem and implemented the following (Yea, well, I had some 3 dimensional variables and didn&amp;#39;t want to make any mistakes while trying to adapt it for posting on the lsit):&lt;/div&gt;

&lt;div&gt; &lt;/div&gt;
&lt;div&gt;var runlength integer &amp;gt;= 0;&lt;/div&gt;
&lt;div&gt;var z {COMP_TIMES} binary;&lt;/div&gt;
&lt;div&gt;var run{S24s, LOCATIONS, COMP_TIMES} &amp;lt;= LENGTH + 1;&lt;/div&gt;
&lt;div&gt;var S24_Map{S24s, j in LOCATIONS, COMP_TIMES} binary ;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;subject to runlength1 {i in S24s, j in LOCATIONS, k in COMP_TIMES: k &amp;gt; 1}: run[i, j, k] &amp;lt;= run[i, j, k-1] + 1;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;subject to runlength2 {i in S24s, j in LOCATIONS, k in COMP_TIMES: k &amp;gt; 1}: run[i, j, k] &amp;gt;= run[i, j, k-1] + 1 - LENGTH * (1 - S24_Map[i, j, k-1]);&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;subject to runlength3{i in S24s, j in LOCATIONS}: run[i, j, 1] = 1 - LENGTH*(1-S24_Map[i, j, 1]);&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;subject to PickOne: sum{i in COMP_TIMES} z[i] &amp;lt;= 1;&lt;/div&gt;
&lt;div&gt;subject to MinCondition{i in S24s, j in LOCATIONS, k in COMP_TIMES}: runlength &amp;lt;= run[i, j, k];&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;subject to Limit{i in S24s, j in LOCATIONS, k in COMP_TIMES}: runlength &amp;lt;= run[i, j, k] + LENGTH*(1-run[i, j, k]);&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;#subject to MinRun: runlength &amp;gt;= 2;&lt;br&gt;&lt;br&gt;I&amp;#39;ve still got the run length constraint commented out and yet the problem doesn&amp;#39;t seem to be solvable and I get impossible deduced bounds in presolve. Given my modified requirements, is there some error in the above constraints that you can see? Otherwise, I can post the complete model and data files for you and others to run and try.&lt;/div&gt;

&lt;div&gt;&lt;span&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div class=&quot;gmail_quote&quot;&gt;On Thu, Nov 19, 2009 at 5:27 AM, Paul &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26495499&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;rubin@...&lt;/a&gt;&amp;gt;&lt;/span&gt; wrote:&lt;br&gt;
&lt;blockquote style=&quot;BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex&quot; class=&quot;gmail_quote&quot;&gt;You haven&amp;#39;t specified whether your model is linear or not, so I&amp;#39;m&lt;br&gt;going to assume it&amp;#39;s an integer linear program.  I&amp;#39;m inferring from&lt;br&gt;
your examples that (a) the length of a run includes the bounding 1&lt;br&gt;bits (e.g., 1001 is a run of length 4) and (b) when you refer to the&lt;br&gt;run length of a bit sequence you mean the length of the longest run in&lt;br&gt;the sequence.  That leaves open the question of whether a bit sequence&lt;br&gt;
that starts/ends with a zero has an initial/final run (i.e., is there&lt;br&gt;an implicit one before/after a sequence).  For instance, would 000000&lt;br&gt;be considered a single run of six zeros or considered to have no runs&lt;br&gt;at all?&lt;br&gt;
&lt;br&gt;Assuming you want a linear model and there must be an explicit one bit&lt;br&gt;at each end of a run, something like the following might work.  I&lt;br&gt;won&amp;#39;t swear it&amp;#39;s the most efficient possible formulation, though.  I&amp;#39;m&lt;br&gt;
adopting the convention that no runs equates to run length 0.&lt;br&gt;&lt;br&gt;param LENGTH integer &amp;gt; 0;  # length of a bit sequence -- I assume they&lt;br&gt;all have the same length&lt;br&gt;set POSITION := 1..LENGTH;  # index set&lt;br&gt;var bit {POSITION} binary;   # variables that will yield a bit&lt;br&gt;
sequence&lt;br&gt;var runlength integer &amp;gt;= 0;  # maximum run length&lt;br&gt;var r {POSITION};  # helper variable that maps each bit to the length&lt;br&gt;of the run containing it -- NOT nonnegative and not explicitly&lt;br&gt;declared integer&lt;br&gt;
var y {POSITION} binary;  # helper variable that maps a bit to 0 if it&lt;br&gt;is part of an ongoing run and 1 if not&lt;br&gt;var z {POSITION} binary;  # helper variable that points to the end bit&lt;br&gt;of the longest run&lt;br&gt;&lt;br&gt;# the next three constraints determine y&lt;br&gt;
s.t. Ongoing1 {k in POSITION : k &amp;gt; 1}: y[k] &amp;gt;= bit[k-1] + bit[k] - 1;&lt;br&gt;s.t. Ongoing2 {k in POSITION : k &amp;gt; 1}: 2*y[k] &amp;lt;= bit[k-1] + bit[k];&lt;br&gt;s.t. Start: y[1] = 0;  # the first bit cannot be part of an &amp;quot;ongoing&amp;quot;&lt;br&gt;
run (it could start one)&lt;br&gt;# if bit[k] and bit[k-1] are both 1, y[k] = 1; otherwise y[k] = 0&lt;br&gt;&lt;br&gt;# the following constraints compute the length of any ongoing run at&lt;br&gt;each position&lt;br&gt;s.t. RunUpperLimit {k in POSITION}: r[k] &amp;lt;= r[k-1] + 1;  # run length&lt;br&gt;
increases at most 1 as you advance one bit&lt;br&gt;s.t. InRun1 {k in POSITION : k &amp;gt; 1}: r[k] &amp;gt;= r[k-1] + 1 - LENGTH*y&lt;br&gt;[k];  # if y[k] = 0 (position k is part of a run), r[k] must equal r&lt;br&gt;[k-1] + 1&lt;br&gt;s.t. InRun2 {k in POSITION : k &amp;gt; 1}: r[k] &amp;lt;= 1 + LENGTH*(1 - y[k]);  #&lt;br&gt;
if y[k] = 0 (position k is part of a run), this is vacuous; otherwise&lt;br&gt;it forces r[k] &amp;lt;= 1 (bit[k] could be the initial 1 of a run, or it&lt;br&gt;could be part of a non-run)&lt;br&gt;s.t. InitLength: r[1] = 1 - LENGTH*(1-bit[1]);  # if bit[1] = 1, r[1]&lt;br&gt;
= 1; otherwise r[1] is negative (sequence starts with 0, so the&lt;br&gt;initial &amp;quot;run&amp;quot; doesn&amp;#39;t count)&lt;br&gt;&lt;br&gt;# the next constraint says we&amp;#39;ll select at most a single bit position&lt;br&gt;as the terminus of the maximum run&lt;br&gt;
s.t. PickOne: sum {k in POSIITION} z[k] &amp;lt;= 1;  # the sum is zero --&lt;br&gt;all z[k] are 0 -- iff there is no run&lt;br&gt;&lt;br&gt;# finally, we need constraints to define the maximum run length&lt;br&gt;s.t. MaxCondition {k in POSITION}: runlength &amp;gt;= r[k];  # the run&lt;br&gt;
length is at least as large as the ongoing run length at every&lt;br&gt;position&lt;br&gt;s.t. Limit {k in POSITION}: runlength &amp;lt;= r[k] + LENGTH*(1 - z[k]);  #&lt;br&gt;limits the runlength to r[k] if k is the position that terminates the&lt;br&gt;
longest run&lt;br&gt;&lt;br&gt;You really need to check that mess; it&amp;#39;s not beyond the bounds of&lt;br&gt;possibility that I booted something.&lt;br&gt;&lt;font color=&quot;#888888&quot;&gt;&lt;br&gt;/Paul&lt;br&gt;&lt;/font&gt;
&lt;div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;msaqib wrote:&lt;br&gt;&amp;gt; My case is &amp;quot;c&amp;quot;, the bits are model variables and the run length should be&lt;br&gt;&amp;gt; computed and it factors in the objective function.&lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt; Paul-432 wrote:&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;&amp;gt; &amp;gt; I can interpret this three different ways:&lt;br&gt;&amp;gt; &amp;gt;&lt;br&gt;&amp;gt; &amp;gt; a) the bits are parameters of the model;&lt;br&gt;&amp;gt; &amp;gt; b) the bits are model variables (unknown when the model is&lt;br&gt;&amp;gt; &amp;gt; formulated), and you need to compute the run length of the final&lt;br&gt;
&amp;gt; &amp;gt; solution after the solution is obtained; or&lt;br&gt;&amp;gt; &amp;gt; c) the bits are model variables and so is the run length, and the run&lt;br&gt;&amp;gt; &amp;gt; length is used within the model.&lt;br&gt;&amp;gt; &amp;gt;&lt;br&gt;&amp;gt; &amp;gt; The first two can be handled by looping; the third requires additional&lt;br&gt;
&amp;gt; &amp;gt; model constructs (constraints and probability some auxiliary&lt;br&gt;&amp;gt; &amp;gt; variables).&lt;br&gt;&amp;gt; &amp;gt;&lt;br&gt;&amp;gt; &amp;gt; /Paul&lt;br&gt;&amp;gt; &amp;gt;&lt;br&gt;&amp;gt; &amp;gt; On Nov 16, 8:24 am, msaqib &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26495499&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;msa...@...&lt;/a&gt;&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; Hi all&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; In a model, I need to calculate the runlength of a sequence of binary&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; (0/1)&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; numbers. In other words, I need to count the number of zeros between a&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; pair&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; of ones. For example, the runlength in 0010001110010 is 5, and that for&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; 0010000110010 is 6. I&amp;#39;m not sure how to represent this mathematically in&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; an&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; AMPL model. We typically do this iteratively in other programming&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; languages.&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; Any clues?&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; Thanks and best regards&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; --&lt;br&gt;&amp;gt; &amp;gt;&lt;br&gt;&amp;gt; --&lt;br&gt;
&amp;gt; View this message in context: &lt;a href=&quot;http://old.nabble.com/calculating-runlength-tp26371837p26385781.html&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://old.nabble.com/calculating-runlength-tp26371837p26385781.html&lt;/a&gt;&lt;br&gt;&amp;gt; Sent from the AMPL mailing list archive at Nabble.com.&lt;br&gt;
&lt;br&gt;--&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26495499&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.&lt;br&gt;
To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26495499&amp;i=5&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl%2Bunsubscribe@...&lt;/a&gt;.&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;&lt;br&gt; &lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;br clear=&quot;all&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;/div&gt;&lt;span&gt;-- &lt;br&gt;Muhammad Saqib Ilyas&lt;br&gt;PhD Student, Computer Science and Engineering&lt;br&gt;Lahore University of Management Sciences&lt;/span&gt; 
&lt;div&gt;&lt;span&gt;&lt;br&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;--&lt;/p&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26495499&amp;i=6&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.&lt;br&gt;
To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26495499&amp;i=7&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl%2Bunsubscribe@...&lt;/a&gt;.&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.&lt;br&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;--&lt;/p&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26495499&amp;i=8&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.&lt;br&gt;
To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26495499&amp;i=9&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl%2Bunsubscribe@...&lt;/a&gt;.&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.&lt;br&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;br clear=&quot;all&quot;&gt;&lt;br&gt;-- &lt;br&gt;Muhammad Saqib Ilyas&lt;br&gt;PhD Student, Computer Science and Engineering&lt;br&gt;Lahore University of Management Sciences&lt;br&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;--&lt;/p&gt;

You received this message because you are subscribed to the Google Groups &quot;AMPL Modeling Language&quot; group.&lt;br /&gt;

To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26495499&amp;i=10&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.&lt;br /&gt;

To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26495499&amp;i=11&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.&lt;br /&gt;

For more options, visit this group at http://groups.google.com/group/ampl?hl=en.&lt;br /&gt;

</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/calculating-runlength-tp26371837p26495499.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26488331</id>
	<title>[AMPL 3035] write table command error</title>
	<published>2009-11-23T15:57:11Z</published>
	<updated>2009-11-23T15:57:11Z</updated>
	<author>
		<name>Mangotree</name>
	</author>
	<content type="html">Dear AMPL guru,
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;When using write table command, ampl gave me an error
&lt;br&gt;message:
&lt;br&gt;&lt;br&gt;'Error executing &amp;quot;write_table&amp;quot; command:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 contexts remain open after compile!'
&lt;br&gt;&lt;br&gt;The table is defined as: table example OUT: {i in NAME, j in TIME} -&amp;gt;
&lt;br&gt;[NAME,TIME], Value;
&lt;br&gt;&lt;br&gt;where: Value is defined over 2 sets Name &amp; Time.
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Can someone advise me where the issue is? What is the exact
&lt;br&gt;meaning of the error message? Thanks!
&lt;br&gt;&lt;br&gt;Feng
&lt;br&gt;&lt;br&gt;--
&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26488331&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26488331&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/-AMPL-3035--write-table-command-error-tp26488331p26488331.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26480054</id>
	<title>[AMPL 3034] how to spec. an assignment constraint</title>
	<published>2009-11-23T07:09:43Z</published>
	<updated>2009-11-23T07:09:43Z</updated>
	<author>
		<name>L. G.</name>
	</author>
	<content type="html">hi!
&lt;br&gt;&lt;br&gt;&lt;br&gt;I'm quite novice in ampl yet and trying to solve a sort of a task
&lt;br&gt;assignment problem with ampl/cplex. I have had several attempts on one
&lt;br&gt;of my constraints but it does not seem to work out for me.
&lt;br&gt;&lt;br&gt;The problem is the following, I have a set of i's clustered into
&lt;br&gt;subsets and a set of j's clustered into subsets for another reason.
&lt;br&gt;Let's say
&lt;br&gt;&lt;br&gt;i in FRUITS, j in STUDENTS, then within the fruits I would have e.g.
&lt;br&gt;25 types/subsets/SUBFRUITS (fruits are categorized in param ms[i,s]
&lt;br&gt;given as data) and also the students would be classified e.g. into 10
&lt;br&gt;CLASSES (also a param classes[j] tells which class a student is in).
&lt;br&gt;&lt;br&gt;In this case I would want to have all fruits given to some students
&lt;br&gt;such that all fruits of a certain type out of the 25 possible, e.g. 5
&lt;br&gt;apples, are distributed among the students so that each of the five
&lt;br&gt;apples are given to students in different classes (out of the 10). No
&lt;br&gt;second student in a class can get an apple where an apple has already
&lt;br&gt;been handed out.
&lt;br&gt;&lt;br&gt;The target of the optimization is the mapping between i -&amp;gt; j (m[i,j]
&lt;br&gt;binary), and this would be one of the constraints to it.
&lt;br&gt;&lt;br&gt;One of my many failed attempts to specify this constraint:
&lt;br&gt;&lt;br&gt;subject to Constr1 {s in SUBFRUITS, i in FRUITS, k in FRUITS, d in
&lt;br&gt;CLASSES: i&amp;lt;k}:
&lt;br&gt;ms[i,s] * md[i,d] + ms[k,s] * md[k,d] &amp;lt;= 1;
&lt;br&gt;&lt;br&gt;where the binary md[i,d] would return the mapping between a fruit i
&lt;br&gt;(in FRUITS) and a class d (a subclass within STUDENTS), but I don't
&lt;br&gt;know how to specify md[] to make this work.
&lt;br&gt;&lt;br&gt;First of all I'm not quite sure if md[] would be a var or a param, as
&lt;br&gt;it derives from a var that we optimize, the mapping m[i,j], the
&lt;br&gt;following way:
&lt;br&gt;md[ i, m[i,j]*classes[j] ] = 1, and 0 otherwise.
&lt;br&gt;&lt;br&gt;since we have the classification of the students in the param classes
&lt;br&gt;[j], but this sentence above is syntactically incorrect.
&lt;br&gt;&lt;br&gt;Could anyone give me a hint how to spec. this constraint of mine?
&lt;br&gt;&lt;br&gt;--
&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26480054&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26480054&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/-AMPL-3034--how-to-spec.-an-assignment-constraint-tp26480054p26480054.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26461298</id>
	<title>Re: [AMPL 3032] Re: calculating runlength</title>
	<published>2009-11-21T15:02:31Z</published>
	<updated>2009-11-21T15:02:31Z</updated>
	<author>
		<name>Paul-432</name>
	</author>
	<content type="html">Saqib Ilyas wrote:
&lt;br&gt;&amp;gt; Firstly, thanks for your reply and taking out time for this implementation.
&lt;br&gt;&lt;br&gt;You're welcome.
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Paul, I would love an integer linear problem. Thanks for your clever
&lt;br&gt;&amp;gt; linearization of the model. I spent some time trying to digest it and
&lt;br&gt;&amp;gt; implement it in my model. The model is slightly different from what you've
&lt;br&gt;&amp;gt; interpreted.
&lt;br&gt;&amp;gt; First, I am (now) interested in the number of consecutive 1s. That is
&lt;br&gt;&amp;gt; 1100011010 has three runs of length 2, 2, and 1 respectively, whereas
&lt;br&gt;&amp;gt; 00111100 has one run of length 4. Secondly, I am interested in constraining
&lt;br&gt;&amp;gt; the length of the smallest runs. I tried to adapt your approach to my
&lt;br&gt;&amp;gt; problem and implemented the following (Yea, well, I had some 3 dimensional
&lt;br&gt;&amp;gt; variables and didn't want to make any mistakes while trying to adapt it for
&lt;br&gt;&amp;gt; posting on the lsit):
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; var runlength integer &amp;gt;= 0;
&lt;br&gt;&amp;gt; var z {COMP_TIMES} binary;
&lt;br&gt;&amp;gt; var run{S24s, LOCATIONS, COMP_TIMES} &amp;lt;= LENGTH + 1;
&lt;br&gt;&amp;gt; var S24_Map{S24s, j in LOCATIONS, COMP_TIMES} binary ;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; subject to runlength1 {i in S24s, j in LOCATIONS, k in COMP_TIMES: k &amp;gt; 1}:
&lt;br&gt;&amp;gt; run[i, j, k] &amp;lt;= run[i, j, k-1] + 1;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; subject to runlength2 {i in S24s, j in LOCATIONS, k in COMP_TIMES: k &amp;gt; 1}:
&lt;br&gt;&amp;gt; run[i, j, k] &amp;gt;= run[i, j, k-1] + 1 - LENGTH * (1 - S24_Map[i, j, k-1]);
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; subject to runlength3{i in S24s, j in LOCATIONS}: run[i, j, 1] = 1 -
&lt;br&gt;&amp;gt; LENGTH*(1-S24_Map[i, j, 1]);
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; subject to PickOne: sum{i in COMP_TIMES} z[i] &amp;lt;= 1;
&lt;br&gt;&amp;gt; subject to MinCondition{i in S24s, j in LOCATIONS, k in COMP_TIMES}:
&lt;br&gt;&amp;gt; runlength &amp;lt;= run[i, j, k];
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; subject to Limit{i in S24s, j in LOCATIONS, k in COMP_TIMES}: runlength &amp;lt;=
&lt;br&gt;&amp;gt; run[i, j, k] + LENGTH*(1-run[i, j, k]);
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; #subject to MinRun: runlength &amp;gt;= 2;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I've still got the run length constraint commented out and yet the problem
&lt;br&gt;&amp;gt; doesn't seem to be solvable and I get impossible deduced bounds in presolve.
&lt;br&gt;&amp;gt; Given my modified requirements, is there some error in the above constraints
&lt;br&gt;&amp;gt; that you can see?
&lt;/div&gt;&lt;br&gt;Yes, there's a problem. &amp;nbsp;Keep in mind that run[i,j,k] is defined for
&lt;br&gt;every triple (i,j,k), not just for those that are parts of a run. &amp;nbsp;So
&lt;br&gt;if S24_Map[i,j,1] (which I assume represents the first bit in a
&lt;br&gt;string) is 0, then run[i,j,1] is negative (courtesy of the runlength3
&lt;br&gt;constraints), which means runlength is negative (courtesy of
&lt;br&gt;MinCondition), which means the MinRun constraint cannot be satisfied.
&lt;br&gt;&lt;br&gt;There are other problems as well. Suppose that S24_Map[i,j,1] = 1
&lt;br&gt;(initial bit is 1). &amp;nbsp;Then run[i,j,1] = 1, which means runlength &amp;lt;= 1.
&lt;br&gt;&lt;br&gt;Your definition of run[,,] is ok. &amp;nbsp;What you need to do is constrain
&lt;br&gt;runlength &amp;lt;= run[i,j,k] only when S24_Map[i,j,k] = 1 and S24_Map[i,j,k
&lt;br&gt;+1] = 0 (or does not exist because k is at its largest possible
&lt;br&gt;value). &amp;nbsp;In other words, runlength needs to be limited only by the
&lt;br&gt;cumulative run length at a bit that marks the end of a run.
&lt;br&gt;&lt;br&gt;/Paul
&lt;br&gt;&lt;br&gt;--
&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26461298&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26461298&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/calculating-runlength-tp26371837p26461298.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26480050</id>
	<title>Re: [AMPL 3033] Re: calculating runlength</title>
	<published>2009-11-21T09:50:22Z</published>
	<updated>2009-11-21T09:50:22Z</updated>
	<author>
		<name>abusufiyan p ..</name>
	</author>
	<content type="html">mr: saqib,i would like to more information about lenear programming problem&lt;br&gt;&lt;br&gt;
&lt;div&gt;&lt;span class=&quot;gmail_quote&quot;&gt;On 11/21/09, &lt;b class=&quot;gmail_sendername&quot;&gt;Saqib Ilyas&lt;/b&gt; &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26480050&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;msaqib@...&lt;/a&gt;&amp;gt; wrote:&lt;/span&gt;
&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid&quot;&gt;
&lt;div&gt;Firstly, thanks for your reply and taking out time for this implementation. Paul, I would love an integer linear problem. Thanks for your clever linearization of the model. I spent some time trying to digest it and implement it in my model. The model is slightly different from what you&amp;#39;ve interpreted. &lt;/div&gt;

&lt;div&gt;First, I am (now) interested in the number of consecutive 1s. That is 1100011010 has three runs of length 2, 2, and 1 respectively, whereas 00111100 has one run of length 4. Secondly, I am interested in constraining the length of the smallest runs. I tried to adapt your approach to my problem and implemented the following (Yea, well, I had some 3 dimensional variables and didn&amp;#39;t want to make any mistakes while trying to adapt it for posting on the lsit):&lt;/div&gt;

&lt;div&gt; &lt;/div&gt;
&lt;div&gt;var runlength integer &amp;gt;= 0;&lt;/div&gt;
&lt;div&gt;var z {COMP_TIMES} binary;&lt;/div&gt;
&lt;div&gt;var run{S24s, LOCATIONS, COMP_TIMES} &amp;lt;= LENGTH + 1;&lt;/div&gt;
&lt;div&gt;var S24_Map{S24s, j in LOCATIONS, COMP_TIMES} binary ;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;subject to runlength1 {i in S24s, j in LOCATIONS, k in COMP_TIMES: k &amp;gt; 1}: run[i, j, k] &amp;lt;= run[i, j, k-1] + 1;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;subject to runlength2 {i in S24s, j in LOCATIONS, k in COMP_TIMES: k &amp;gt; 1}: run[i, j, k] &amp;gt;= run[i, j, k-1] + 1 - LENGTH * (1 - S24_Map[i, j, k-1]);&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;subject to runlength3{i in S24s, j in LOCATIONS}: run[i, j, 1] = 1 - LENGTH*(1-S24_Map[i, j, 1]);&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;subject to PickOne: sum{i in COMP_TIMES} z[i] &amp;lt;= 1;&lt;/div&gt;
&lt;div&gt;subject to MinCondition{i in S24s, j in LOCATIONS, k in COMP_TIMES}: runlength &amp;lt;= run[i, j, k];&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;subject to Limit{i in S24s, j in LOCATIONS, k in COMP_TIMES}: runlength &amp;lt;= run[i, j, k] + LENGTH*(1-run[i, j, k]);&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;#subject to MinRun: runlength &amp;gt;= 2;&lt;br&gt;&lt;br&gt;I&amp;#39;ve still got the run length constraint commented out and yet the problem doesn&amp;#39;t seem to be solvable and I get impossible deduced bounds in presolve. Given my modified requirements, is there some error in the above constraints that you can see? Otherwise, I can post the complete model and data files for you and others to run and try.&lt;/div&gt;

&lt;div&gt;&lt;span class=&quot;e&quot; id=&quot;q_125166ce79936e8a_1&quot;&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div class=&quot;gmail_quote&quot;&gt;On Thu, Nov 19, 2009 at 5:27 AM, Paul &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26480050&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;rubin@...&lt;/a&gt;&amp;gt;&lt;/span&gt; wrote:&lt;br&gt;

&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid&quot;&gt;You haven&amp;#39;t specified whether your model is linear or not, so I&amp;#39;m&lt;br&gt;going to assume it&amp;#39;s an integer linear program.  I&amp;#39;m inferring from&lt;br&gt;
your examples that (a) the length of a run includes the bounding 1&lt;br&gt;bits (e.g., 1001 is a run of length 4) and (b) when you refer to the&lt;br&gt;run length of a bit sequence you mean the length of the longest run in&lt;br&gt;the sequence.  That leaves open the question of whether a bit sequence&lt;br&gt;
that starts/ends with a zero has an initial/final run (i.e., is there&lt;br&gt;an implicit one before/after a sequence).  For instance, would 000000&lt;br&gt;be considered a single run of six zeros or considered to have no runs&lt;br&gt;at all?&lt;br&gt;
&lt;br&gt;Assuming you want a linear model and there must be an explicit one bit&lt;br&gt;at each end of a run, something like the following might work.  I&lt;br&gt;won&amp;#39;t swear it&amp;#39;s the most efficient possible formulation, though.  I&amp;#39;m&lt;br&gt;
adopting the convention that no runs equates to run length 0.&lt;br&gt;&lt;br&gt;param LENGTH integer &amp;gt; 0;  # length of a bit sequence -- I assume they&lt;br&gt;all have the same length&lt;br&gt;set POSITION := 1..LENGTH;  # index set&lt;br&gt;var bit {POSITION} binary;   # variables that will yield a bit&lt;br&gt;
sequence&lt;br&gt;var runlength integer &amp;gt;= 0;  # maximum run length&lt;br&gt;var r {POSITION};  # helper variable that maps each bit to the length&lt;br&gt;of the run containing it -- NOT nonnegative and not explicitly&lt;br&gt;declared integer&lt;br&gt;
var y {POSITION} binary;  # helper variable that maps a bit to 0 if it&lt;br&gt;is part of an ongoing run and 1 if not&lt;br&gt;var z {POSITION} binary;  # helper variable that points to the end bit&lt;br&gt;of the longest run&lt;br&gt;&lt;br&gt;# the next three constraints determine y&lt;br&gt;
s.t. Ongoing1 {k in POSITION : k &amp;gt; 1}: y[k] &amp;gt;= bit[k-1] + bit[k] - 1;&lt;br&gt;s.t. Ongoing2 {k in POSITION : k &amp;gt; 1}: 2*y[k] &amp;lt;= bit[k-1] + bit[k];&lt;br&gt;s.t. Start: y[1] = 0;  # the first bit cannot be part of an &amp;quot;ongoing&amp;quot;&lt;br&gt;
run (it could start one)&lt;br&gt;# if bit[k] and bit[k-1] are both 1, y[k] = 1; otherwise y[k] = 0&lt;br&gt;&lt;br&gt;# the following constraints compute the length of any ongoing run at&lt;br&gt;each position&lt;br&gt;s.t. RunUpperLimit {k in POSITION}: r[k] &amp;lt;= r[k-1] + 1;  # run length&lt;br&gt;
increases at most 1 as you advance one bit&lt;br&gt;s.t. InRun1 {k in POSITION : k &amp;gt; 1}: r[k] &amp;gt;= r[k-1] + 1 - LENGTH*y&lt;br&gt;[k];  # if y[k] = 0 (position k is part of a run), r[k] must equal r&lt;br&gt;[k-1] + 1&lt;br&gt;s.t. InRun2 {k in POSITION : k &amp;gt; 1}: r[k] &amp;lt;= 1 + LENGTH*(1 - y[k]);  #&lt;br&gt;
if y[k] = 0 (position k is part of a run), this is vacuous; otherwise&lt;br&gt;it forces r[k] &amp;lt;= 1 (bit[k] could be the initial 1 of a run, or it&lt;br&gt;could be part of a non-run)&lt;br&gt;s.t. InitLength: r[1] = 1 - LENGTH*(1-bit[1]);  # if bit[1] = 1, r[1]&lt;br&gt;
= 1; otherwise r[1] is negative (sequence starts with 0, so the&lt;br&gt;initial &amp;quot;run&amp;quot; doesn&amp;#39;t count)&lt;br&gt;&lt;br&gt;# the next constraint says we&amp;#39;ll select at most a single bit position&lt;br&gt;as the terminus of the maximum run&lt;br&gt;
s.t. PickOne: sum {k in POSIITION} z[k] &amp;lt;= 1;  # the sum is zero --&lt;br&gt;all z[k] are 0 -- iff there is no run&lt;br&gt;&lt;br&gt;# finally, we need constraints to define the maximum run length&lt;br&gt;s.t. MaxCondition {k in POSITION}: runlength &amp;gt;= r[k];  # the run&lt;br&gt;
length is at least as large as the ongoing run length at every&lt;br&gt;position&lt;br&gt;s.t. Limit {k in POSITION}: runlength &amp;lt;= r[k] + LENGTH*(1 - z[k]);  #&lt;br&gt;limits the runlength to r[k] if k is the position that terminates the&lt;br&gt;
longest run&lt;br&gt;&lt;br&gt;You really need to check that mess; it&amp;#39;s not beyond the bounds of&lt;br&gt;possibility that I booted something.&lt;br&gt;&lt;font color=&quot;#888888&quot;&gt;&lt;br&gt;/Paul&lt;br&gt;&lt;/font&gt;
&lt;div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;msaqib wrote:&lt;br&gt;&amp;gt; My case is &amp;quot;c&amp;quot;, the bits are model variables and the run length should be&lt;br&gt;&amp;gt; computed and it factors in the objective function.&lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt; Paul-432 wrote:&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;&amp;gt; &amp;gt; I can interpret this three different ways:&lt;br&gt;&amp;gt; &amp;gt;&lt;br&gt;&amp;gt; &amp;gt; a) the bits are parameters of the model;&lt;br&gt;&amp;gt; &amp;gt; b) the bits are model variables (unknown when the model is&lt;br&gt;&amp;gt; &amp;gt; formulated), and you need to compute the run length of the final&lt;br&gt;
&amp;gt; &amp;gt; solution after the solution is obtained; or&lt;br&gt;&amp;gt; &amp;gt; c) the bits are model variables and so is the run length, and the run&lt;br&gt;&amp;gt; &amp;gt; length is used within the model.&lt;br&gt;&amp;gt; &amp;gt;&lt;br&gt;&amp;gt; &amp;gt; The first two can be handled by looping; the third requires additional&lt;br&gt;
&amp;gt; &amp;gt; model constructs (constraints and probability some auxiliary&lt;br&gt;&amp;gt; &amp;gt; variables).&lt;br&gt;&amp;gt; &amp;gt;&lt;br&gt;&amp;gt; &amp;gt; /Paul&lt;br&gt;&amp;gt; &amp;gt;&lt;br&gt;&amp;gt; &amp;gt; On Nov 16, 8:24 am, msaqib &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26480050&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;msa...@...&lt;/a&gt;&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; Hi all&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; In a model, I need to calculate the runlength of a sequence of binary&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; (0/1)&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; numbers. In other words, I need to count the number of zeros between a&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; pair&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; of ones. For example, the runlength in 0010001110010 is 5, and that for&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; 0010000110010 is 6. I&amp;#39;m not sure how to represent this mathematically in&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; an&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; AMPL model. We typically do this iteratively in other programming&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; languages.&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; Any clues?&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; Thanks and best regards&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; --&lt;br&gt;&amp;gt; &amp;gt;&lt;br&gt;&amp;gt; --&lt;br&gt;
&amp;gt; View this message in context: &lt;a href=&quot;http://old.nabble.com/calculating-runlength-tp26371837p26385781.html&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://old.nabble.com/calculating-runlength-tp26371837p26385781.html&lt;/a&gt;&lt;br&gt;
&amp;gt; Sent from the AMPL mailing list archive at Nabble.com.&lt;br&gt;&lt;br&gt;--&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26480050&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.&lt;br&gt;
To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26480050&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl%2Bunsubscribe@...&lt;/a&gt;.&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;&lt;br&gt; &lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;br clear=&quot;all&quot;&gt;&lt;br&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;sg&quot;&gt;-- &lt;br&gt;Muhammad Saqib Ilyas&lt;br&gt;PhD Student, Computer Science and Engineering&lt;br&gt;Lahore University of Management Sciences&lt;/span&gt; 
&lt;div&gt;&lt;span class=&quot;e&quot; id=&quot;q_125166ce79936e8a_3&quot;&gt;&lt;br&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;--&lt;/p&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26480050&amp;i=5&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.&lt;br&gt;
To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26480050&amp;i=6&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl%2Bunsubscribe@...&lt;/a&gt;.&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.&lt;br&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;--&lt;/p&gt;

You received this message because you are subscribed to the Google Groups &quot;AMPL Modeling Language&quot; group.&lt;br /&gt;

To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26480050&amp;i=7&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.&lt;br /&gt;

To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26480050&amp;i=8&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.&lt;br /&gt;

For more options, visit this group at http://groups.google.com/group/ampl?hl=.&lt;br /&gt;

</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/calculating-runlength-tp26371837p26480050.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26455500</id>
	<title>Re: [AMPL 3031] Re: calculating runlength</title>
	<published>2009-11-21T03:07:30Z</published>
	<updated>2009-11-21T03:07:30Z</updated>
	<author>
		<name>msaqib</name>
	</author>
	<content type="html">&lt;div&gt;Firstly, thanks for your reply and taking out time for this implementation. Paul, I would love an integer linear problem. Thanks for your clever linearization of the model. I spent some time trying to digest it and implement it in my model. The model is slightly different from what you&amp;#39;ve interpreted. &lt;/div&gt;

&lt;div&gt;First, I am (now) interested in the number of consecutive 1s. That is 1100011010 has three runs of length 2, 2, and 1 respectively, whereas 00111100 has one run of length 4. Secondly, I am interested in constraining the length of the smallest runs. I tried to adapt your approach to my problem and implemented the following (Yea, well, I had some 3 dimensional variables and didn&amp;#39;t want to make any mistakes while trying to adapt it for posting on the lsit):&lt;/div&gt;

&lt;div&gt; &lt;/div&gt;
&lt;div&gt;var runlength integer &amp;gt;= 0;&lt;/div&gt;
&lt;div&gt;var z {COMP_TIMES} binary;&lt;/div&gt;
&lt;div&gt;var run{S24s, LOCATIONS, COMP_TIMES} &amp;lt;= LENGTH + 1;&lt;/div&gt;
&lt;div&gt;var S24_Map{S24s, j in LOCATIONS, COMP_TIMES} binary ;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;subject to runlength1 {i in S24s, j in LOCATIONS, k in COMP_TIMES: k &amp;gt; 1}: run[i, j, k] &amp;lt;= run[i, j, k-1] + 1;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;subject to runlength2 {i in S24s, j in LOCATIONS, k in COMP_TIMES: k &amp;gt; 1}: run[i, j, k] &amp;gt;= run[i, j, k-1] + 1 - LENGTH * (1 - S24_Map[i, j, k-1]);&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;subject to runlength3{i in S24s, j in LOCATIONS}: run[i, j, 1] = 1 - LENGTH*(1-S24_Map[i, j, 1]);&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;subject to PickOne: sum{i in COMP_TIMES} z[i] &amp;lt;= 1;&lt;/div&gt;
&lt;div&gt;subject to MinCondition{i in S24s, j in LOCATIONS, k in COMP_TIMES}: runlength &amp;lt;= run[i, j, k];&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;subject to Limit{i in S24s, j in LOCATIONS, k in COMP_TIMES}: runlength &amp;lt;= run[i, j, k] + LENGTH*(1-run[i, j, k]);&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;#subject to MinRun: runlength &amp;gt;= 2;&lt;br&gt;&lt;br&gt;I&amp;#39;ve still got the run length constraint commented out and yet the problem doesn&amp;#39;t seem to be solvable and I get impossible deduced bounds in presolve. Given my modified requirements, is there some error in the above constraints that you can see? Otherwise, I can post the complete model and data files for you and others to run and try.&lt;/div&gt;

&lt;div&gt; &lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div class=&quot;gmail_quote&quot;&gt;On Thu, Nov 19, 2009 at 5:27 AM, Paul &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26455500&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;rubin@...&lt;/a&gt;&amp;gt;&lt;/span&gt; wrote:&lt;br&gt;
&lt;blockquote style=&quot;BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex&quot; class=&quot;gmail_quote&quot;&gt;You haven&amp;#39;t specified whether your model is linear or not, so I&amp;#39;m&lt;br&gt;going to assume it&amp;#39;s an integer linear program.  I&amp;#39;m inferring from&lt;br&gt;
your examples that (a) the length of a run includes the bounding 1&lt;br&gt;bits (e.g., 1001 is a run of length 4) and (b) when you refer to the&lt;br&gt;run length of a bit sequence you mean the length of the longest run in&lt;br&gt;the sequence.  That leaves open the question of whether a bit sequence&lt;br&gt;
that starts/ends with a zero has an initial/final run (i.e., is there&lt;br&gt;an implicit one before/after a sequence).  For instance, would 000000&lt;br&gt;be considered a single run of six zeros or considered to have no runs&lt;br&gt;at all?&lt;br&gt;
&lt;br&gt;Assuming you want a linear model and there must be an explicit one bit&lt;br&gt;at each end of a run, something like the following might work.  I&lt;br&gt;won&amp;#39;t swear it&amp;#39;s the most efficient possible formulation, though.  I&amp;#39;m&lt;br&gt;
adopting the convention that no runs equates to run length 0.&lt;br&gt;&lt;br&gt;param LENGTH integer &amp;gt; 0;  # length of a bit sequence -- I assume they&lt;br&gt;all have the same length&lt;br&gt;set POSITION := 1..LENGTH;  # index set&lt;br&gt;var bit {POSITION} binary;   # variables that will yield a bit&lt;br&gt;
sequence&lt;br&gt;var runlength integer &amp;gt;= 0;  # maximum run length&lt;br&gt;var r {POSITION};  # helper variable that maps each bit to the length&lt;br&gt;of the run containing it -- NOT nonnegative and not explicitly&lt;br&gt;declared integer&lt;br&gt;
var y {POSITION} binary;  # helper variable that maps a bit to 0 if it&lt;br&gt;is part of an ongoing run and 1 if not&lt;br&gt;var z {POSITION} binary;  # helper variable that points to the end bit&lt;br&gt;of the longest run&lt;br&gt;&lt;br&gt;# the next three constraints determine y&lt;br&gt;
s.t. Ongoing1 {k in POSITION : k &amp;gt; 1}: y[k] &amp;gt;= bit[k-1] + bit[k] - 1;&lt;br&gt;s.t. Ongoing2 {k in POSITION : k &amp;gt; 1}: 2*y[k] &amp;lt;= bit[k-1] + bit[k];&lt;br&gt;s.t. Start: y[1] = 0;  # the first bit cannot be part of an &amp;quot;ongoing&amp;quot;&lt;br&gt;
run (it could start one)&lt;br&gt;# if bit[k] and bit[k-1] are both 1, y[k] = 1; otherwise y[k] = 0&lt;br&gt;&lt;br&gt;# the following constraints compute the length of any ongoing run at&lt;br&gt;each position&lt;br&gt;s.t. RunUpperLimit {k in POSITION}: r[k] &amp;lt;= r[k-1] + 1;  # run length&lt;br&gt;
increases at most 1 as you advance one bit&lt;br&gt;s.t. InRun1 {k in POSITION : k &amp;gt; 1}: r[k] &amp;gt;= r[k-1] + 1 - LENGTH*y&lt;br&gt;[k];  # if y[k] = 0 (position k is part of a run), r[k] must equal r&lt;br&gt;[k-1] + 1&lt;br&gt;s.t. InRun2 {k in POSITION : k &amp;gt; 1}: r[k] &amp;lt;= 1 + LENGTH*(1 - y[k]);  #&lt;br&gt;
if y[k] = 0 (position k is part of a run), this is vacuous; otherwise&lt;br&gt;it forces r[k] &amp;lt;= 1 (bit[k] could be the initial 1 of a run, or it&lt;br&gt;could be part of a non-run)&lt;br&gt;s.t. InitLength: r[1] = 1 - LENGTH*(1-bit[1]);  # if bit[1] = 1, r[1]&lt;br&gt;
= 1; otherwise r[1] is negative (sequence starts with 0, so the&lt;br&gt;initial &amp;quot;run&amp;quot; doesn&amp;#39;t count)&lt;br&gt;&lt;br&gt;# the next constraint says we&amp;#39;ll select at most a single bit position&lt;br&gt;as the terminus of the maximum run&lt;br&gt;
s.t. PickOne: sum {k in POSIITION} z[k] &amp;lt;= 1;  # the sum is zero --&lt;br&gt;all z[k] are 0 -- iff there is no run&lt;br&gt;&lt;br&gt;# finally, we need constraints to define the maximum run length&lt;br&gt;s.t. MaxCondition {k in POSITION}: runlength &amp;gt;= r[k];  # the run&lt;br&gt;
length is at least as large as the ongoing run length at every&lt;br&gt;position&lt;br&gt;s.t. Limit {k in POSITION}: runlength &amp;lt;= r[k] + LENGTH*(1 - z[k]);  #&lt;br&gt;limits the runlength to r[k] if k is the position that terminates the&lt;br&gt;
longest run&lt;br&gt;&lt;br&gt;You really need to check that mess; it&amp;#39;s not beyond the bounds of&lt;br&gt;possibility that I booted something.&lt;br&gt;&lt;font color=&quot;#888888&quot;&gt;&lt;br&gt;/Paul&lt;br&gt;&lt;/font&gt;
&lt;div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div class=&quot;h5&quot;&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;msaqib wrote:&lt;br&gt;&amp;gt; My case is &amp;quot;c&amp;quot;, the bits are model variables and the run length should be&lt;br&gt;&amp;gt; computed and it factors in the objective function.&lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt; Paul-432 wrote:&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;&amp;gt; &amp;gt; I can interpret this three different ways:&lt;br&gt;&amp;gt; &amp;gt;&lt;br&gt;&amp;gt; &amp;gt; a) the bits are parameters of the model;&lt;br&gt;&amp;gt; &amp;gt; b) the bits are model variables (unknown when the model is&lt;br&gt;&amp;gt; &amp;gt; formulated), and you need to compute the run length of the final&lt;br&gt;
&amp;gt; &amp;gt; solution after the solution is obtained; or&lt;br&gt;&amp;gt; &amp;gt; c) the bits are model variables and so is the run length, and the run&lt;br&gt;&amp;gt; &amp;gt; length is used within the model.&lt;br&gt;&amp;gt; &amp;gt;&lt;br&gt;&amp;gt; &amp;gt; The first two can be handled by looping; the third requires additional&lt;br&gt;
&amp;gt; &amp;gt; model constructs (constraints and probability some auxiliary&lt;br&gt;&amp;gt; &amp;gt; variables).&lt;br&gt;&amp;gt; &amp;gt;&lt;br&gt;&amp;gt; &amp;gt; /Paul&lt;br&gt;&amp;gt; &amp;gt;&lt;br&gt;&amp;gt; &amp;gt; On Nov 16, 8:24 am, msaqib &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26455500&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;msa...@...&lt;/a&gt;&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; Hi all&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; In a model, I need to calculate the runlength of a sequence of binary&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; (0/1)&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; numbers. In other words, I need to count the number of zeros between a&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; pair&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; of ones. For example, the runlength in 0010001110010 is 5, and that for&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; 0010000110010 is 6. I&amp;#39;m not sure how to represent this mathematically in&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; an&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; AMPL model. We typically do this iteratively in other programming&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; languages.&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; Any clues?&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; Thanks and best regards&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; --&lt;br&gt;&amp;gt; &amp;gt;&lt;br&gt;&amp;gt; --&lt;br&gt;
&amp;gt; View this message in context: &lt;a href=&quot;http://old.nabble.com/calculating-runlength-tp26371837p26385781.html&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://old.nabble.com/calculating-runlength-tp26371837p26385781.html&lt;/a&gt;&lt;br&gt;&amp;gt; Sent from the AMPL mailing list archive at Nabble.com.&lt;br&gt;
&lt;br&gt;--&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26455500&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.&lt;br&gt;
To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26455500&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl%2Bunsubscribe@...&lt;/a&gt;.&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;br clear=&quot;all&quot;&gt;&lt;br&gt;-- &lt;br&gt;Muhammad Saqib Ilyas&lt;br&gt;PhD Student, Computer Science and Engineering&lt;br&gt;Lahore University of Management Sciences&lt;br&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;--&lt;/p&gt;

You received this message because you are subscribed to the Google Groups &quot;AMPL Modeling Language&quot; group.&lt;br /&gt;

To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26455500&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.&lt;br /&gt;

To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26455500&amp;i=5&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.&lt;br /&gt;

For more options, visit this group at http://groups.google.com/group/ampl?hl=.&lt;br /&gt;

</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/calculating-runlength-tp26371837p26455500.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26444706</id>
	<title>[AMPL 3030] save the current B&amp;C tree in AMPL 10</title>
	<published>2009-11-20T06:57:11Z</published>
	<updated>2009-11-20T06:57:11Z</updated>
	<author>
		<name>Lei-5</name>
	</author>
	<content type="html">Is it possible in AMPL 10 that one can save the MIP &amp;nbsp;B&amp;C tree to a
&lt;br&gt;file so that later on the search can start from that status??? &amp;nbsp;It
&lt;br&gt;would be really nice if someone can help. It is also helpful if anyone
&lt;br&gt;knows how to do it in cplex 10.
&lt;br&gt;&lt;br&gt;Thanks,
&lt;br&gt;&lt;br&gt;/Lei
&lt;br&gt;&lt;br&gt;--
&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26444706&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26444706&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/-AMPL-3030--save-the-current-B-C-tree-in-AMPL-10-tp26444706p26444706.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26432485</id>
	<title>RE: [AMPL 3029] Remove/reset table in ODBC</title>
	<published>2009-11-19T11:24:52Z</published>
	<updated>2009-11-19T11:24:52Z</updated>
	<author>
		<name>Robert Fourer-2</name>
	</author>
	<content type="html">&lt;br&gt;The command &amp;quot;delete table example;&amp;quot; will remove the table definition, after
&lt;br&gt;which you can declare a different table with the same name.
&lt;br&gt;&lt;br&gt;Bob Fourer
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26432485&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;4er@...&lt;/a&gt;
&lt;br&gt;&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; -----Original Message-----
&lt;br&gt;&amp;gt; From: Ziming Guan [mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26432485&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;z.guan@...&lt;/a&gt;]
&lt;br&gt;&amp;gt; Sent: Wednesday, November 18, 2009 1:00 PM
&lt;br&gt;&amp;gt; To: &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26432485&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;
&lt;br&gt;&amp;gt; Subject: [AMPL 3026] Remove/reset table in ODBC
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Hi,
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I declare a table using ODBC to write data from spreadsheet, for example,
&lt;br&gt;&amp;gt; as
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; table &amp;nbsp; example &amp;nbsp; OUT &amp;nbsp; &amp;quot;ODBC&amp;quot; &amp;nbsp; &amp;quot;example.xls&amp;quot; &amp;nbsp; &amp;quot;example&amp;quot; :
&lt;br&gt;&amp;gt; {t in 1..T} -&amp;gt; [Stage],
&lt;br&gt;&amp;gt; {r in RES} &amp;lt;beta[r,t] ~ (r)&amp;gt;
&lt;br&gt;&amp;gt; ;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Then later I want to remove or reset this table and then declare a table
&lt;br&gt;&amp;gt; with the same name as
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; table &amp;nbsp; example &amp;nbsp; OUT &amp;nbsp; &amp;quot;ODBC&amp;quot; &amp;nbsp; &amp;quot;example.xls&amp;quot; &amp;nbsp; &amp;quot;example&amp;quot; :
&lt;br&gt;&amp;gt; {t in 1..T} -&amp;gt; [Stage],
&lt;br&gt;&amp;gt; {r in RESALL} &amp;lt;beta[r,t] ~ (r)&amp;gt;
&lt;br&gt;&amp;gt; ;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; What are the commands to remove or reset a table in ODBC? Or is there
&lt;br&gt;&amp;gt; another way to do this?
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Thank you,
&lt;br&gt;&amp;gt; Ziming
&lt;br&gt;&amp;gt; 
&lt;/div&gt;&lt;br&gt;&lt;br&gt;--
&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26432485&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26432485&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/-AMPL-3026--Remove-reset-table-in-ODBC-tp26413641p26432485.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26419315</id>
	<title>[AMPL 3028] Remove/reset table in ODBC</title>
	<published>2009-11-18T18:17:21Z</published>
	<updated>2009-11-18T18:17:21Z</updated>
	<author>
		<name>chandrashekar.tallichetty</name>
	</author>
	<content type="html">Return Receipt
&lt;br&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; &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;br&gt;&amp;nbsp; &amp;nbsp;Your &amp;nbsp; &amp;nbsp; &amp;nbsp; [AMPL 3026] Remove/reset table in ODBC &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; &amp;nbsp;document: &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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&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; &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;br&gt;&amp;nbsp; &amp;nbsp;was &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Chandrashekar S Tallichetty/IN/GM/GMC &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;br&gt;&amp;nbsp; &amp;nbsp;received &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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
&lt;br&gt;&amp;nbsp; &amp;nbsp;by: &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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&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; &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;br&gt;&amp;nbsp; &amp;nbsp;at: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;11/19/2009 07:47:24 AM &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;br&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; &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;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Nothing in this message is intended to constitute an electronic signature unless a specific statement to the contrary is included in this message. 
&lt;br&gt;&lt;br&gt;Confidentiality Note: This message is intended only for the person or entity to which it is addressed. It may contain confidential and/or privileged material. &amp;nbsp;Any review, transmission, dissemination or other use, or taking of any action in reliance upon this message by persons or entities other than the intended recipient is prohibited and may be unlawful. If you received this message in error, please contact the sender and delete it from your computer.
&lt;br&gt;&lt;br&gt;--
&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26419315&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26419315&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/-AMPL-3028--Remove-reset-table-in-ODBC-tp26419315p26419315.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26418337</id>
	<title>Re: [AMPL 3027] Re: calculating runlength</title>
	<published>2009-11-18T16:27:32Z</published>
	<updated>2009-11-18T16:27:32Z</updated>
	<author>
		<name>Paul-432</name>
	</author>
	<content type="html">You haven't specified whether your model is linear or not, so I'm
&lt;br&gt;going to assume it's an integer linear program. &amp;nbsp;I'm inferring from
&lt;br&gt;your examples that (a) the length of a run includes the bounding 1
&lt;br&gt;bits (e.g., 1001 is a run of length 4) and (b) when you refer to the
&lt;br&gt;run length of a bit sequence you mean the length of the longest run in
&lt;br&gt;the sequence. &amp;nbsp;That leaves open the question of whether a bit sequence
&lt;br&gt;that starts/ends with a zero has an initial/final run (i.e., is there
&lt;br&gt;an implicit one before/after a sequence). &amp;nbsp;For instance, would 000000
&lt;br&gt;be considered a single run of six zeros or considered to have no runs
&lt;br&gt;at all?
&lt;br&gt;&lt;br&gt;Assuming you want a linear model and there must be an explicit one bit
&lt;br&gt;at each end of a run, something like the following might work. &amp;nbsp;I
&lt;br&gt;won't swear it's the most efficient possible formulation, though. &amp;nbsp;I'm
&lt;br&gt;adopting the convention that no runs equates to run length 0.
&lt;br&gt;&lt;br&gt;param LENGTH integer &amp;gt; 0; &amp;nbsp;# length of a bit sequence -- I assume they
&lt;br&gt;all have the same length
&lt;br&gt;set POSITION := 1..LENGTH; &amp;nbsp;# index set
&lt;br&gt;var bit {POSITION} binary; &amp;nbsp; # variables that will yield a bit
&lt;br&gt;sequence
&lt;br&gt;var runlength integer &amp;gt;= 0; &amp;nbsp;# maximum run length
&lt;br&gt;var r {POSITION}; &amp;nbsp;# helper variable that maps each bit to the length
&lt;br&gt;of the run containing it -- NOT nonnegative and not explicitly
&lt;br&gt;declared integer
&lt;br&gt;var y {POSITION} binary; &amp;nbsp;# helper variable that maps a bit to 0 if it
&lt;br&gt;is part of an ongoing run and 1 if not
&lt;br&gt;var z {POSITION} binary; &amp;nbsp;# helper variable that points to the end bit
&lt;br&gt;of the longest run
&lt;br&gt;&lt;br&gt;# the next three constraints determine y
&lt;br&gt;s.t. Ongoing1 {k in POSITION : k &amp;gt; 1}: y[k] &amp;gt;= bit[k-1] + bit[k] - 1;
&lt;br&gt;s.t. Ongoing2 {k in POSITION : k &amp;gt; 1}: 2*y[k] &amp;lt;= bit[k-1] + bit[k];
&lt;br&gt;s.t. Start: y[1] = 0; &amp;nbsp;# the first bit cannot be part of an &amp;quot;ongoing&amp;quot;
&lt;br&gt;run (it could start one)
&lt;br&gt;# if bit[k] and bit[k-1] are both 1, y[k] = 1; otherwise y[k] = 0
&lt;br&gt;&lt;br&gt;# the following constraints compute the length of any ongoing run at
&lt;br&gt;each position
&lt;br&gt;s.t. RunUpperLimit {k in POSITION}: r[k] &amp;lt;= r[k-1] + 1; &amp;nbsp;# run length
&lt;br&gt;increases at most 1 as you advance one bit
&lt;br&gt;s.t. InRun1 {k in POSITION : k &amp;gt; 1}: r[k] &amp;gt;= r[k-1] + 1 - LENGTH*y
&lt;br&gt;[k]; &amp;nbsp;# if y[k] = 0 (position k is part of a run), r[k] must equal r
&lt;br&gt;[k-1] + 1
&lt;br&gt;s.t. InRun2 {k in POSITION : k &amp;gt; 1}: r[k] &amp;lt;= 1 + LENGTH*(1 - y[k]); &amp;nbsp;#
&lt;br&gt;if y[k] = 0 (position k is part of a run), this is vacuous; otherwise
&lt;br&gt;it forces r[k] &amp;lt;= 1 (bit[k] could be the initial 1 of a run, or it
&lt;br&gt;could be part of a non-run)
&lt;br&gt;s.t. InitLength: r[1] = 1 - LENGTH*(1-bit[1]); &amp;nbsp;# if bit[1] = 1, r[1]
&lt;br&gt;= 1; otherwise r[1] is negative (sequence starts with 0, so the
&lt;br&gt;initial &amp;quot;run&amp;quot; doesn't count)
&lt;br&gt;&lt;br&gt;# the next constraint says we'll select at most a single bit position
&lt;br&gt;as the terminus of the maximum run
&lt;br&gt;s.t. PickOne: sum {k in POSIITION} z[k] &amp;lt;= 1; &amp;nbsp;# the sum is zero --
&lt;br&gt;all z[k] are 0 -- iff there is no run
&lt;br&gt;&lt;br&gt;# finally, we need constraints to define the maximum run length
&lt;br&gt;s.t. MaxCondition {k in POSITION}: runlength &amp;gt;= r[k]; &amp;nbsp;# the run
&lt;br&gt;length is at least as large as the ongoing run length at every
&lt;br&gt;position
&lt;br&gt;s.t. Limit {k in POSITION}: runlength &amp;lt;= r[k] + LENGTH*(1 - z[k]); &amp;nbsp;#
&lt;br&gt;limits the runlength to r[k] if k is the position that terminates the
&lt;br&gt;longest run
&lt;br&gt;&lt;br&gt;You really need to check that mess; it's not beyond the bounds of
&lt;br&gt;possibility that I booted something.
&lt;br&gt;&lt;br&gt;/Paul
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;msaqib wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; My case is &amp;quot;c&amp;quot;, the bits are model variables and the run length should be
&lt;br&gt;&amp;gt; computed and it factors in the objective function.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Paul-432 wrote:
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; I can interpret this three different ways:
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; a) the bits are parameters of the model;
&lt;br&gt;&amp;gt; &amp;gt; b) the bits are model variables (unknown when the model is
&lt;br&gt;&amp;gt; &amp;gt; formulated), and you need to compute the run length of the final
&lt;br&gt;&amp;gt; &amp;gt; solution after the solution is obtained; or
&lt;br&gt;&amp;gt; &amp;gt; c) the bits are model variables and so is the run length, and the run
&lt;br&gt;&amp;gt; &amp;gt; length is used within the model.
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; The first two can be handled by looping; the third requires additional
&lt;br&gt;&amp;gt; &amp;gt; model constructs (constraints and probability some auxiliary
&lt;br&gt;&amp;gt; &amp;gt; variables).
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; /Paul
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; On Nov 16, 8:24 am, msaqib &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26418337&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;msa...@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; Hi all
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; In a model, I need to calculate the runlength of a sequence of binary
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; (0/1)
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; numbers. In other words, I need to count the number of zeros between a
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; pair
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; of ones. For example, the runlength in 0010001110010 is 5, and that for
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; 0010000110010 is 6. I'm not sure how to represent this mathematically in
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; an
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; AMPL model. We typically do this iteratively in other programming
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; languages.
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; Any clues?
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; Thanks and best regards
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; --
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; View this message in context: &lt;a href=&quot;http://old.nabble.com/calculating-runlength-tp26371837p26385781.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://old.nabble.com/calculating-runlength-tp26371837p26385781.html&lt;/a&gt;&lt;br&gt;&amp;gt; Sent from the AMPL mailing list archive at Nabble.com.
&lt;/div&gt;&lt;br&gt;--
&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26418337&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26418337&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/calculating-runlength-tp26371837p26418337.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26413641</id>
	<title>[AMPL 3026] Remove/reset table in ODBC</title>
	<published>2009-11-18T10:59:32Z</published>
	<updated>2009-11-18T10:59:32Z</updated>
	<author>
		<name>ziming guan</name>
	</author>
	<content type="html">Hi,
&lt;br&gt;&lt;br&gt;I declare a table using ODBC to write data from spreadsheet, for example, as
&lt;br&gt;&lt;br&gt;table &amp;nbsp; example &amp;nbsp; OUT &amp;nbsp; &amp;quot;ODBC&amp;quot; &amp;nbsp; &amp;quot;example.xls&amp;quot; &amp;nbsp; &amp;quot;example&amp;quot; :
&lt;br&gt;{t in 1..T} -&amp;gt; [Stage], 
&lt;br&gt;{r in RES} &amp;lt;beta[r,t] ~ (r)&amp;gt;
&lt;br&gt;;
&lt;br&gt;&lt;br&gt;Then later I want to remove or reset this table and then declare a table 
&lt;br&gt;with the same name as
&lt;br&gt;&lt;br&gt;table &amp;nbsp; example &amp;nbsp; OUT &amp;nbsp; &amp;quot;ODBC&amp;quot; &amp;nbsp; &amp;quot;example.xls&amp;quot; &amp;nbsp; &amp;quot;example&amp;quot; :
&lt;br&gt;{t in 1..T} -&amp;gt; [Stage], 
&lt;br&gt;{r in RESALL} &amp;lt;beta[r,t] ~ (r)&amp;gt;
&lt;br&gt;;
&lt;br&gt;&lt;br&gt;What are the commands to remove or reset a table in ODBC? Or is there 
&lt;br&gt;another way to do this?
&lt;br&gt;&lt;br&gt;Thank you,
&lt;br&gt;Ziming
&lt;br&gt;&lt;br&gt;--
&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26413641&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26413641&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=en&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=en&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/-AMPL-3026--Remove-reset-table-in-ODBC-tp26413641p26413641.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26400814</id>
	<title>RE: [AMPL 3025] Re: Logical operators</title>
	<published>2009-11-17T16:00:16Z</published>
	<updated>2009-11-17T16:00:16Z</updated>
	<author>
		<name>Jen T</name>
	</author>
	<content type="html">&lt;br&gt;Thank you!
&lt;br&gt;&lt;br&gt;&lt;br&gt;Robert Fourer-2 wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; To express such a &amp;quot;disjunctive&amp;quot; constraint of this kind for current
&lt;br&gt;&amp;gt; solvers,
&lt;br&gt;&amp;gt; you need to define a zero-one (or &amp;quot;binary&amp;quot;) variable and to create two
&lt;br&gt;&amp;gt; constraints. &amp;nbsp;The first constraint is equivalent to c1 when the binary
&lt;br&gt;&amp;gt; variable is 1, but is trivially satisfied when the binary variable is 0;
&lt;br&gt;&amp;gt; the
&lt;br&gt;&amp;gt; second constraint is equivalent to c2 when the binary variable is 0, but
&lt;br&gt;&amp;gt; is
&lt;br&gt;&amp;gt; trivially satisfied when the binary variable is 1.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; The details depend on the specifics of your constraints. &amp;nbsp;But as a simple
&lt;br&gt;&amp;gt; example if you want to specify
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;param a &amp;gt;= 0;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;param b &amp;gt;= 0;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;var x &amp;gt;= 0;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;var y &amp;gt;= 0;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;subj to eitheror: &amp;nbsp;x &amp;gt;= a &amp;nbsp;or &amp;nbsp;y &amp;gt;= b;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; then you can write
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;var u binary;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;subj to eitherx: &amp;nbsp;x &amp;gt;= a * u;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;subj to eithery: &amp;nbsp;y &amp;gt;= b * (1-u);
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; For other kinds of inequalities the formulation is a little different, but
&lt;br&gt;&amp;gt; it's not hard to find once you appreciate the principle involved.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Bob Fourer
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26400814&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;4er@...&lt;/a&gt;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; -----Original Message-----
&lt;br&gt;&amp;gt;&amp;gt; From: Jen T [mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26400814&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;jeniphyr@...&lt;/a&gt;]
&lt;br&gt;&amp;gt;&amp;gt; Sent: Sunday, November 15, 2009 6:04 PM
&lt;br&gt;&amp;gt;&amp;gt; To: &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26400814&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;
&lt;br&gt;&amp;gt;&amp;gt; Subject: Re: [AMPL 3013] Re: Logical operators
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; I'm new to AMPL, so try to forgive me if this question is posed
&lt;br&gt;&amp;gt;&amp;gt; elsewhere,
&lt;br&gt;&amp;gt;&amp;gt; or if there is an obvious solution.
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; As the solvers don't support logical operators, is there an alternative
&lt;br&gt;&amp;gt;&amp;gt; way to encode a constraint of the following form...
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; subject to constraintName : c1 or c2;
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; ... where c1 and c2 are simple non-strict inequalities?
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; Robert Fourer-2 wrote:
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; AMPL does allow constraints that use logical operators like &amp;quot;or&amp;quot; (not
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; &amp;quot;OR&amp;quot;), but currently none of the AMPL-solver interfaces are set up to 
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; use such constraints.
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; Bob Fourer
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26400814&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;4er@...&lt;/a&gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;&amp;gt; -----Original Message-----
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;&amp;gt; From: &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26400814&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt; [mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26400814&amp;i=5&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;] On Behalf
&lt;br&gt;&amp;gt;&amp;gt; Of
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;&amp;gt; Dilip
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;&amp;gt; Kothari
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;&amp;gt; Sent: Sunday, April 08, 2007 3:30 AM
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;&amp;gt; To: &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26400814&amp;i=6&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;&amp;gt; Subject: [AMPL 957] Logical operators
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;&amp;gt; Hi
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;&amp;gt; Is AMPL permit the use of logical operators.
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;&amp;gt; e.g I wish to write
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;&amp;gt; zn[i,j] = z[i,j] OR y[i,j]
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;&amp;gt; where zn,z and y are variables. i and j are index over sets
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;&amp;gt; I and J respectively.
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;&amp;gt; Thanks,
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;&amp;gt; DK
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; --~--~---------~--~----~------------~-------~--~----~
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; You received this message because you are subscribed to the Google
&lt;br&gt;&amp;gt;&amp;gt; Groups
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26400814&amp;i=7&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; To unsubscribe from this group, send email to
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26400814&amp;i=8&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl-unsubscribe@...&lt;/a&gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; For more options, visit this group at
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; &lt;a href=&quot;http://groups.google.com/group/ampl?hl=en&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=en&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt; &amp;gt; -~----------~----~----~----~------~----~------~--~---
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; --
&lt;br&gt;&amp;gt;&amp;gt; View this message in context: &lt;a href=&quot;http://old.nabble.com/-AMPL-957--Logical-&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://old.nabble.com/-AMPL-957--Logical-&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt; operators-tp9892505p26365085.html
&lt;br&gt;&amp;gt;&amp;gt; Sent from the AMPL mailing list archive at Nabble.com.
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; --
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; You received this message because you are subscribed to the Google Groups
&lt;br&gt;&amp;gt;&amp;gt; &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;&amp;gt;&amp;gt; To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26400814&amp;i=9&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;&amp;gt;&amp;gt; To unsubscribe from this group, send email to
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26400814&amp;i=10&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;&amp;gt;&amp;gt; For more options, visit this group at
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; You received this message because you are subscribed to the Google Groups
&lt;br&gt;&amp;gt; &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;&amp;gt; To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26400814&amp;i=11&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;&amp;gt; To unsubscribe from this group, send email to
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26400814&amp;i=12&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;&amp;gt; For more options, visit this group at
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;/div&gt;&lt;br&gt;-- 
&lt;br&gt;View this message in context: &lt;a href=&quot;http://old.nabble.com/-AMPL-957--Logical-operators-tp9892505p26400087.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://old.nabble.com/-AMPL-957--Logical-operators-tp9892505p26400087.html&lt;/a&gt;&lt;br&gt;Sent from the AMPL mailing list archive at Nabble.com.
&lt;br&gt;&lt;br&gt;--
&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26400814&amp;i=13&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26400814&amp;i=14&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/-AMPL-957--Logical-operators-tp9892505p26400814.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26399907</id>
	<title>RE: [AMPL 3024] Help with AMPL and L1-SVM</title>
	<published>2009-11-17T15:39:54Z</published>
	<updated>2009-11-17T15:39:54Z</updated>
	<author>
		<name>Robert Fourer-2</name>
	</author>
	<content type="html">&lt;br&gt;There are two ways to read data from a text file, both described in chapter
&lt;br&gt;9 of the AMPL book. &amp;nbsp;You can create a formatted data file according to the
&lt;br&gt;syntax described in sections 9.1-9.4, and then read it using the &amp;quot;data&amp;quot;
&lt;br&gt;command. &amp;nbsp;Or you can create an unformatted file -- containing just a series
&lt;br&gt;of values -- and then read those values into specified parameters using the
&lt;br&gt;&amp;quot;read&amp;quot; command described in section 9.5.
&lt;br&gt;&lt;br&gt;Both of these approaches are quite general. &amp;nbsp;The details of how you use them
&lt;br&gt;will depend upon how you have written the &amp;quot;set&amp;quot; and &amp;quot;param&amp;quot; statements in
&lt;br&gt;your model.
&lt;br&gt;&lt;br&gt;Bob Fourer
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26399907&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;4er@...&lt;/a&gt;
&lt;br&gt;&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; -----Original Message-----
&lt;br&gt;&amp;gt; From: guess85 [mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26399907&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;saintofme85@...&lt;/a&gt;]
&lt;br&gt;&amp;gt; Sent: Thursday, November 12, 2009 2:06 PM
&lt;br&gt;&amp;gt; To: AMPL Modeling Language
&lt;br&gt;&amp;gt; Subject: [AMPL 3005] Help with AMPL and L1-SVM
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Hi, I have to use AMPL to write a L1-SVM classifier. I need to read
&lt;br&gt;&amp;gt; data from a text file where there is the instances and the result of
&lt;br&gt;&amp;gt; classification. I try to write it but without success, how can I do?
&lt;br&gt;&amp;gt; Thanks for the help.
&lt;br&gt;&amp;gt; 
&lt;/div&gt;&lt;br&gt;&lt;br&gt;--
&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26399907&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26399907&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/-AMPL-3005--Help-with-AMPL-and-L1-SVM-tp26328355p26399907.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26398083</id>
	<title>RE: [AMPL 3023] If...Then...Else</title>
	<published>2009-11-17T13:28:49Z</published>
	<updated>2009-11-17T13:28:49Z</updated>
	<author>
		<name>Robert Fourer-2</name>
	</author>
	<content type="html">Various problems here:
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; -- In defining the variables, you need to use &amp;gt;= and &amp;lt;=, 
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;rather than &amp;gt; and &amp;lt;.
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; -- The square root function is &amp;quot;sqrt&amp;quot; rather than &amp;quot;Sqrt&amp;quot;.
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; -- Probably you forgot &amp;quot;data;&amp;quot; before the data statements, 
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;or read the data file as a model file.
&lt;br&gt;&lt;br&gt;Also it's not going to work with existing solvers to have an expression
&lt;br&gt;involving variables between &amp;quot;if&amp;quot; and &amp;quot;then&amp;quot;. &amp;nbsp;You could try defining a
&lt;br&gt;zero-one variable Outside[emp] and inventing some constraints to force that
&lt;br&gt;variable to be one if (XEmpA[emp] - XGrpA)^2 + (YEmpA[emp] - YGrpA)^2 &amp;gt;=
&lt;br&gt;Ra^2; then you could minimize sum {emp in GROUPA} Outside[emp] using a
&lt;br&gt;solver that can handle both quadratic expressions and integer variables.
&lt;br&gt;But if it's acceptable to use a square rather than a circle then you might
&lt;br&gt;find yourself with a more tractable, linear problem.
&lt;br&gt;&lt;br&gt;Bob Fourer
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26398083&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;4er@...&lt;/a&gt;
&lt;br&gt;&amp;nbsp; 
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; -----Original Message-----
&lt;br&gt;&amp;gt; From: Daniel [mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26398083&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;daniel.han.park@...&lt;/a&gt;]
&lt;br&gt;&amp;gt; Sent: Monday, November 16, 2009 11:29 AM
&lt;br&gt;&amp;gt; To: AMPL Modeling Language
&lt;br&gt;&amp;gt; Subject: [AMPL 3018] If...Then...Else
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Hello,
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I'm a recent IE grad with just one grad level IE course under my belt.
&lt;br&gt;&amp;gt; My boss gave me a fun project. Our department is being reorganized
&lt;br&gt;&amp;gt; (people on our floor are being assigned to new groups) and he wants to
&lt;br&gt;&amp;gt; know where to locate each group on our floor to minimize the number
&lt;br&gt;&amp;gt; moves (cost about $800 each).
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; For now I'm just trying to find the x,y coordinate that minimizes the
&lt;br&gt;&amp;gt; number of individuals in one of those groups (we'll call it GroupA)
&lt;br&gt;&amp;gt; that are outside the area if a circle centered at (XGrpA, YGrpA) with
&lt;br&gt;&amp;gt; a radius of Ra.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; The .mod file (first time using AMPL so please feel free to point out
&lt;br&gt;&amp;gt; any syntax errors):
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; set GROUPA; # employees in groupa
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; param XEmpA {emp in GROUPA};
&lt;br&gt;&amp;gt; param YEmpA {emp in GROUPA};
&lt;br&gt;&amp;gt; param Ra;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; var XGrpA &amp;gt; 2, &amp;lt; 6;
&lt;br&gt;&amp;gt; var YGrpA &amp;gt; 3, &amp;lt; 8;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; minimize Moves: sum{emp in GROUPA} (if Sqrt((XEmpA[emp] - XGrpA)^2 +
&lt;br&gt;&amp;gt; (YEmpA[emp] - YGrpA)^2) &amp;gt; Ra then 1 else 0)
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; The data file:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; # Type data here or open a data file...
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; set GROUPA := 1 2 3 4 5 6 7 8 9 10;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; param:	XEmpA	YEmpA	:=
&lt;br&gt;&amp;gt; 1	1	1
&lt;br&gt;&amp;gt; 2	7	1
&lt;br&gt;&amp;gt; 3	1	2
&lt;br&gt;&amp;gt; 4	3	2
&lt;br&gt;&amp;gt; 5	4	2
&lt;br&gt;&amp;gt; 6	4	2
&lt;br&gt;&amp;gt; 7	8	2
&lt;br&gt;&amp;gt; 8	1	3
&lt;br&gt;&amp;gt; 9	2	3
&lt;br&gt;&amp;gt; 10	3	3;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; param Ra := 3;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I get the following errors:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; file -
&lt;br&gt;&amp;gt; line 7
&lt;br&gt;&amp;gt; offset 169
&lt;br&gt;&amp;gt; cannot enforce strict bound
&lt;br&gt;&amp;gt; file -
&lt;br&gt;&amp;gt; line 7
&lt;br&gt;&amp;gt; offset 174
&lt;br&gt;&amp;gt; cannot enforce strict bound
&lt;br&gt;&amp;gt; file -
&lt;br&gt;&amp;gt; line 8
&lt;br&gt;&amp;gt; offset 190
&lt;br&gt;&amp;gt; cannot enforce strict bound
&lt;br&gt;&amp;gt; file -
&lt;br&gt;&amp;gt; line 8
&lt;br&gt;&amp;gt; offset 195
&lt;br&gt;&amp;gt; cannot enforce strict bound
&lt;br&gt;&amp;gt; file -
&lt;br&gt;&amp;gt; line 9
&lt;br&gt;&amp;gt; offset 238
&lt;br&gt;&amp;gt; Sqrt is not defined
&lt;br&gt;&amp;gt; file -
&lt;br&gt;&amp;gt; line 12
&lt;br&gt;&amp;gt; offset 365
&lt;br&gt;&amp;gt; GROUPA is already defined
&lt;br&gt;&amp;gt; file -
&lt;br&gt;&amp;gt; line 13
&lt;br&gt;&amp;gt; offset 398
&lt;br&gt;&amp;gt; syntax error
&lt;br&gt;&amp;gt; file -
&lt;br&gt;&amp;gt; line 24
&lt;br&gt;&amp;gt; offset 499
&lt;br&gt;&amp;gt; Ra is already defined
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Specific Questions: What is the correct symbol for the square root
&lt;br&gt;&amp;gt; operator? Is there some documentation on when you can and cannot use
&lt;br&gt;&amp;gt; the if, then statements in AMPL (looked through the related forum
&lt;br&gt;&amp;gt; posts but still a bit confused on this)?
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; AMPL book is on the way but I'd like to get a little bit done sooner
&lt;br&gt;&amp;gt; to show my boss. Thanks!!!
&lt;br&gt;&amp;gt; 
&lt;/div&gt;&lt;br&gt;&lt;br&gt;--
&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26398083&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26398083&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/-AMPL-3018--If...Then...Else-tp26377194p26398083.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26397749</id>
	<title>RE: [AMPL 3022] Re: Logical operators</title>
	<published>2009-11-17T13:14:07Z</published>
	<updated>2009-11-17T13:14:07Z</updated>
	<author>
		<name>Robert Fourer-2</name>
	</author>
	<content type="html">&lt;br&gt;To express such a &amp;quot;disjunctive&amp;quot; constraint of this kind for current solvers,
&lt;br&gt;you need to define a zero-one (or &amp;quot;binary&amp;quot;) variable and to create two
&lt;br&gt;constraints. &amp;nbsp;The first constraint is equivalent to c1 when the binary
&lt;br&gt;variable is 1, but is trivially satisfied when the binary variable is 0; the
&lt;br&gt;second constraint is equivalent to c2 when the binary variable is 0, but is
&lt;br&gt;trivially satisfied when the binary variable is 1.
&lt;br&gt;&lt;br&gt;The details depend on the specifics of your constraints. &amp;nbsp;But as a simple
&lt;br&gt;example if you want to specify
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;param a &amp;gt;= 0;
&lt;br&gt;&amp;nbsp; &amp;nbsp;param b &amp;gt;= 0;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;var x &amp;gt;= 0;
&lt;br&gt;&amp;nbsp; &amp;nbsp;var y &amp;gt;= 0;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;subj to eitheror: &amp;nbsp;x &amp;gt;= a &amp;nbsp;or &amp;nbsp;y &amp;gt;= b;
&lt;br&gt;&lt;br&gt;then you can write
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;var u binary;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;subj to eitherx: &amp;nbsp;x &amp;gt;= a * u;
&lt;br&gt;&amp;nbsp; &amp;nbsp;subj to eithery: &amp;nbsp;y &amp;gt;= b * (1-u);
&lt;br&gt;&lt;br&gt;For other kinds of inequalities the formulation is a little different, but
&lt;br&gt;it's not hard to find once you appreciate the principle involved.
&lt;br&gt;&lt;br&gt;Bob Fourer
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26397749&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;4er@...&lt;/a&gt;
&lt;br&gt;&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; -----Original Message-----
&lt;br&gt;&amp;gt; From: Jen T [mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26397749&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;jeniphyr@...&lt;/a&gt;]
&lt;br&gt;&amp;gt; Sent: Sunday, November 15, 2009 6:04 PM
&lt;br&gt;&amp;gt; To: &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26397749&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;
&lt;br&gt;&amp;gt; Subject: Re: [AMPL 3013] Re: Logical operators
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I'm new to AMPL, so try to forgive me if this question is posed elsewhere,
&lt;br&gt;&amp;gt; or if there is an obvious solution.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; As the solvers don't support logical operators, is there an alternative
&lt;br&gt;&amp;gt; way to encode a constraint of the following form...
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; subject to constraintName : c1 or c2;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; ... where c1 and c2 are simple non-strict inequalities?
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Robert Fourer-2 wrote:
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; AMPL does allow constraints that use logical operators like &amp;quot;or&amp;quot; (not
&lt;br&gt;&amp;gt; &amp;gt; &amp;quot;OR&amp;quot;), but currently none of the AMPL-solver interfaces are set up to 
&lt;br&gt;&amp;gt; &amp;gt; use such constraints.
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; Bob Fourer
&lt;br&gt;&amp;gt; &amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26397749&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;4er@...&lt;/a&gt;
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; -----Original Message-----
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; From: &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26397749&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt; [mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26397749&amp;i=5&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;] On Behalf Of
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; Dilip
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; Kothari
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; Sent: Sunday, April 08, 2007 3:30 AM
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; To: &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26397749&amp;i=6&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; Subject: [AMPL 957] Logical operators
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; Hi
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; Is AMPL permit the use of logical operators.
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; e.g I wish to write
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; zn[i,j] = z[i,j] OR y[i,j]
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; where zn,z and y are variables. i and j are index over sets
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; I and J respectively.
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; Thanks,
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt; DK
&lt;br&gt;&amp;gt; &amp;gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; --~--~---------~--~----~------------~-------~--~----~
&lt;br&gt;&amp;gt; &amp;gt; You received this message because you are subscribed to the Google
&lt;br&gt;&amp;gt; Groups
&lt;br&gt;&amp;gt; &amp;gt; &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;&amp;gt; &amp;gt; To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26397749&amp;i=7&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;
&lt;br&gt;&amp;gt; &amp;gt; To unsubscribe from this group, send email to
&lt;br&gt;&amp;gt; &amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26397749&amp;i=8&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl-unsubscribe@...&lt;/a&gt;
&lt;br&gt;&amp;gt; &amp;gt; For more options, visit this group at
&lt;br&gt;&amp;gt; &amp;gt; &lt;a href=&quot;http://groups.google.com/group/ampl?hl=en&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=en&lt;/a&gt;&lt;br&gt;&amp;gt; &amp;gt; -~----------~----~----~----~------~----~------~--~---
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; View this message in context: &lt;a href=&quot;http://old.nabble.com/-AMPL-957--Logical-&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://old.nabble.com/-AMPL-957--Logical-&lt;/a&gt;&lt;br&gt;&amp;gt; operators-tp9892505p26365085.html
&lt;br&gt;&amp;gt; Sent from the AMPL mailing list archive at Nabble.com.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; You received this message because you are subscribed to the Google Groups
&lt;br&gt;&amp;gt; &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;&amp;gt; To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26397749&amp;i=9&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;&amp;gt; To unsubscribe from this group, send email to
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26397749&amp;i=10&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;&amp;gt; For more options, visit this group at
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.
&lt;br&gt;&amp;gt; 
&lt;/div&gt;&lt;br&gt;&lt;br&gt;--
&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26397749&amp;i=11&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26397749&amp;i=12&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/-AMPL-957--Logical-operators-tp9892505p26397749.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26390069</id>
	<title>[AMPL 3019] Re: calculating runlength</title>
	<published>2009-11-17T05:37:29Z</published>
	<updated>2009-11-17T05:37:29Z</updated>
	<author>
		<name>msaqib</name>
	</author>
	<content type="html">Hi Paul
&lt;br&gt;Thanks for the reply. In my case, it is &amp;quot;c&amp;quot;, i.e., the bits are
&lt;br&gt;variables and the value they take on, is factored into the objective
&lt;br&gt;function.
&lt;br&gt;I have a feeling that computing exclusive OR(XOR) of each adjacent
&lt;br&gt;pair of bits and summing the answer (as an integer) gives me the
&lt;br&gt;answer. Can anyone come up with a different approach? I'll need to
&lt;br&gt;read the AMPL book to see if XOR is possible in AMPL models.
&lt;br&gt;Thanks and best regards
&lt;br&gt;&lt;br&gt;On Nov 16, 8:02 pm, Paul &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26390069&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ru...@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; I can interpret this three different ways:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; a) the bits are parameters of the model;
&lt;br&gt;&amp;gt; b) the bits are model variables (unknown when the model is
&lt;br&gt;&amp;gt; formulated), and you need to compute the run length of the final
&lt;br&gt;&amp;gt; solution after the solution is obtained; or
&lt;br&gt;&amp;gt; c) the bits are model variables and so is the run length, and the run
&lt;br&gt;&amp;gt; length is used within the model.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; The first two can be handled by looping; the third requires additional
&lt;br&gt;&amp;gt; model constructs (constraints and probability some auxiliary
&lt;br&gt;&amp;gt; variables).
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; /Paul
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; On Nov 16, 8:24 am, msaqib &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26390069&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;msa...@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; Hi all
&lt;br&gt;&amp;gt; &amp;gt; In a model, I need to calculate the runlength of a sequence of binary (0/1)
&lt;br&gt;&amp;gt; &amp;gt; numbers. In other words, I need to count the number of zeros between a pair
&lt;br&gt;&amp;gt; &amp;gt; of ones. For example, the runlength in 0010001110010 is 5, and that for
&lt;br&gt;&amp;gt; &amp;gt; 0010000110010 is 6. I'm not sure how to represent this mathematically in an
&lt;br&gt;&amp;gt; &amp;gt; AMPL model. We typically do this iteratively in other programming languages.
&lt;br&gt;&amp;gt; &amp;gt; Any clues?
&lt;br&gt;&amp;gt; &amp;gt; Thanks and best regards
&lt;br&gt;&amp;gt; &amp;gt; --
&lt;br&gt;&amp;gt; &amp;gt; View this message in context:&lt;a href=&quot;http://old.nabble.com/calculating-runlength-tp26371837p26371837.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://old.nabble.com/calculating-runlength-tp26371837p26371837.html&lt;/a&gt;&lt;br&gt;&amp;gt; &amp;gt; Sent from the AMPL mailing list archive at Nabble.com.- Hide quoted text -
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; - Show quoted text -
&lt;/div&gt;&lt;br&gt;--
&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26390069&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26390069&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/calculating-runlength-tp26371837p26390069.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26392086</id>
	<title>Re: [AMPL 3021] expanding defined variables</title>
	<published>2009-11-17T01:31:51Z</published>
	<updated>2009-11-17T01:31:51Z</updated>
	<author>
		<name>Ali Baharev</name>
	</author>
	<content type="html">David M. Gay suggested this (with the &amp;lt;var&amp;gt; = &amp;lt;defining expression&amp;gt;
&lt;br&gt;explicit constraint approach):
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;expand{i in 1.._nvars: &amp;nbsp;_var[i].status == 'sub'} _con[_var[i].defeqn];
&lt;br&gt;&lt;br&gt;It works but Lambda[1,1,1] appears in def_sum_xLambda[1,1]
&lt;br&gt;however Lambda[1,1,1] is 1 and should be eliminated.
&lt;br&gt;&lt;br&gt;In other words: the output still needs considerable editing.
&lt;br&gt;&lt;br&gt;It seems to me that the easiest would be to write a custom parser for
&lt;br&gt;the nl file.
&lt;br&gt;&lt;br&gt;Many thanks for the help,
&lt;br&gt;&lt;br&gt;Ali
&lt;br&gt;&lt;br&gt;--
&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26392086&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26392086&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/-AMPL-2957--expanding-defined-variables-tp26222287p26392086.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26385781</id>
	<title>Re: [AMPL 3015] Re: calculating runlength</title>
	<published>2009-11-16T23:56:10Z</published>
	<updated>2009-11-17T02:14:22Z</updated>
	<author>
		<name>msaqib</name>
	</author>
	<content type="html">My case is &amp;quot;c&amp;quot;, the bits are model variables and the run length should be computed and it factors in the objective function.
&lt;br&gt;&lt;br&gt;&lt;blockquote class=&quot;quote light-black dark-border-color&quot;&gt;&lt;div class=&quot;quote light-border-color&quot;&gt;
&lt;div class=&quot;quote-author&quot; style=&quot;font-weight: bold;&quot;&gt;Paul-432 wrote:&lt;/div&gt;
&lt;div class=&quot;quote-message shrinkable-quote&quot;&gt;I can interpret this three different ways:
&lt;br&gt;&lt;br&gt;a) the bits are parameters of the model;
&lt;br&gt;b) the bits are model variables (unknown when the model is
&lt;br&gt;formulated), and you need to compute the run length of the final
&lt;br&gt;solution after the solution is obtained; or
&lt;br&gt;c) the bits are model variables and so is the run length, and the run
&lt;br&gt;length is used within the model.
&lt;br&gt;&lt;br&gt;The first two can be handled by looping; the third requires additional
&lt;br&gt;model constructs (constraints and probability some auxiliary
&lt;br&gt;variables).
&lt;br&gt;&lt;br&gt;/Paul
&lt;br&gt;&lt;br&gt;On Nov 16, 8:24 am, msaqib &amp;lt;msa...@gmail.com&amp;gt; wrote:
&lt;br&gt;&amp;gt; Hi all
&lt;br&gt;&amp;gt; In a model, I need to calculate the runlength of a sequence of binary (0/1)
&lt;br&gt;&amp;gt; numbers. In other words, I need to count the number of zeros between a pair
&lt;br&gt;&amp;gt; of ones. For example, the runlength in 0010001110010 is 5, and that for
&lt;br&gt;&amp;gt; 0010000110010 is 6. I'm not sure how to represent this mathematically in an
&lt;br&gt;&amp;gt; AMPL model. We typically do this iteratively in other programming languages.
&lt;br&gt;&amp;gt; Any clues?
&lt;br&gt;&amp;gt; Thanks and best regards
&lt;br&gt;&amp;gt; --
&lt;/div&gt;
&lt;/div&gt;&lt;/blockquote&gt;
</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/calculating-runlength-tp26371837p26385781.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26377194</id>
	<title>[AMPL 3018] If...Then...Else</title>
	<published>2009-11-16T09:29:29Z</published>
	<updated>2009-11-16T09:29:29Z</updated>
	<author>
		<name>Daniel-389</name>
	</author>
	<content type="html">Hello,
&lt;br&gt;&lt;br&gt;I'm a recent IE grad with just one grad level IE course under my belt.
&lt;br&gt;My boss gave me a fun project. Our department is being reorganized
&lt;br&gt;(people on our floor are being assigned to new groups) and he wants to
&lt;br&gt;know where to locate each group on our floor to minimize the number
&lt;br&gt;moves (cost about $800 each).
&lt;br&gt;&lt;br&gt;For now I'm just trying to find the x,y coordinate that minimizes the
&lt;br&gt;number of individuals in one of those groups (we'll call it GroupA)
&lt;br&gt;that are outside the area if a circle centered at (XGrpA, YGrpA) with
&lt;br&gt;a radius of Ra.
&lt;br&gt;&lt;br&gt;The .mod file (first time using AMPL so please feel free to point out
&lt;br&gt;any syntax errors):
&lt;br&gt;&lt;br&gt;set GROUPA; # employees in groupa
&lt;br&gt;&lt;br&gt;param XEmpA {emp in GROUPA};
&lt;br&gt;param YEmpA {emp in GROUPA};
&lt;br&gt;param Ra;
&lt;br&gt;&lt;br&gt;var XGrpA &amp;gt; 2, &amp;lt; 6;
&lt;br&gt;var YGrpA &amp;gt; 3, &amp;lt; 8;
&lt;br&gt;&lt;br&gt;minimize Moves: sum{emp in GROUPA} (if Sqrt((XEmpA[emp] - XGrpA)^2 +
&lt;br&gt;(YEmpA[emp] - YGrpA)^2) &amp;gt; Ra then 1 else 0)
&lt;br&gt;&lt;br&gt;The data file:
&lt;br&gt;&lt;br&gt;# Type data here or open a data file...
&lt;br&gt;&lt;br&gt;set GROUPA := 1 2 3 4 5 6 7 8 9 10;
&lt;br&gt;&lt;br&gt;param:	XEmpA	YEmpA	:=
&lt;br&gt;1	1	1
&lt;br&gt;2	7	1
&lt;br&gt;3	1	2
&lt;br&gt;4	3	2
&lt;br&gt;5	4	2
&lt;br&gt;6	4	2
&lt;br&gt;7	8	2
&lt;br&gt;8	1	3
&lt;br&gt;9	2	3
&lt;br&gt;10	3	3;
&lt;br&gt;&lt;br&gt;param Ra := 3;
&lt;br&gt;&lt;br&gt;I get the following errors:
&lt;br&gt;&lt;br&gt;file -
&lt;br&gt;line 7
&lt;br&gt;offset 169
&lt;br&gt;cannot enforce strict bound
&lt;br&gt;file -
&lt;br&gt;line 7
&lt;br&gt;offset 174
&lt;br&gt;cannot enforce strict bound
&lt;br&gt;file -
&lt;br&gt;line 8
&lt;br&gt;offset 190
&lt;br&gt;cannot enforce strict bound
&lt;br&gt;file -
&lt;br&gt;line 8
&lt;br&gt;offset 195
&lt;br&gt;cannot enforce strict bound
&lt;br&gt;file -
&lt;br&gt;line 9
&lt;br&gt;offset 238
&lt;br&gt;Sqrt is not defined
&lt;br&gt;file -
&lt;br&gt;line 12
&lt;br&gt;offset 365
&lt;br&gt;GROUPA is already defined
&lt;br&gt;file -
&lt;br&gt;line 13
&lt;br&gt;offset 398
&lt;br&gt;syntax error
&lt;br&gt;file -
&lt;br&gt;line 24
&lt;br&gt;offset 499
&lt;br&gt;Ra is already defined
&lt;br&gt;&lt;br&gt;Specific Questions: What is the correct symbol for the square root
&lt;br&gt;operator? Is there some documentation on when you can and cannot use
&lt;br&gt;the if, then statements in AMPL (looked through the related forum
&lt;br&gt;posts but still a bit confused on this)?
&lt;br&gt;&lt;br&gt;AMPL book is on the way but I'd like to get a little bit done sooner
&lt;br&gt;to show my boss. Thanks!!!
&lt;br&gt;&lt;br&gt;--
&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26377194&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26377194&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/-AMPL-3018--If...Then...Else-tp26377194p26377194.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26375304</id>
	<title>[AMPL 3017] Re: Segmentation fault and Logical constraint is always  false error</title>
	<published>2009-11-16T08:50:40Z</published>
	<updated>2009-11-16T08:50:40Z</updated>
	<author>
		<name>enhany75</name>
	</author>
	<content type="html">Thanks a lot, it helps me to found the mistake. The RHS of the
&lt;br&gt;constriant was missing.
&lt;br&gt;&lt;br&gt;On Nov 16, 5:05 pm, Paul &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26375304&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ru...@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Try adding the line
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; expand optimality_cut[nsoln];
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; after nsoln gets incremented and see what you get.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; /Paul
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; On Nov 15, 9:46 pm, enhany75 &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26375304&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;enhan...@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; Hi,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; I am trying to solve a model by decomposition using master and sub-
&lt;br&gt;&amp;gt; &amp;gt; problem. At each time an optimality cut is added to the master
&lt;br&gt;&amp;gt; &amp;gt; problem.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; subject to optimality_cut {n in nols: n &amp;lt;= nsoln}: sum {j in t1, i in
&lt;br&gt;&amp;gt; &amp;gt; prodj[j],q in seqj[j]: Xjiq_cut[n,j,i,q] = 0} Xjiq[j,i,q] + sum {j in
&lt;br&gt;&amp;gt; &amp;gt; t1, i in prodj[j],q in seqj[j]: Xjiq_cut[n,j,i,q] = 1}(1- Xjiq[j,i,q])
&lt;br&gt;&amp;gt; &amp;gt; + sum {k in t2, i in prodk[k],q in seqk[k]: Xkiq_cut[n,k,i,q] = 0} Xkiq
&lt;br&gt;&amp;gt; &amp;gt; [k,i,q] + sum {k in t2, i in prodk[k],q in seqk[k]: Xkiq_cut[n,k,i,q]
&lt;br&gt;&amp;gt; &amp;gt; = 1}(1- Xkiq[k,i,q]);
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; But  the solver gives me this error message
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; presolve, constraint optimality_cut[2]:
&lt;br&gt;&amp;gt; &amp;gt;         Logical constraint is always false.
&lt;br&gt;&amp;gt; &amp;gt; presolve, constraint optimality_cut[1]:
&lt;br&gt;&amp;gt; &amp;gt;         Logical constraint is always false.
&lt;br&gt;&amp;gt; &amp;gt; presolve, constraint optimality_cut[1]:
&lt;br&gt;&amp;gt; &amp;gt;         Logical constraint is always false.
&lt;br&gt;&amp;gt; &amp;gt; presolve, constraint optimality_cut[2]:
&lt;br&gt;&amp;gt; &amp;gt;         .
&lt;br&gt;&amp;gt; &amp;gt; srun: error: n281: task0: Segmentation fault
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; Could you please tell me why the Logical constraint is always false,
&lt;br&gt;&amp;gt; &amp;gt; knowing that Xjiq_cut take binary values.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;--
&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26375304&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26375304&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/-AMPL-3012--Segmentation-fault-and-Logical-constraint-is-always-false--error-tp26366146p26375304.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26373503</id>
	<title>[AMPL 3016] Re: Segmentation fault and Logical constraint is always  false error</title>
	<published>2009-11-16T07:05:58Z</published>
	<updated>2009-11-16T07:05:58Z</updated>
	<author>
		<name>Paul-432</name>
	</author>
	<content type="html">Try adding the line
&lt;br&gt;&lt;br&gt;expand optimality_cut[nsoln];
&lt;br&gt;&lt;br&gt;after nsoln gets incremented and see what you get.
&lt;br&gt;&lt;br&gt;/Paul
&lt;br&gt;&lt;br&gt;On Nov 15, 9:46 pm, enhany75 &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26373503&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;enhan...@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hi,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I am trying to solve a model by decomposition using master and sub-
&lt;br&gt;&amp;gt; problem. At each time an optimality cut is added to the master
&lt;br&gt;&amp;gt; problem.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; subject to optimality_cut {n in nols: n &amp;lt;= nsoln}: sum {j in t1, i in
&lt;br&gt;&amp;gt; prodj[j],q in seqj[j]: Xjiq_cut[n,j,i,q] = 0} Xjiq[j,i,q] + sum {j in
&lt;br&gt;&amp;gt; t1, i in prodj[j],q in seqj[j]: Xjiq_cut[n,j,i,q] = 1}(1- Xjiq[j,i,q])
&lt;br&gt;&amp;gt; + sum {k in t2, i in prodk[k],q in seqk[k]: Xkiq_cut[n,k,i,q] = 0} Xkiq
&lt;br&gt;&amp;gt; [k,i,q] + sum {k in t2, i in prodk[k],q in seqk[k]: Xkiq_cut[n,k,i,q]
&lt;br&gt;&amp;gt; = 1}(1- Xkiq[k,i,q]);
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; But  the solver gives me this error message
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; presolve, constraint optimality_cut[2]:
&lt;br&gt;&amp;gt;         Logical constraint is always false.
&lt;br&gt;&amp;gt; presolve, constraint optimality_cut[1]:
&lt;br&gt;&amp;gt;         Logical constraint is always false.
&lt;br&gt;&amp;gt; presolve, constraint optimality_cut[1]:
&lt;br&gt;&amp;gt;         Logical constraint is always false.
&lt;br&gt;&amp;gt; presolve, constraint optimality_cut[2]:
&lt;br&gt;&amp;gt;         .
&lt;br&gt;&amp;gt; srun: error: n281: task0: Segmentation fault
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Could you please tell me why the Logical constraint is always false,
&lt;br&gt;&amp;gt; knowing that Xjiq_cut take binary values.
&lt;/div&gt;&lt;br&gt;--
&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26373503&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26373503&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/-AMPL-3012--Segmentation-fault-and-Logical-constraint-is-always-false--error-tp26366146p26373503.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26373441</id>
	<title>[AMPL 3015] Re: calculating runlength</title>
	<published>2009-11-16T07:02:19Z</published>
	<updated>2009-11-16T07:02:19Z</updated>
	<author>
		<name>Paul-432</name>
	</author>
	<content type="html">I can interpret this three different ways:
&lt;br&gt;&lt;br&gt;a) the bits are parameters of the model;
&lt;br&gt;b) the bits are model variables (unknown when the model is
&lt;br&gt;formulated), and you need to compute the run length of the final
&lt;br&gt;solution after the solution is obtained; or
&lt;br&gt;c) the bits are model variables and so is the run length, and the run
&lt;br&gt;length is used within the model.
&lt;br&gt;&lt;br&gt;The first two can be handled by looping; the third requires additional
&lt;br&gt;model constructs (constraints and probability some auxiliary
&lt;br&gt;variables).
&lt;br&gt;&lt;br&gt;/Paul
&lt;br&gt;&lt;br&gt;On Nov 16, 8:24 am, msaqib &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26373441&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;msa...@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hi all
&lt;br&gt;&amp;gt; In a model, I need to calculate the runlength of a sequence of binary (0/1)
&lt;br&gt;&amp;gt; numbers. In other words, I need to count the number of zeros between a pair
&lt;br&gt;&amp;gt; of ones. For example, the runlength in 0010001110010 is 5, and that for
&lt;br&gt;&amp;gt; 0010000110010 is 6. I'm not sure how to represent this mathematically in an
&lt;br&gt;&amp;gt; AMPL model. We typically do this iteratively in other programming languages.
&lt;br&gt;&amp;gt; Any clues?
&lt;br&gt;&amp;gt; Thanks and best regards
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; View this message in context:&lt;a href=&quot;http://old.nabble.com/calculating-runlength-tp26371837p26371837.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://old.nabble.com/calculating-runlength-tp26371837p26371837.html&lt;/a&gt;&lt;br&gt;&amp;gt; Sent from the AMPL mailing list archive at Nabble.com.
&lt;/div&gt;&lt;br&gt;--
&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26373441&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26373441&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/calculating-runlength-tp26371837p26373441.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26371837</id>
	<title>calculating runlength</title>
	<published>2009-11-16T05:24:48Z</published>
	<updated>2009-11-16T05:24:48Z</updated>
	<author>
		<name>msaqib</name>
	</author>
	<content type="html">Hi all
&lt;br&gt;In a model, I need to calculate the runlength of a sequence of binary (0/1) numbers. In other words, I need to count the number of zeros between a pair of ones. For example, the runlength in 0010001110010 is 5, and that for 0010000110010 is 6. I'm not sure how to represent this mathematically in an AMPL model. We typically do this iteratively in other programming languages.
&lt;br&gt;Any clues?
&lt;br&gt;Thanks and best regards</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/calculating-runlength-tp26371837p26371837.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26366146</id>
	<title>[AMPL 3012] Segmentation fault and Logical constraint is always false  error</title>
	<published>2009-11-15T18:46:15Z</published>
	<updated>2009-11-15T18:46:15Z</updated>
	<author>
		<name>enhany75</name>
	</author>
	<content type="html">Hi,
&lt;br&gt;&lt;br&gt;I am trying to solve a model by decomposition using master and sub-
&lt;br&gt;problem. At each time an optimality cut is added to the master
&lt;br&gt;problem.
&lt;br&gt;&lt;br&gt;subject to optimality_cut {n in nols: n &amp;lt;= nsoln}: sum {j in t1, i in
&lt;br&gt;prodj[j],q in seqj[j]: Xjiq_cut[n,j,i,q] = 0} Xjiq[j,i,q] + sum {j in
&lt;br&gt;t1, i in prodj[j],q in seqj[j]: Xjiq_cut[n,j,i,q] = 1}(1- Xjiq[j,i,q])
&lt;br&gt;+ sum {k in t2, i in prodk[k],q in seqk[k]: Xkiq_cut[n,k,i,q] = 0} Xkiq
&lt;br&gt;[k,i,q] + sum {k in t2, i in prodk[k],q in seqk[k]: Xkiq_cut[n,k,i,q]
&lt;br&gt;= 1}(1- Xkiq[k,i,q]);
&lt;br&gt;&lt;br&gt;But &amp;nbsp;the solver gives me this error message
&lt;br&gt;&lt;br&gt;presolve, constraint optimality_cut[2]:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Logical constraint is always false.
&lt;br&gt;presolve, constraint optimality_cut[1]:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Logical constraint is always false.
&lt;br&gt;presolve, constraint optimality_cut[1]:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Logical constraint is always false.
&lt;br&gt;presolve, constraint optimality_cut[2]:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .
&lt;br&gt;srun: error: n281: task0: Segmentation fault
&lt;br&gt;&lt;br&gt;Could you please tell me why the Logical constraint is always false,
&lt;br&gt;knowing that Xjiq_cut take binary values.
&lt;br&gt;&lt;br&gt;--
&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26366146&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26366146&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/-AMPL-3012--Segmentation-fault-and-Logical-constraint-is-always-false--error-tp26366146p26366146.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26365085</id>
	<title>Re: [AMPL 970] Re: Logical operators</title>
	<published>2009-11-15T16:04:11Z</published>
	<updated>2009-11-15T16:04:11Z</updated>
	<author>
		<name>Jen T</name>
	</author>
	<content type="html">I'm new to AMPL, so try to forgive me if this question is posed elsewhere, 
&lt;br&gt;or if there is an obvious solution.
&lt;br&gt;&lt;br&gt;As the solvers don't support logical operators, is there an alternative way to 
&lt;br&gt;encode a constraint of the following form...
&lt;br&gt;&lt;br&gt;subject to constraintName : c1 or c2;
&lt;br&gt;&lt;br&gt;... where c1 and c2 are simple non-strict inequalities?
&lt;br&gt;&lt;br&gt;&amp;nbsp;
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;blockquote class=&quot;quote light-black dark-border-color&quot;&gt;&lt;div class=&quot;quote light-border-color&quot;&gt;
&lt;div class=&quot;quote-author&quot; style=&quot;font-weight: bold;&quot;&gt;Robert Fourer-2 wrote:&lt;/div&gt;
&lt;div class=&quot;quote-message shrinkable-quote&quot;&gt;AMPL does allow constraints that use logical operators like &amp;quot;or&amp;quot; (not &amp;quot;OR&amp;quot;),
&lt;br&gt;but currently none of the AMPL-solver interfaces are set up to use such
&lt;br&gt;constraints.
&lt;br&gt;&lt;br&gt;Bob Fourer
&lt;br&gt;4er@ampl.com
&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;gt; -----Original Message-----
&lt;br&gt;&amp;gt; From: ampl@googlegroups.com [mailto:ampl@googlegroups.com] On Behalf Of Dilip
&lt;br&gt;&amp;gt; Kothari
&lt;br&gt;&amp;gt; Sent: Sunday, April 08, 2007 3:30 AM
&lt;br&gt;&amp;gt; To: ampl@googlegroups.com
&lt;br&gt;&amp;gt; Subject: [AMPL 957] Logical operators
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Hi
&lt;br&gt;&amp;gt; Is AMPL permit the use of logical operators.
&lt;br&gt;&amp;gt; e.g I wish to write
&lt;br&gt;&amp;gt; zn[i,j] = z[i,j] OR y[i,j]
&lt;br&gt;&amp;gt; where zn,z and y are variables. i and j are index over sets
&lt;br&gt;&amp;gt; I and J respectively.
&lt;br&gt;&amp;gt; Thanks,
&lt;br&gt;&amp;gt; DK
&lt;br&gt;&amp;gt; 
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;--~--~---------~--~----~------------~-------~--~----~
&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to ampl@googlegroups.com
&lt;br&gt;To unsubscribe from this group, send email to ampl-unsubscribe@googlegroups.com
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=en&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=en&lt;/a&gt;&lt;br&gt;-~----------~----~----~----~------~----~------~--~---
&lt;br&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/blockquote&gt;
</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/-AMPL-957--Logical-operators-tp9892505p26365085.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26351137</id>
	<title>RE: [AMPL 3011] Re: number accuracy in writing to file</title>
	<published>2009-11-14T07:50:48Z</published>
	<updated>2009-11-14T07:50:48Z</updated>
	<author>
		<name>Robert Fourer-2</name>
	</author>
	<content type="html">&lt;br&gt;AMPL's calculations are done in double-precision floating point arithmetic
&lt;br&gt;using all of the precision that the computer and processor can provide.
&lt;br&gt;&lt;br&gt;The display_precision and display_round options affect how numerical values
&lt;br&gt;are displayed, but numbers are stored in full precision internally and the
&lt;br&gt;full precision is used in all calculations.
&lt;br&gt;&lt;br&gt;Bob Fourer
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26351137&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;4er@...&lt;/a&gt;
&lt;br&gt;&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; -----Original Message-----
&lt;br&gt;&amp;gt; From: hessam [mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26351137&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;hessam.1983@...&lt;/a&gt;]
&lt;br&gt;&amp;gt; Sent: Friday, November 13, 2009 3:22 AM
&lt;br&gt;&amp;gt; To: AMPL Modeling Language
&lt;br&gt;&amp;gt; Subject: [AMPL 3006] Re: number accuracy in writing to file
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I have another question. Is there any default precision in math
&lt;br&gt;&amp;gt; calculations in AMPL or the operations (for example dividing two
&lt;br&gt;&amp;gt; numbers) are calculated with maximum precision??
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; On Nov 12, 11:36 am, hessam &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26351137&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;hessam.1...@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt; &amp;gt; Thanks Bob, your comments are always a great help to me.
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; On Nov 12, 7:23 am, &amp;quot;Robert Fourer&amp;quot; &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26351137&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;4...@...&lt;/a&gt;&amp;gt; wrote:&amp;gt; The default
&lt;br&gt;&amp;gt; precision for &amp;quot;display&amp;quot; is 6 significant digits.  To get a more
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; precise display of the objective value, set for example &amp;quot;option
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; display_precision 10;&amp;quot; before the display command.  (To tell AMPL that
&lt;br&gt;&amp;gt; you
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; want the most precision possible, given the number of bits used to
&lt;br&gt;&amp;gt; represent
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; the objective value in the computer, set &amp;quot;option display_precision
&lt;br&gt;&amp;gt; 0;&amp;quot;.)
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; Bob Fourer
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26351137&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;4...@...&lt;/a&gt;
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; &amp;gt; -----Original Message-----
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; &amp;gt; From: hessam [mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26351137&amp;i=5&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;hessam.1...@...&lt;/a&gt;]
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; &amp;gt; Sent: Wednesday, November 11, 2009 9:47 PM
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; &amp;gt; To: AMPL Modeling Language
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; &amp;gt; Subject: [AMPL 2996] number accuracy in writing to file
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; &amp;gt; Hi All,
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; &amp;gt; I have a problem with writing my results in a file. When I solve my
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; &amp;gt; ILP with CPLEX+AMPL I get this result:
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; &amp;gt; --------------------------------------------------------------------
&lt;br&gt;&amp;gt; ------
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; &amp;gt; CPLEX 11.2.1: optimal integer solution; objective 1213236000
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; &amp;gt; 731 MIP simplex iterations
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; &amp;gt; 0 branch-and-bound nodes
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; &amp;gt; 6 Gomory cuts
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; &amp;gt; 7 zero-half cuts
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; &amp;gt; --------------------------------------------------------------------
&lt;br&gt;&amp;gt; ------
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; &amp;gt; BUT when I use the command &amp;quot;display totalenergy &amp;gt; result.txt;&amp;quot; after
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; &amp;gt; solving my ILP (note than the variable totalenergy is the objective
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; &amp;gt; which I try to minimize), in the file I see the number 1213240000
&lt;br&gt;&amp;gt; !!!
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; &amp;gt; Any suggestions about how I can have the same number in the file??
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; &amp;gt; Thanks,
&lt;br&gt;&amp;gt; &amp;gt; &amp;gt; &amp;gt; Hessam
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; &amp;gt;
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; You received this message because you are subscribed to the Google Groups
&lt;br&gt;&amp;gt; &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;&amp;gt; To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26351137&amp;i=6&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;&amp;gt; To unsubscribe from this group, send email to
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26351137&amp;i=7&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;&amp;gt; For more options, visit this group at
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.
&lt;br&gt;&amp;gt; 
&lt;/div&gt;&lt;br&gt;&lt;br&gt;--
&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26351137&amp;i=8&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26351137&amp;i=9&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/-AMPL-2996--number-accuracy-in-writing-to-file-tp26313761p26351137.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26345981</id>
	<title>RE: [AMPL 3010] AMPL/MINOS support of complex numbers</title>
	<published>2009-11-13T16:54:38Z</published>
	<updated>2009-11-13T16:54:38Z</updated>
	<author>
		<name>Robert Fourer-2</name>
	</author>
	<content type="html">&lt;br&gt;There is no support for complex variables in AMPL. &amp;nbsp;You have to declare the
&lt;br&gt;real and imaginary parts (x and y) separately and write the objective and
&lt;br&gt;constraints in terms of those parts.
&lt;br&gt;&lt;br&gt;Bob Fourer
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26345981&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;4er@...&lt;/a&gt;
&lt;br&gt;&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; -----Original Message-----
&lt;br&gt;&amp;gt; From: Enrique Perea [mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26345981&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;enrique.perea@...&lt;/a&gt;]
&lt;br&gt;&amp;gt; Sent: Friday, November 13, 2009 2:04 PM
&lt;br&gt;&amp;gt; To: AMPL Modeling Language
&lt;br&gt;&amp;gt; Subject: [AMPL 3007] AMPL/MINOS support of complex numbers
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Hi,
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I'm working on a telecommunication application problem and some of my
&lt;br&gt;&amp;gt; variables and input parameter are complex-valued i.e. z= x + j*y,
&lt;br&gt;&amp;gt; where x,y are real.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Does AMPL/MINOS suport such complex variables?
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Does somebody know, any other solver that support them?
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Your help will be greatly appreciated,
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; -Diego Perea
&lt;br&gt;&amp;gt; Ph.D. student
&lt;br&gt;&amp;gt; Ecole Polytechnique de Montreal.
&lt;br&gt;&amp;gt; 
&lt;/div&gt;&lt;br&gt;&lt;br&gt;--
&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26345981&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26345981&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/-AMPL-3007--AMPL-MINOS-support-of-complex-numbers-tp26343121p26345981.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26345966</id>
	<title>RE: [AMPL 3009] Converting if-then-else statement to linear equations</title>
	<published>2009-11-13T16:52:28Z</published>
	<updated>2009-11-13T16:52:28Z</updated>
	<author>
		<name>Robert Fourer-2</name>
	</author>
	<content type="html">&lt;br&gt;The CPLEX message about a &amp;quot;nonquadratic nonlinear constraint&amp;quot; is due to the
&lt;br&gt;use of a variable following &amp;quot;if&amp;quot; in the constraint expression. &amp;nbsp;CPLEX
&lt;br&gt;doesn't recognize this as the sort of linear or quadratic expression that it
&lt;br&gt;can deal with.
&lt;br&gt;&lt;br&gt;The &amp;quot;presolve&amp;quot; messages are indicating that there are no feasible values for
&lt;br&gt;your variables, because your constraints imply conflicting bounds for some
&lt;br&gt;of them. &amp;nbsp;Without seeing the whole model I can't be sure why that is.
&lt;br&gt;&lt;br&gt;However, it seems to me that if your variables are nonnegative then it would
&lt;br&gt;suffice for you to write the constraints
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;t[i,m] &amp;gt;= a[i,m] - U[i,m] * (1-y[i,m])
&lt;br&gt;&lt;br&gt;where U[i,m] is an upper limit on the value that variable a[i,m] can be
&lt;br&gt;expected to take. &amp;nbsp;(For best results U[i,m] should not be chosen any larger
&lt;br&gt;than necessary.) &amp;nbsp;If the variables can be negative then you would also need
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;t[i,m] &amp;gt;= L[i,m] * y[i,m]
&lt;br&gt;&lt;br&gt;where L[i,m] is a (negative) lower limit on the value that variable t[i,m]
&lt;br&gt;can be expected to take. &amp;nbsp;With CPLEX you can also express these conditions
&lt;br&gt;using &amp;quot;indicator constraints&amp;quot; that are written in AMPL as
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;y[i,m] = 1 ==&amp;gt; t[i,m] &amp;gt;= a[i,m];
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;y[i,m] = 0 ==&amp;gt; t[i,m] &amp;gt;= 0;
&lt;br&gt;&lt;br&gt;where of course the second is unnecessary variables that are already
&lt;br&gt;declared nonnegative.
&lt;br&gt;&lt;br&gt;Bob Fourer
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26345966&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;4er@...&lt;/a&gt;
&lt;br&gt;&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; -----Original Message-----
&lt;br&gt;&amp;gt; From: hessam [mailto:&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26345966&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;hessam.1983@...&lt;/a&gt;]
&lt;br&gt;&amp;gt; Sent: Friday, November 13, 2009 5:32 PM
&lt;br&gt;&amp;gt; To: AMPL Modeling Language
&lt;br&gt;&amp;gt; Subject: [AMPL 3008] Converting if-then-else statement to linear equations
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Hi,
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I'm trying to implement the following condition in AMPL+CPLEX
&lt;br&gt;&amp;gt; solver: &amp;nbsp; (t[i,m] &amp;gt;= a[i,m]*y[i,m]) , in this condition, variables &amp;quot;t&amp;quot;
&lt;br&gt;&amp;gt; and &amp;quot;a&amp;quot; are numbers and variable &amp;quot;y&amp;quot; in binary.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I try to implement this in AMPL &amp;nbsp;like this:
&lt;br&gt;&amp;gt; --------------------------------------------------------------------------
&lt;br&gt;&amp;gt; -----------
&lt;br&gt;&amp;gt; subject to ......... : &amp;nbsp;t[i,m]&amp;gt;= (if y[i,m]=1 then a[i,m] else 0);
&lt;br&gt;&amp;gt; --------------------------------------------------------------------------
&lt;br&gt;&amp;gt; -----------
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; but I receive the following error in the AMPL:
&lt;br&gt;&amp;gt; CPLEX 11.2.1: /tmp/at13284.nl contains a nonquadratic nonlinear
&lt;br&gt;&amp;gt; constraint.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Then I tried to implement the constraint as linear equations so I
&lt;br&gt;&amp;gt; define a new variable named &amp;quot;ya&amp;quot; and I wrote the conditions as
&lt;br&gt;&amp;gt; following:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; subject to contition1 .....: &amp;nbsp;t[i,m]&amp;gt;= ya[i,m];
&lt;br&gt;&amp;gt; subject to contition2 .....: &amp;nbsp;a[i,m]&amp;gt;= ya[i,m];
&lt;br&gt;&amp;gt; subject to contition3 .....: &amp;nbsp;ya[i,m]&amp;gt;= 0;
&lt;br&gt;&amp;gt; subject to contition4 .....: &amp;nbsp;M*y[i,m] &amp;gt;= ya[i,m];
&lt;br&gt;&amp;gt; subject to contition5 .....: &amp;nbsp;M*(1-y[i,m])&amp;gt;=a[i,m]-ya[i,m];
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; M is an arbitrary big number. With this conditions, if y[i,m]=0 then
&lt;br&gt;&amp;gt; with condition 3 &amp; 4 we can claim ya[i,m]=0 and if y[i,m]=1 then with
&lt;br&gt;&amp;gt; condition 2 &amp; 5 we can claim ya[i,m]=a[i,m]. BUT when I try to solve
&lt;br&gt;&amp;gt; my ILP, I receive the following errors in AMPL:
&lt;br&gt;&amp;gt; presolve, variable ya[46,3,2]:
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; impossible deduced bounds: lower = 0, upper = -2.1338e-11
&lt;br&gt;&amp;gt; presolve, variable ya[46,3,1]:
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; impossible deduced bounds: lower = 0, upper = -2.1338e-11
&lt;br&gt;&amp;gt; presolve, variable ya[46,2,2]:
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; impossible deduced bounds: lower = 0, upper = -0.000546142
&lt;br&gt;&amp;gt; presolve, variable ya[46,2,1]:
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; impossible deduced bounds: lower = 0, upper = -0.000546142
&lt;br&gt;&amp;gt; presolve, variable ya[46,1,2]:
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; impossible deduced bounds: lower = 0, upper = -0.00157774
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; What is the problem?? Why I can't have if-then-else statement in my
&lt;br&gt;&amp;gt; code??
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Thanks all,
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; You received this message because you are subscribed to the Google Groups
&lt;br&gt;&amp;gt; &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;&amp;gt; To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26345966&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;&amp;gt; To unsubscribe from this group, send email to
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26345966&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;&amp;gt; For more options, visit this group at
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.
&lt;br&gt;&amp;gt; 
&lt;/div&gt;&lt;br&gt;&lt;br&gt;--
&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26345966&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26345966&amp;i=5&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/-AMPL-3008--Converting-if-then-else-statement-to-linear-equations-tp26345624p26345966.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26345624</id>
	<title>[AMPL 3008] Converting if-then-else statement to linear equations</title>
	<published>2009-11-13T15:32:22Z</published>
	<updated>2009-11-13T15:32:22Z</updated>
	<author>
		<name>hessam-4</name>
	</author>
	<content type="html">Hi,
&lt;br&gt;&lt;br&gt;I'm trying to implement the following condition in AMPL+CPLEX
&lt;br&gt;solver: &amp;nbsp; (t[i,m] &amp;gt;= a[i,m]*y[i,m]) , in this condition, variables &amp;quot;t&amp;quot;
&lt;br&gt;and &amp;quot;a&amp;quot; are numbers and variable &amp;quot;y&amp;quot; in binary.
&lt;br&gt;&lt;br&gt;I try to implement this in AMPL &amp;nbsp;like this:
&lt;br&gt;-------------------------------------------------------------------------------------
&lt;br&gt;subject to ......... : &amp;nbsp;t[i,m]&amp;gt;= (if y[i,m]=1 then a[i,m] else 0);
&lt;br&gt;-------------------------------------------------------------------------------------
&lt;br&gt;&lt;br&gt;but I receive the following error in the AMPL:
&lt;br&gt;CPLEX 11.2.1: /tmp/at13284.nl contains a nonquadratic nonlinear
&lt;br&gt;constraint.
&lt;br&gt;&lt;br&gt;Then I tried to implement the constraint as linear equations so I
&lt;br&gt;define a new variable named &amp;quot;ya&amp;quot; and I wrote the conditions as
&lt;br&gt;following:
&lt;br&gt;&lt;br&gt;subject to contition1 .....: &amp;nbsp;t[i,m]&amp;gt;= ya[i,m];
&lt;br&gt;subject to contition2 .....: &amp;nbsp;a[i,m]&amp;gt;= ya[i,m];
&lt;br&gt;subject to contition3 .....: &amp;nbsp;ya[i,m]&amp;gt;= 0;
&lt;br&gt;subject to contition4 .....: &amp;nbsp;M*y[i,m] &amp;gt;= ya[i,m];
&lt;br&gt;subject to contition5 .....: &amp;nbsp;M*(1-y[i,m])&amp;gt;=a[i,m]-ya[i,m];
&lt;br&gt;&lt;br&gt;M is an arbitrary big number. With this conditions, if y[i,m]=0 then
&lt;br&gt;with condition 3 &amp; 4 we can claim ya[i,m]=0 and if y[i,m]=1 then with
&lt;br&gt;condition 2 &amp; 5 we can claim ya[i,m]=a[i,m]. BUT when I try to solve
&lt;br&gt;my ILP, I receive the following errors in AMPL:
&lt;br&gt;presolve, variable ya[46,3,2]:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; impossible deduced bounds: lower = 0, upper = -2.1338e-11
&lt;br&gt;presolve, variable ya[46,3,1]:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; impossible deduced bounds: lower = 0, upper = -2.1338e-11
&lt;br&gt;presolve, variable ya[46,2,2]:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; impossible deduced bounds: lower = 0, upper = -0.000546142
&lt;br&gt;presolve, variable ya[46,2,1]:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; impossible deduced bounds: lower = 0, upper = -0.000546142
&lt;br&gt;presolve, variable ya[46,1,2]:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; impossible deduced bounds: lower = 0, upper = -0.00157774
&lt;br&gt;&lt;br&gt;&lt;br&gt;What is the problem?? Why I can't have if-then-else statement in my
&lt;br&gt;code??
&lt;br&gt;&lt;br&gt;Thanks all,
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;--
&lt;br&gt;&lt;br&gt;You received this message because you are subscribed to the Google Groups &amp;quot;AMPL Modeling Language&amp;quot; group.
&lt;br&gt;To post to this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26345624&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl@...&lt;/a&gt;.
&lt;br&gt;To unsubscribe from this group, send email to &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26345624&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ampl+unsubscribe@...&lt;/a&gt;.
&lt;br&gt;For more options, visit this group at &lt;a href=&quot;http://groups.google.com/group/ampl?hl=&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://groups.google.com/group/ampl?hl=&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/-AMPL-3008--Converting-if-then-else-statement-to-linear-equations-tp26345624p26345624.html" />
</entry>

</feed>
