Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Manual de GAMS PDF
Manual de GAMS PDF
273
EL problema del transporte
Distancias en Km.
mercados
plantas m1 m2 m3
p1 2.0 1.6 1.8
p2 2.5 1.2 1.4
El problema consiste en
XX
Minimizar cij xij
i j
P
j xij ≤ ai, ∀i
i xij ≥ bj , ∀j
P
sujeta a
xij ≥ 0, ∀i, j,
Los datos son:
i: Número de plantas (2).
j: Número de mercados (3).
ai: La máxima capacidad de producción de la planta i en
toneladas (300 y 500 toneladas),
bj : La demanda del mercado j en toneladas (100, 200 y 300
toneladas), y
cij : el coste de transporte de la planta i al mercado j (0.09
dólares por tonelada y km).
Las variables de decisión son:
xij : la cantidad de producto a enviar de la planta i al mercado
j, en toneladas.
274
Problema del transporte
Código GAMS
275
Algunos comandos de GAMS
Comando Propósito
Set(s) Dar nombre a los ı́ndices
y definir sus posibles valores
Scalar(s) Dar nombre a los escalares
y asignarles valores
Parameter(s) Dar nombre a los vectores
y asignarles valores
Table(s) Dar nombre a las matrices
y asignarles valores
Variable(s) Declarar variables,
asignarles un tipo (opcional)
y darles cotas inferior y superior
Equation(s) Definir la función a optimizar
y las restricciones
Model Dar nombre a los modelos
y asignarles la lista de restricciones
Solve Indicar a GAMS el programa
que debe resolverlo
Display Decir a GAMS los elementos
a listar en el informe de salida
276
Reglas de GAMS
277
SETS y SCALARS
Alias(i,k);
278
PARAMETERS y TABLES I
279
PARAMETERS y TABLES II
280
Expresiones matemáticas
281
Funciones matemáticas en GAMS
Función Descripción
abs(x) Valor absoluto de x
arctan(x) Arco tangente (en radianes)
ceil(x) Mı́nimo entero mayor o igual que x
cos(x) Función coseno (x en radianes)
errorf(x) Función de distribuciónn
de la normal N (0, 1) en x
exp(x) Función exponencial
floor(x) Mayor entero menor o igual que x
log(x) Logaritmo natural de x
log10(x) Logaritmo en base 10 de x
mapval(x) Función proyección
max(x1,x2,...) Máximo de una lista
min(x1,x2,...) Mı̀nimo de una lista
mod(x,y) Resto al dividir x por y
normal(x,y) Número aleatorio de una variable normal
con media x y desviación tı́pica y
power(x,y) Función potencial xy (donde y debe ser un entero)
x ∗ ∗y Función potencial xy (donde x debe ser positiva)
round(x) Redondeo de x al entero más cercano
round(x,y) Redondea x a y decimales
sign(x) Signo de x, 1 si positivo, -1 si negativo, y 0 si nulo.
sin(x) Función seno (en radianes)
sqr(x) Cuadrado de x
sqrt(x) Raı́z cuadrada de x
trunc(x) Es igual a sign(x) * floor(abs(x))
uniform(x,y) Número aleatorio uniforme U (x, y)
282
Variables
Positive Variable x;
Binary Variable r;
Se pueden fijar también cotas para las variables, o fijar sus valores (no
cambian durante la ejecución):
r.lo = 2.0;
r.up = 5.0;
y.fx(i) = 3.0;
y cambiar los valores de las variables durante la ejecución:
s.l(i,j) = 3.0;
283
EQUATIONS
Equations
cost objective function
supply(i) meet supply limit at plant i
demand(j) satisfy demand at market j;
cost .. z =e= sum((i,j), c(i,j)*x(i,j));
supply(i) .. sum(j, x(i,j)) =l= a(i);
demand(j) .. sum(i, x(i,j)) =g= b(j);
P
El sumatorio i xij se expresa sum(i, x(i,j)), y Πixij , se escribe
prod(i, x(i,j)).
Los sı́mbolos que se utilizan en las ecuaciones son:
• =e= indica ‘es igual a’,
• =l= indica ‘es menor o igual que’, y
• =g= indica ‘es mayor o igual que’.
Se pueden definir muchas ecuaciones simultáneamente, usando ı́ndices:
supply(i) .. sum(j, x(i,j)) =l= a(i);
es equivalente a:
284
MODEL AND SOLVE
285
Información sobre recursos
286
Uso del asterisco
es euivalente a
287
Comandos condicionales
288
Conjuntos dinámicos I
289
Conjuntos dinámicos II
290
Comandos de control
loop(S,
loop(JJ,
x0=0.0001;
x1=2.0;
aux=W0.l(JJ)+sum(I,W.l(JJ,I)*X(I,S));
error=1000;
f0=sum(R$(ord(R)<4),alpha.l(JJ,R)*(x0**ord(R)))
+alpha.l(JJ,’4’)*arctan(x0)-aux;
f1=sum(R$(ord(R)<4),alpha.l(JJ,R)*(x1**ord(R)))
+alpha.l(JJ,’4’)*arctan(x1)-aux;
put "aux=",aux:12:8, " f0=",f0:12:8," f1=",f1:12:8/;
if(f0*f1>0.0,
put "POSSIBLE ERROR EN INVERSAS"/;
);
while(error gt 0.00001,
error=abs(x0-x1);
x2=(x0+x1)*0.5;
f2=sum(R$(ord(R)<4),alpha.l(JJ,R)*(x2**ord(R)))
+alpha.l(JJ,’4’)*arctan(x2)-aux;
if(f2*f0>0.0,
f0=f2;
x0=x2;
else
f1=f2;
x1=x2;
););
aux=(x0+x1)*0.5;
gam(JJ,S)=rho*gam(JJ,S)+(1.0-rho)*(1.0/abs(aux-Y(JJ,S)));
if(maxerror(J)<abs(aux-Y(JJ,S)),maxerror(J)=abs(aux-Y(JJ,S)));
meanerror(JJ)=meanerror(JJ)+abs(aux-Y(JJ,S));
var(JJ)=var(JJ)+sqr(abs(aux-Y(JJ,S)));
););
291
Salidas usando ficheros
292
El problema del transporte I
m
X n
X
Minimizar Z = cij xij . (1)
i=1 j=1
sujeta a
n
P
xij = ui; ∀i = 1 . . . m,
j=1
m
P
xij = vj ; ∀j = 1 . . . n, (2)
i=1
xij ≥ 0; ∀i = 1 . . . m; ∀j = 1 . . . n,
donde m = n = 3 y
1 2 3
2 5
C = 2 1 2 , u = 3 , y v = 2 .
3 2 1 4 2
$title THE TRANSPORTATION PROBLEM
SETS
I index of shipping origins /I1*I3/
J index of shipping destinations /J1*J3/;
PARAMETERS
U(I) the amount of good to be shipped from origin I
/I1 2
I2 3
I3 4/
V(J) the amount of good to be received in destination J
/J1 5
J2 2
J3 2/;
293
El problema del transporte II
VARIABLES
z objective function variable
x(I,J) the amount of product to be shipped from I to J;
EQUATIONS
COST objective function equation
SHIP(I) shipping equation
RECEIVE(J) receiving equation;
294
El problema de planificación
de la producción I
n
X
Maximizar Z = (atyt − btxt − ctst), (3)
t=1
sujeta a
st−1 + xt − st = yt, ∀t = 1 . . . n,
(4)
s t , x t , yt ≥ 0.
donde at = bt = ct = 1, ∀t = 1 . . . n; n = 4; s0 = 2 y
y = (2, 3, 6, 1)T .
SET
T The month index /0*4/;
PARAMETER
Y(T) demand in month T
/1 2
2 3
3 6
4 1/
A(T)
B(T)
C(T);
295
El problema de planificación
de la producción II
VARIABLES
z objective function variable
x(T) number of units produced in month T
s(T) number of units in storage in month T;
s.fx(‘0’)=2;
EQUATIONS
COST objective function
INOUT(T) input and output balance;
296
El problema de la dieta I
n
X
Minimizar Z = cj xj , (5)
j=1
sujeta a
n
P
aij xj ≥ bi; i = 1 . . . m
j=1
xj ≥ 0; j = 1 . . . n.
donde m = 4, n = 5 y
1
78.6
70.1 80.1 67.2 77.0 74.2
0.5
6.50
9.40 8.80 13.7 30.4
14.7
A=
, b =
,
and c = 2
.
0.02
0.09 0.03 0.14 0.41
0.14
1.2
0.27 0.34 0.30 1.29 0.86 0.55
3
SET
I set of nutrients /DN,DP,Ca,Ph/
J set of foods /Corn,Oats,Milo,Bran,Linseed/;
PARAMETERS
B(I) the minimum required amount of nutrient I
/DN 74.2
DP 14.7
Ca 0.14
Ph 0.55/
C(J) cost of one unit of food J
/Corn 1
Oats 0.5
Milo 2
Bran 1.2
Linseed 3/;
297
El problema de la dieta II
VARIABLES
z objective function variable
x(J) the amount of food J to be purchased
EQUATIONS
COST objective function
NUTFOOD(I) nutrients and food relation;
298
Despacho económico I
n
X
Minimizar Z = Ci pi, (7)
i=1
sujeto a
δk = 0
j∈Ωi Bij (δi − δj ) + pi
P
= Di; i = 1, 2, . . . , n.
−P ij ≤ Bij (δi − δj ) ≤ P ij ; ∀j ∈ Ωi, i = 1, 2, . . . , n.
P i ≤ pi ≤ P i; i = 1, 2, . . . , n.
(8)
donde n = 3, k = 3 ,
0.15 0.6 6
p= , p= , c = ,
0.10 0.4 7
0.0 2.5 3.5 0.0 0.0 0.3 0.5
B = 2.5 0.0 3.0 , D = 0.0 , P = 0.3 0.0 0.4 ,
3.5 3.0 0.0 0.85 0.5 0.4 0.0
Ω1 = {2, 3}, Ω2 = {1, 3}, y Ω3 = {1, 2},
y la variables son p1, p2, δ1 and δ2.
$title THE ECONOMIC DISPATCH PROBLEM
SETS
G index of generators /G1*G2/
N index of buses /N1*N3/
MAP(G,N) associates generators with buses /G1.N1,G2.N2/;
ALIAS(N,NP);
299
Despacho económico II
PARAMETER
LOAD(N) load at bus N / N3 0.85 /
VARIABLES
z objective function variable
p(G) output power for generator G
d(N) angle at bus N;
p.lo(G)=GDATA(G,’PMIN’);
p.up(G)=GDATA(G,’PMAX’);
d.fx(’N3’)=0;
EQUATIONS
COST objective function
MAXPOW(N,N) maximum line power limit
MINPOW(N,N) minimum line power limit
LOADBAL(N) load balance equation;
COST.. z =e= SUM(G,GDATA(G,’COST’)*p(G));
MAXPOW(N,NP).. LDATA(N,NP,’SUS’)*(d(N)-d(NP))=l= LDATA(N,NP,’LIMIT’);
MINPOW(N,NP).. LDATA(N,NP,’SUS’)*(d(N)-d(NP))=g=-LDATA(N,NP,’LIMIT’);
LOADBAL(N).. SUM(G$MAP(G,N),p(G))+SUM(NP,LDATA(N,NP,’SUS’)
*(d(N)-d(NP))+LDATA(NP,N,’SUS’)*(d(N)-d(NP)))=e=LOAD(N);
MODEL ed /COST,MAXPOW,MINPOW,LOADBAL/;
SOLVE ed USING lp MINIMIZING z;
300
Problema de la red de flujo I
X
Minimizar Z = cij xij
ij
sujeta a
P
(xij − xji) = fi; i = 1, . . . , n;
j
−fij ≤ xij ≤ fij ; ∀i < j.
donde n = 4, se supone que fij = 4, ∀i, j, y (f1, f2, f3, f4) =
(7, −4, −1, −2) y cij = 1; ∀i, j.
$title NETWORK FLOW PROBLEM
SET
I set of nodes in the network /I1*I4/
CONEX(I,I) set of node connections
/I1.I2,I1.I3,I1.I4,I2.I4,I3.I4/;
ALIAS(I,J)
PARAMETERS
F(I) the input or output flow at node I
/I1 7
I2 -4
I3 -1
I4 -2/
FMAX(I,J) maximum flow capacity of conduction from I to J;
FMAX(I,J)=4;
VARIABLES
z objective function variable
x(I,J) the flow going from node I to node J
301
Problema de la red de flujo II
La solución es:
Z = 5, x12 = 0, x13 = 3, x14 = 4, x24 = −4, x34 = 2.
302
La cartera de valores I
X
Maximizar Z = dj (bj + xj ) (9)
j
sujeta a
bi + xi ≥ 0
r(Pj vj (bj + xj )) ≤ vi(bi + xi)
P (10)
j vj x j = 0
P
j wj (bj + xj ) ≥ (1 + s) Pj vj bj .
Sea el caso particular de tres acciones, 75 de A1, 100 de A2
y 35 de A3, con valores $20, $20 y $100, respectivamente.
Además, se tiene la información: A1 no dará dividendos con
un nuevo valor $18, A2 pagará $3 por acción y su valor será
$23, y A3 pagará $5 por acción con nuevo valor $102. Si se
toma r = 0.25 y s = 0.03, se tiene
xA ≥ −75,
xB ≥ −100,
xC ≥ −35,
0.25 [20(75 + xA) + 20(100 + xB ) + 100(35 + xC )] ≤ 20(75 + xA),
0.25 [20(75 + xA) + 20(100 + xB ) + 100(35 + xC )] ≤ 20(100 + xB ),
0.25 [20(75 + xA) + 20(100 + xB ) + 100(35 + xC )] ≤ 100(35 + xC ),
20xA + 20xB + 100xC = 0,
18(75 + xA) + 23(100 + xB ) + 102(35 + xC ) ≥ 1.03(20(175)+3500).
ALIAS(I,J);
303
La cartera de valores II
TABLE data(I,*)
B V D W
* ($) ($) ($)
A1 75 20 0 18
A2 100 20 3 23
A3 35 100 5 102
VARIABLES
z objective function variable
x(I) number of shares of stock I;
POSITIVE VARIABLE x(I);
x.lo(I)=-data(I,’B’);
EQUATIONS
COST objective function
NOCHANGE no change in the current value
INFLATION future value must be 3\% greater than the current value
BALANCE(I) to avoid excessive reliance on a single stock;
La solución es:
Z = 612.5 en el punto xA = 12.5, xB = 75.0, xC = −17.5.
304
El andamio I
X
Maximizar Z = xi
i
sujeta a
TE + TF = x2 ,
TC + TD = TF ,
TA + TB = x1 + TC + TD ,
10TF = 5x2,
8TD = 6TF ,
10TB = 5x1 + 2TC + 10TD .
$title SCAFFOLDING PROBLEM (LINEAR)
SET
B set of beams /B1*B3/
R set of ropes /RA,RB,RC,RD,RE,RF/
L set of loads /L1,L2/
UPP(B,R)
/ B1.(RA,RB)
B2.(RC,RD)
B3.(RE,RF)/
DOWN(B,R)
/ B1.(RC,RD)
B2.(RF)/
LOAD(B,L)
/ B1.L1
B3.L2/;
PARAMETER LMAX(R) maximum load for ropes
/ (RA,RB) 300
(RC,RD) 200
(RE,RF) 100/;
305
El andamio II
La solución es:
Z = 640; x1 = 440, x2 = 200; TA = 240,
TB = 300, TC = 25, TD = 75, TE = 100, TF = 100.
306
El armador I
n
X
Maximizar Z = cj xj
j=1
sujeta a
n
X
aj xj ≤ b,
j=1
xj ∈ {0, 1} ∀j = 1 · · · n.
donde se ha supuesto que aj = cj , b = 700 y
a = (100, 155, 50, 112, 70, 80, 60, 118, 110, 55)T .
$title 0-1 KNAPSACK PROBLEM.
OPTION OPTCR=1e-10;
SET
J set of containers /c1*c10/;
PARAMETERS
C(J) benefit of container J
/c1 100
c2 155
c3 50
c4 112
c5 70
c6 80
c7 60
c8 118
c9 110
c10 55/
A(J) weight of container J;
A(J) = C(J);
307
El armador II
VARIABLES
z objective function variable
x(J) binary choice;
BINARY VARIABLE x;
EQUATIONS
COST objective function
CAPA is the loading of the freighter;
308
Problema de la distribución de energı́a I
K X
X J
Minimizar Z = [Aj vj (k) + Bj pj (k) + Cj yj (k) + Dj zj (k)]
k=1 j=1
(11)
sujeta a
P j vj (k) ≤ pj (k) ≤ P j vj (k); ∀j, ∀k,
pj (k + 1) − pj (k) ≤ Sj ; ∀j, k = 0, · · · , K − 1,
pj (k) − pj (k + 1) ≤ Tj ; ∀j, k = 0, · · · , K − 1,
(12)
yj (k) − zj (k) = vj (k) − vj (k − 1); ∀j, k = 1, · · · , K,
PJ
j=1 pj (k) = D(k); ∀k,
PJ
j=1 P j vj (k) ≥ D(k) + R(k); ∀k,
donde K = 4, J = 3, y
50
350
300
200
P=
80 , P = 200 , T = 150 , S = 100 ,
40 140 100 100
5
20
0.5
0.100
A=
7 , B = 18 , C = 0.3 , E = 0.125 ,
6 5 1.0 0.150
150
15
D=
500 , R = 50 .
400 40
$title THE UNIT COMMITMENT PROBLEM
SETS
K index of periods of time /1*4/
J index of generators /1*3/
309
Problema de la distribución de energı́a I
310
Problema de la distribución de energı́a I
EQUATIONS
RESERVE(K) spinning reserve equation
LOGIC(J,K) start-up shut-down and running logic
RUP(J,K) maximum up ramp rate limit
RDOWN(J,K) maximum down ramp rate limit;
COST..z=e= SUM((K,J),GDATA(J,’A’)*v(J,K)+GDATA(J,’B’)
*y(J,K)+GDATA(J,’C’)*s(J,K)+GDATA(J,’D’)*p(J,K));
PMAXL(J,K)$(ord(K) GT 1)..p(J,K)=l=GDATA(J,’PMAX’)*v(J,K);
PMINL(J,K)$(ord(K) GT 1)..p(J,K)=g=GDATA(J,’PMIN’)*v(J,K);
LOAD(K)$(ord(K) GT 1)..SUM(J,p(J,K))=e=PDATA(K,’D’);
RESERVE(K)$(ord(K) GT 1)..SUM(J,GDATA(J,’PMAX’)*v(J,K))=g=
PDATA(K,’D’)+PDATA(K,’R’);
LOGIC(J,K)$(ord(K) GT 1)..y(J,K)-s(J,K)=e=v(J,K)-v(J,K-1);
RUP(J,K)$(ord(K) GT 1)..p(J,K)-p(J,K-1)=l=GDATA(J,’S’);
RDOWN(J,K)$(ord(K) GT 1)..p(J,K-1)-p(J,K)=l=GDATA(J,’T’);
MODEL uc /ALL/;
La solución es:
150 350 320 1 1 1
Z = 191, P = 0 100 80 , V = 0 1 1
0 50 0 0 1 0
1 0 0 0 0 0
yj (k) = 0 1 0 , pj (k) = 0 0 0 .
0 1 0 0 0 1
311
Modelos de localización I
X X X
Maximizar Z = cij xij − fj yj .
i∈I j∈J j∈J
sujeta a X
xij = bi, ∀i ∈ I
j∈J
X
xij ≤ uj yj , ∀j ∈ J
i∈I
yj ∈ {0, 1}, ∀j ∈ J
xij ≥ 0, ∀i ∈ I, ∀j ∈ J.
donde se supone que uj = 6 ∀j, fj = 10 ∀j y
OPTION OPTCR=1e-10;
SET
I index of cities /C1*C7/
J index of locations /L1*L6/;
PARAMETERS
312
Modelos de localización II
Ciudades
Situación C1 C2 C3 C4 C5 C6 C7
L2 1.5 2.0 1.0
L4 3.0 2.5
L5 3.0 1.0 2.0
TABLE C(J,I) benefits according to different locations
C1 C2 C3 C4 C5 C6 C7
L1 4.0 4.5 2.5 0.5 1.0 0.5 -3.5
L2 4.0 4.5 2.5 4.2 3.5 1.5 -0.5
L3 3.5 5.0 4.0 3.5 4.5 1.5 0.0
L4 1.3 3.0 5.0 3.3 5.5 1.8 1.3
L5 0.5 1.0 1.5 5.0 4.0 5.5 3.0
L6 -1.0 0.0 1.5 3.3 4.0 4.5 2.0 ;
VARIABLES
z objective function variable
x(I,J) the amount of good that is made at J and sold at I
y(J) location variable. Equal to 1 if the plant is at J,
and 0 otherwise.
POSITIVE VARIABLE x;
BINARY VARIABLE y;
EQUATIONS
COST objective function
SD(I) satisfying demand of city I
CAPA(J) capacity of production of the plant I;
COST .. z=e= SUM((I,J),C(J,I)*x(I,J))-SUM(J,F(J)*y(J));
SD(I) .. SUM(J,x(I,J)) =e= B(I);
CAPA(J).. SUM(I,x(I,J)) =l= U(J)*y(J);
MODEL loc /all/;
SOLVE loc USING mip MAXIMIZING z;
DISPLAY x.l;
313
EL problema de la Academia I
I
X S
X
Maximizar y Minimizar Zj = xijs, ∀j ∈ {1, 2, . . . , J}
i=1 s=1
sujeta a
S
X
xijs ≤ 1, ∀i ∈ {1, 2, . . . , I}, j ∈ {1, 2, . . . , J}
s=1
J
X
xijs ≤ 1, ∀i ∈ {1, 2, . . . , I}, s ∈ {1, 2, . . . , S}
j=1
I
X S
X
psxijs = cj , ∀j ∈ {1, 2, . . . , J}
i=1 s=1
xijs ∈ {0, 1}, ∀i, j, s
$title ACADEMY
SETS
I number of actual members /1*20/
J number of candidates /1*8/
DIN(J)
S the number of different scores to be assigned /1*4/;
ALIAS(J,J1);
PARAMETER P(S) the $s$-th score
/1 10
2 8
3 3
4 1/;
SCALARS zmin,zmax;
PARAMETER C(J) total score obtained by candidate J;
C(J)=sum(I,N(I,J));
VARIABLES
z function to be optimized ;
BINARY VARIABLE
x(I,J,S) if member I assigns score P(S) to J is 1.
314
EL problema de la Academia II
315
EL problema de la Academia III
OBJ(J)$DIN(J)..z=e=sum(I,sum(S,x(I,J,S)));
L1(I,J)..sum(S,x(I,J,S))=l=1;
L2(I,S)..sum(J,x(I,J,S))=l=1;
TOTALSCORE(J)..sum(I,sum(S,P(S)*x(I,J,S)))=e=C(J);
MODEL Academy /ALL/;
file aux /academy.out/;
put aux;
DIN(J)=NO;
loop(J1,
DIN(J1)=YES;
Solve Academy using mip Minimizing z;
zmin=z.l;
Solve Academy using mip Maximizing z;
zmax=z.l;
put "J=",J1.tl:3," zmin= ",zmin:3:0," zmax= ",zmax:3:0/;
DIN(J1)=NO;
);
316
EL problema de los horarios I
X nc
X
n
X h
Minimizar (c + h) v(s, c, h)
s∈Ω c=1 h=1
sujeta a
Pnh
P
s∈Ωi
Pnc
h=1 v(s, c, h)
c=1 = ni , ∀i
P Pnc
s∈Ωi c=1 v(s, c, h) ≤ 1, ∀h, ∀i
Pnc Pnh
c=1 h=1 v(s, c, h) = 1, ∀s
s∈Ω v(s, c, h) ≤ ∀c, ∀h
P
1,
s∈∆b c=1 v(s, c, h) ≤ ∀h, ∀b
P Pnc
1,
$title CLASS TIMETABLE
SETS
C classrooms /c1*c3/
H hours /h1*h5/
S subjects /s1*s8/
I instructors /i1,i2/
B blocks /b1,b2/
SI(S,I) maps subjects and instructors
/(s1,s2,s8).i1,(s3*s7).i2/
SB(S,B) maps subjects and blocks /(s1*s4).b1,(s5*s8).b2/;
VARIABLE z;
BINARY VARIABLE v(S,C,H);
EQUATIONS
cost compact the timetable
const1(I) instructors teach all his subjects
const2(H,I) instructors teach at most 1 subject per hour
const3(S) every subject is taught once
const4(C,H) in every classroom-hour pair 1 subject
const5(H,B) every hour at most 1 subject of any blockt;
317
EL problema de los horarios II
EQUATIONS
cost.. SUM((S,C,H),(ord(C)+ord(H))*v(S,C,H))=e=z ;
const1(I).. SUM((S,C,H)$SI(S,I),v(S,C,H))=e=
SUM(S$SI(S,I),card(S))/card(S);
const2(H,I)..SUM((S,C)$SI(S,I),v(S,C,H)) =l= 1;
const3(S).. SUM((C,H),v(S,C,H)) =e= 1;
const4(C,H)..SUM(S,v(S,C,H)) =l= 1;
const5(H,B)..SUM((S,C)$SB(S,B),v(S,C,H)) =l= 1;
model timetable /all/;
solve timetable using mip minimizing z;
DISPLAY v.L;
318
El problema del abastecimiento de agua I
Planteamiento no lineal
que corresponde a
X
Z= cij |xij |.
ij
319
El problema del abastecimiento de agua II
Planteamiento no lineal
EQUATIONS
COST objective function
BALANCE(I) conservation of flow conditions;
COST .. z=e=SUM((I,J)$CONEX(I,J),ABS(x(I,J)));
BALANCE(I) ..SUM(J$CONEX(I,J),x(I,J))
-SUM(J$CONEX(J,I),x(J,I))=e=F(I);
La solución es:
0
4 8 8
−4
0 0 1
Z = 23.000, X =
.
−8
0 0 −2
−8 −1 2 0
320
El problema del andamio I
X
Maximizzar xi
i
sujeta a
P
ts = P
xi + P
ts, b ∈ B,
s∈Ψb i∈Ωb x∈Θb
P
drsts = P
xlixi + P
drsts, b ∈ B,
s∈Ψb i∈Ωb x∈Θb
0 ≤ ts ≤ Ts, s ∈ S,
0 ≤ xi .
$title SCAFFOLDING (NON-LINEAR)
SET
B set of beams /B1*B3/
R set of ropes /RA,RB,RC,RD,RE,RF/
L set of loads /L1,L2/
UPP(B,R)
/B1.(RA,RB)
B2.(RC,RD)
B3.(RE,RF)/
DOWN(B,R)
/B1.(RC,RD)
B2.(RF)/
LOAD(B,L)
/B1.L1
B3.L2/;
321
El problema del andamio II
La solución es:
Z = 700 en x1 = 500, x2 = 200, d1 = 6.4, d2 = 5.0,
TA = 300, TB = 300, TC = 25,
TD = 75, TE = 100, TF = 100.
322