[Cmpl] Error

Prof. Dr. Mike Steglich mike.steglich at stegger.net
Sat Jun 28 11:45:27 EDT 2014


Hi Oscar,

sum{i in FARMS,  Please use : instead of the comma

This should work if this constraint is to be formulated one times:
Constraint:   sum{i in FARMS, j in FARMS: XS[i,j] } >= sum{ i in FARMS: Alpha*Q[i] } ;   	

If you want to formulate a couple of constraints using a loop it should be formulated like this:

Constraint {  index in set :  sum{i in FARMS, j in FARMS: XS[i,j] } >= sum{ i in FARMS: Alpha*Q[i] }   ;  }	

I hope that works. I did not test it.

Cheers,

Mike


Am 28.06.2014 um 17:00 schrieb Oscar Augusto Téllez Sánchez <oskarts at gmail.com>:

> Thank you!
> 
> this is my new challenge…i don´t understand the error in this constrain, i have tried in different  ways but nothing… (alpha is a constant like 1)
> 
> 
> 	Constraint {sum{i in FARMS, j in FARMS: XS[i,j]} >= sum{i in FARMS,Alpha*Q[i]};}	
> 
> thank you in advance
> 
> Oscar
> 
> this is the program just in case...
> 
> 
> #%data biomass-data-Small.cdat : SIZE set
> %data biomass-data-Small.cdat :  FARMS set, SP, TC, PC, Q[FARMS], d[FARMS,FARMS], gamma[FARMS], CF, Alpha, K
> variables:
> 	#Quantity of waste treated at plant i
> 	X[FARMS]: real[0..];
> 	#Quantity of waste send from farm j to plant i
> 	XS[FARMS,FARMS]: real[0..];
> 	#1 if plant i is installed with capacity k
> 	Y[FARMS]: binary;
> 	#1 if we send waste from farm j to plant i
> 	W[FARMS,FARMS]: real[0..];
> 	
> 
> objectives:
> 	Profit: sum{i in FARMS: (SP-PC)* X[i] } 
> 		- sum{i in FARMS, j in FARMS : TC * XS[i,j] * d[i,j]}
> 		- sum{i in FARMS : CF*Y[i] } ->max;
> 
> constraints:
> 	
> 	# you cannot send more than farm´s capacity-
> 	farms {j in FARMS: sum{i in FARMS: XS[i,j]} <= sum{i in FARMS:Q[j]*W[i,j]};}
> 
> 	#A farm can only send to one plant-
> 	exclusivity {j in FARMS : sum{i in FARMS: W[i,j]} <= 1;}
> 
> 	#Maximum one plant per site-
> 	nPlants {i in FARMS : Y[i] <= 1;}
> 
> 	#You can send to i only if there is a plant there-
> 	cond1 {i in FARMS,j in FARMS: W[i,j] <= Y[i];}
> 	
> 	#Production capacity-
> 	#ProductionCap: X[] <= K*Y[]; 
> 	ProductionCap {i in FARMS: X[i] <= K*Y[i];} 
> 
> 	# Equivanlence between what is send (waste) and what is produce (methane)-
> 	equivalence {i in FARMS: X[i] = sum{j in FARMS: gamma[i]*XS[i,j]};}	
> 
> 	Constraint {sum{i in FARMS, j in FARMS: XS[i,j]} >= sum{i in FARMS,Alpha*Q[i]};}	
> 
> 
> On Jun 2, 2014, at 4:24 PM, Mike Steglich <mike.steglich at th-wildau.de> wrote:
> 
>> Hallo Oscar,
>> 
>> X[farms] is defined as variable vector, but in the constraint
>>> farms {j in FARMS: sum{i in FARMS: X[i,j]} <= sum{i in FARMS:Q[j]*W[i,j]};}
>> used as variable matrix X[i,j]. Could it be possible that you wanted to use the matrix XS in this constraint?
>> 
>> Cheers,
>> 
>> Mike
>> 
>> 
>> Am 01.06.2014 um 23:36 schrieb Oscar Augusto Téllez Sánchez <oskarts at gmail.com>:
>> 
>>> Thank you very much!
>>> 
>>> i have found these and some errors more. however, with the last one…i give up, any idea? i have tried many ways but nothing
>>> 
>>> create model instance ...
>>> error (compiler): file biomass.cmpl line 21: array dimensions don't match
>>> CMPL model generation - failed
>>> 
>>> here is new version of program:
>>> 
>>> %data biomass-data.cdat : FARMS set, SIZE set, SP,TC,PC,CF[SIZE], Q[FARMS], K[SIZE],d[FARMS,FARMS], gamma[FARMS]
>>> 
>>> variables:
>>> 	#Quantity of waste treated at plant i
>>> 	X[FARMS]: real[0..];
>>> 	#Quantity of waste send from farm j to plant i
>>> 	XS[FARMS,FARMS]: real[0..];
>>> 	#1 if plant i is installed with capacity k
>>> 	Y[FARMS,SIZE]: binary;
>>> 	#1 if we send waste from farm j to plant i
>>> 	W[FARMS,FARMS]: real[0..];
>>> 
>>> objectives:
>>> 	Profit: sum{i in FARMS: (SP-PC)* X[i] } 
>>> 		+ sum{i in FARMS, j in FARMS : TC * XS[i,j] * d[i,j]}
>>> 		+ sum{i in FARMS, k in SIZE : Y[i,k] * CF[k] } ->max;
>>> 
>>> constraints:
>>> 	
>>> 	# you cannot send more than farm´s capacity
>>> 	farms {j in FARMS: sum{i in FARMS: X[i,j]} <= sum{i in FARMS:Q[j]*W[i,j]};}
>>> 
>>> 	#A farm can only send to one plant
>>> 	exclusivity {i in FARMS : sum{j in FARMS: W[i,j]} = 1;}
>>> 	
>>> 	#Maximum one plant per site
>>> 	nPlants {i in FARMS : sum{k in SIZE: Y[i,k]} <= 1;}
>>> 
>>> 	#You can send to i only if there is a plant there
>>> 	cond1 {i in FARMS: sum{j in FARMS: W[i,j]} <= sum{k in SIZE: Y[i,k]};}
>>> 	
>>> 	#Production capacity
>>> 	ProductionCap: X[] <= K[]*Y[,]; 
>>> 
>>> 	# Equivanlence between what is send (waste) and what is produce (methane)
>>> 	equivalence {i in FARMS: gamma[i]*X[i] = sum{j in SIZE: XS[i,j]};}	
>>> 	
>>> thank you in advance
>>> 
>>> Oscar
>>> 
>>> On Jun 1, 2014, at 9:35 PM, Mike Steglich <mike.steglich at berlin.de> wrote:
>>> 
>>>> Hi Oscar,
>>>> 
>>>> In line 16 you specified K as index in the sum header but k is used within the sum body. The same issue is happened in line 20: k defined in the sum header but K is used in the body.
>>>> 
>>>> Cheers,
>>>> 
>>>> Mike
>>>> 
>>>> Am 01.06.2014 um 16:45 schrieb Oscar Augusto Téllez Sánchez <oskarts at gmail.com>:
>>>> 
>>>>> Good day,
>>>>> 
>>>>> here is my problem… when i run my program this is the message
>>>>> 
>>>>> create model instance ...
>>>>> error (compiler): file biomass.cmpl line 16: syntax error, unexpected ASSIGN_ITER, expecting ':'
>>>>> error (compiler): file biomass.cmpl line 20: syntax error, unexpected ASSIGN_ITER, expecting ':'
>>>>> error (compiler): file biomass.cmpl line 20: syntax error, unexpected '}', expecting end of file
>>>>> CMPL model generation - failed
>>>>> 
>>>>> I am following the standard and i don´t know why is asking me to put (:)  any idea how to solve it? (in bold are the referred lines)
>>>>> 
>>>>> thank you in advance ;) my code is below
>>>>> 
>>>>> Oscar
>>>>> 
>>>>> Program:
>>>>> %data biomass-data.cdat : FARMS set, SIZE set, SP,TC,PC,CF[SIZE], Q[FARMS], K[SIZE],d[FARMS,FARMS], gamma[FARMS]
>>>>> 
>>>>> variables:
>>>>> 	#Quantity of waste treated at plant i
>>>>> 	X[FARMS]: real[0..];
>>>>> 	#Quantity of waste send from farm j to plant i
>>>>> 	XS[FARMS,FARMS]: real[0..];
>>>>> 	#1 if plant i is installed with capacity k
>>>>> 	Y[FARMS,SIZE]: binary;
>>>>> 	#1 if we send waste from farm j to plant i
>>>>> 	W[FARMS,FARMS]: real[0..];
>>>>> 
>>>>> objectives:
>>>>> 	Profit: sum{i in FARMS: (SP-PC)* X[i] } 
>>>>> 		+ sum{i in FARMS, j in FARMS : TC * XS[i,j] * d[i,j]}
>>>>> 		+ sum{i in FARMS, K in SIZE : Y[i,k] * CF[k] } ->max;
>>>>> 
>>>>> constraints:
>>>>> 	#Maximum one plant per site
>>>>> 	nPlants {i in FARMS : sum{k in SIZE: Y[i,K]} <= 1;}
>>>>> 	
>>>>> 	#A farm can only send to one plant
>>>>> 	exclusivity {i in FARMS : sum{j in FARMS: W[i,j]} = 1;}
>>>>> 	
>>>>> 	#You can send to i only if there is a plant there
>>>>> 	cond1 {i in < FARMS: sum{j in FARMS: W[i,j]} <= sum{k in SIZE: Y[i,K]};}
>>>>> 	
>>>>> 	# Equivanlence between what is send (waste) and what is produce (methane)
>>>>> 	equivalence {i in < FARMS: gamma[i]*X[i] = sum{j in SIZE: XS[i,j]};}		
>>>>> 	
>>>>> 	#Production capacity
>>>>> 	ProductionCap {i in < FARMS: x[i] <= sum{k in SIZE: Y[i,K]*KP[K]};}
>>>>> 	
>>>>> 	# you cannot send more than farm´s capacity
>>>>> 	farmsCapacity {j in < FARMS: sum{i in FARMS: X[i,j]} <= sum{i in FARMS: W[i,j]*Q[j]};}
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>>> _______________________________________________
>>>>>> Cmpl mailing list
>>>>>> Cmpl at list.coin-or.org
>>>>>> http://list.coin-or.org/mailman/listinfo/cmpl
>>>>> 
>>>>> _______________________________________________
>>>>> Cmpl mailing list
>>>>> Cmpl at list.coin-or.org
>>>>> http://list.coin-or.org/mailman/listinfo/cmpl
>>> 
>>> _______________________________________________
>>> Cmpl mailing list
>>> Cmpl at list.coin-or.org
>>> http://list.coin-or.org/mailman/listinfo/cmpl
> 
> _______________________________________________
> Cmpl mailing list
> Cmpl at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/cmpl

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/cmpl/attachments/20140628/a11d8c2c/attachment.html>


More information about the Cmpl mailing list