Error Topic is solved

Solver related questions
Post Reply
Rofice
User
User
Posts: 28
Joined: 6 years ago

Error

Post by Rofice »

I am finding error in objective function, I will highly appreciate, If somebody tell me reason of error. Below is the detail of model..

sets

str process streams / 1*2/
comp compressor /1/
compon component feed /h2/
icomp(comp,str) inlet stream of compressor /1.1/
ocomp(comp,str) outlet stream of compressor /1.2/
com(comp,compon) compressor feed match /1.h2/ ;


scalars
alpha compressor efficiency /.3665/
compeff compressor efficiency /0.750/
gam ratio of cp to cv /1.300/
costelec electricity cost /0.340/ ;

positive variable

f(str) stream flow-rates (kg-mole per min)
fc(str,compon) component flow-rates (kg-mole per min)
p(str) stream pressure (mega_pascal)
t(str) stream temperature (100 k)
elec(comp) objective function
presrat(comp), z
;

equations

compcmb(comp,compon) component balance for compressor
comphb(comp) heat balance for compressor
compelec(comp) energy balance for compressor
ratio(comp) pressure ratio (out to in)
obj objective function ;

compcmb(comp,compon)..
sum( str $ ocomp(comp,str) , fc(str,compon) ) =e=
sum( str $ icomp(comp,str) , fc(str,compon) ) ;

comphb(comp)..
sum( str $ ocomp(comp,str) , t(str) ) =e=
presrat(comp) * sum( str $ icomp(comp,str) , t(str) ) ;

compelec(comp)..
elec(comp) =e=
alpha * ( presrat(comp) - 1) *
sum( str $ icomp(comp,str) , 100. * t(str) * f(str) / 60. ) *
(1 / compeff) * ( gam / ( gam - 1. ) ) ;


ratio(comp)..
presrat(comp) ** ( gam / ( gam - 1. ) ) =e=
sum( str $ ocomp(comp,str) , p(str) ) /
sum( str $ icomp(comp,str) , p(str) ) ;

obj.. z=e= sum(comp,(costelec)*elec(comp)) ;

model m /all/ ;
solve m using lp minimizing z;
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: Error

Post by Renger »

Hi Rofice

Your variable z can't be a positive variable but should be free (this is also indicated in the listing).
Furthermore, your model is not an LP but a NLP.
It is also good to give your model some sensible start values, so you won't get problems with divisions (GAMS otherwise assumes zero as start value).

Cheers
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Rofice
User
User
Posts: 28
Joined: 6 years ago

Re: Error

Post by Rofice »

Thank you very much for helping me.

Could you tell me how to make set controlled, As I am freshman, so mostly the error I receive is "uncontrolled set entered as a constant"

for example just see this syntax

material.. sum(pm(i,m),spltfrc(i,m)*f(i)) =e= sum(fm(i,m),f(i)) ;
User avatar
Renger
Posts: 639
Joined: 7 years ago

Re: Error

Post by Renger »

search for "uncontrolled set" in this forum and you will find your answer.
Renger
____________________________________
Enjoy modeling even more: Read my blog on modeling at The lazy economist
Mr.South
User
User
Posts: 1
Joined: 6 years ago

Re: Error

Post by Mr.South »

I am finding error in constraints, I will highly appreciate, If somebody tell me reason of error. Below is the detail of model..

1 Sets
2 i blocks / 1, 2 /
3 j floors / 1, 2 /
4 k activities / 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120,
130,
5 140, 150, 160, 170, 180, 190, 200, 210, 220, 230,
240,
6 250, 260, 270, 280, 290, 300, 310, 320, 330, 340,
350 /
7 m modes / 1, 2 /
8 t time periods / 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
,20,21,22,23,24,25,
9 26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41
,42,43,44,45,46,47,48,49,50 / ;
10
11
12
13 Table d(k,m) duration of activity k if performed in mode m
14 1 2
15 10 2 1
16 20 2 1
17 30 2 1
18 40 2 1
19 50 2 1
20 60 2 1
21 70 2 1
22 80 2 1
23 90 2 1
24 100 2 1
25 110 2 1
26 120 2 1
27 130 2 1
28 140 2 1
29 150 2 1
30 160 2 1
31 170 2 1
32 180 2 1
33 190 2 1
34 200 2 1
35 210 2 1
36 220 4 2
37 230 4 2
38 240 4 2
39 250 4 2
40 260 4 2
41 270 2 1
42 280 2 1
43 290 2 1
44 300 2 1
45 310 2 1
46 320 2 1
47 330 2 1
48 340 2 1
49 350 2 1 ;
50
51 Scalars
52 ineff daily payment for inefficient subcontractors /1000/
53 eff daily payment for efficient subcontractors /2500/
54 penalty penalty cost if project completion time exceeds 24 weeks
/20000/ ;
55
56
57
58
59 Variables
60 x(i,j,k,m,t) if activity k for i th block for j th floor at mo
de m is completed in period t
61 y(i,k,m,t) if activity k for i th block at mode m is complet
ed in period t
62 z total cost ;
63
64 binary variable x ;
65 binary variable y ;
66 binary variable a ;
67 binary variable b ;
68
69
70
71
72
73
74 Equations
75 cost
76 activity_f(i,j,k) ensures activiy completed
77 activity_b(i,k) ensures activity completed
78 precedence1
79
80 ;
81
82
83 cost.. z =e= sum((i,j,k,t),x(i,j,k,'1',t)*d(k,'1'))*ineff + sum((i,k,t),y(i,k,'2',t)*d(k,'2'))*eff ;
84 activity_f(i,j,k).. sum((m,t),x(i,j,k,m,t))=e= 1 ;
85 activity_b(i,k).. sum((m,t),y(i,k,m,t)) =e= 1 ;
86 precedence1(i,j).. sum((k,m,t)$(ord(k) eq 20),(t-d(k,m))*x(i,j,k,m,t
**** $148 $133
)) =g= sum((k,m,t)$(ord(k) eq 10),t*x(i,j,k,m,t));
$148
87
88
89
90 Model MinimizingTotalCostUnderNoResourceLimitations / all / ;
91
92 Solve MinimizingTotalCostUnderNoResourceLimitations using lp minimizing z
;
**** $257
93
94 Display z.l, x.l, y.l ;
**** $141 $141 $141
Post Reply