monorepo
This commit is contained in:
23
PI4/modelos/ej1.lsi
Normal file
23
PI4/modelos/ej1.lsi
Normal file
@@ -0,0 +1,23 @@
|
||||
head section
|
||||
|
||||
Integer getN()
|
||||
Integer getM()
|
||||
Integer getMetrosRequeridos(Integer i)
|
||||
Integer getMetrosDisponibles(Integer j)
|
||||
Integer incompatible(Integer i, Integer k)
|
||||
Integer n = getN()
|
||||
Integer m = getM()
|
||||
|
||||
goal section
|
||||
|
||||
max sum(x[i,j], i in 0 .. n, j in 0 .. m)
|
||||
|
||||
constraints section
|
||||
|
||||
sum(x[i,j], j in 0 .. m) <= 1, i in 0 .. n
|
||||
sum(getMetrosRequeridos(i) x[i,j], i in 0 .. n) <= getMetrosDisponibles(j), j in 0 .. m
|
||||
x[i,j] + x[k,j] <= 1, i in 0 .. n, k in 0 .. n, j in 0 .. m | incompatible(i,k) = 1
|
||||
|
||||
bin
|
||||
|
||||
x[i,j], i in 0 .. n, j in 0 .. m
|
||||
BIN
PI4/modelos/ej1.png
Normal file
BIN
PI4/modelos/ej1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 90 KiB |
21
PI4/modelos/ej2.lsi
Normal file
21
PI4/modelos/ej2.lsi
Normal file
@@ -0,0 +1,21 @@
|
||||
head section
|
||||
Integer getN()
|
||||
Integer getM()
|
||||
Integer getPrecio(Integer i)
|
||||
Integer getValoracion(Integer i)
|
||||
Integer getPresupuesto()
|
||||
Integer tieneCategoria(Integer i, Integer j)
|
||||
|
||||
Integer n = getN()
|
||||
Integer m = getM()
|
||||
|
||||
goal section
|
||||
min sum(getPrecio(i) x[i], i in 0 .. n)
|
||||
|
||||
constraints section
|
||||
sum(tieneCategoria(i,j) x[i], i in 0 .. n) >= 1, j in 0 .. m
|
||||
sum(getValoracion(i) x[i], i in 0 .. n) - sum(3 x[i], i in 0 .. n) > 0
|
||||
sum(getPrecio(i) x[i], i in 0 .. n | tieneCategoria(i,j) > 0) <= getPresupuesto(), j in 0 .. m
|
||||
|
||||
bin
|
||||
x[i], i in 0 .. n
|
||||
BIN
PI4/modelos/ej2.png
Normal file
BIN
PI4/modelos/ej2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 47 KiB |
18
PI4/modelos/ej3.lsi
Normal file
18
PI4/modelos/ej3.lsi
Normal file
@@ -0,0 +1,18 @@
|
||||
head section
|
||||
Integer getN()
|
||||
Integer getM()
|
||||
Integer getCantidad(Integer i)
|
||||
Integer getDemanda(Integer j)
|
||||
Integer getCoste(Integer i, Integer j)
|
||||
Integer n = getN()
|
||||
Integer m = getM()
|
||||
|
||||
goal section
|
||||
min sum(getCoste(i,j) x[i,j], i in 0 .. n, j in 0 .. m)
|
||||
|
||||
constraints section
|
||||
sum(x[i,j], i in 0 .. n) >= getDemanda(j), j in 0 .. m
|
||||
sum(x[i,j], j in 0 .. m) <= getCantidad(i), i in 0 .. n
|
||||
|
||||
int
|
||||
x[i,j], i in 0 .. n, j in 0 .. m
|
||||
BIN
PI4/modelos/ej3.png
Normal file
BIN
PI4/modelos/ej3.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 81 KiB |
54
PI4/modelos/gurobi/ej1.lp
Normal file
54
PI4/modelos/gurobi/ej1.lp
Normal file
@@ -0,0 +1,54 @@
|
||||
Maximize
|
||||
|
||||
x_0_0 + x_0_1 + x_1_0 + x_1_1 + x_2_0 + x_2_1 + x_3_0 + x_3_1 + x_4_0 + x_4_1
|
||||
|
||||
|
||||
Subject To
|
||||
|
||||
a0: x_0_0 + x_0_1 <= 1
|
||||
a1: x_1_0 + x_1_1 <= 1
|
||||
a2: x_2_0 + x_2_1 <= 1
|
||||
a3: x_3_0 + x_3_1 <= 1
|
||||
a4: x_4_0 + x_4_1 <= 1
|
||||
b0: 2 x_0_0 + 4 x_1_0 + 3 x_2_0 + 1 x_3_0 + 6 x_4_0 <= 4
|
||||
b1: 2 x_0_1 + 4 x_1_1 + 3 x_2_1 + 1 x_3_1 + 6 x_4_1 <= 6
|
||||
c0: x_0_0 + x_2_0 <= 1
|
||||
c1: x_0_1 + x_2_1 <= 1
|
||||
c2: x_0_0 + x_3_0 <= 1
|
||||
c3: x_0_1 + x_3_1 <= 1
|
||||
c4: x_0_0 + x_4_0 <= 1
|
||||
c5: x_0_1 + x_4_1 <= 1
|
||||
c6: x_1_0 + x_2_0 <= 1
|
||||
c7: x_1_1 + x_2_1 <= 1
|
||||
c8: x_1_0 + x_4_0 <= 1
|
||||
c9: x_1_1 + x_4_1 <= 1
|
||||
c10: x_2_0 + x_0_0 <= 1
|
||||
c11: x_2_1 + x_0_1 <= 1
|
||||
c12: x_2_0 + x_1_0 <= 1
|
||||
c13: x_2_1 + x_1_1 <= 1
|
||||
c14: x_2_0 + x_4_0 <= 1
|
||||
c15: x_2_1 + x_4_1 <= 1
|
||||
c16: x_3_0 + x_0_0 <= 1
|
||||
c17: x_3_1 + x_0_1 <= 1
|
||||
c18: x_3_0 + x_4_0 <= 1
|
||||
c19: x_3_1 + x_4_1 <= 1
|
||||
c20: x_4_0 + x_0_0 <= 1
|
||||
c21: x_4_1 + x_0_1 <= 1
|
||||
c22: x_4_0 + x_1_0 <= 1
|
||||
c23: x_4_1 + x_1_1 <= 1
|
||||
c24: x_4_0 + x_2_0 <= 1
|
||||
c25: x_4_1 + x_2_1 <= 1
|
||||
c26: x_4_0 + x_3_0 <= 1
|
||||
c27: x_4_1 + x_3_1 <= 1
|
||||
|
||||
|
||||
|
||||
|
||||
Binary
|
||||
|
||||
x_0_0 x_0_1 x_1_0 x_1_1 x_2_0 x_2_1 x_3_0 x_3_1 x_4_0 x_4_1
|
||||
|
||||
|
||||
|
||||
|
||||
End
|
||||
22
PI4/modelos/gurobi/ej2.lp
Normal file
22
PI4/modelos/gurobi/ej2.lp
Normal file
@@ -0,0 +1,22 @@
|
||||
Minimize
|
||||
|
||||
5 x_0 + 4 x_1 + 3 x_2 + 5 x_3 + 5 x_4 + 8 x_5 + 8 x_6 + 7 x_7 + 6 x_8 + 10 x_9
|
||||
|
||||
|
||||
Subject To
|
||||
|
||||
a0: 1 x_0 + 0 x_1 + 0 x_2 + 0 x_3 + 0 x_4 + 0 x_5 + 0 x_6 + 1 x_7 + 0 x_8 + 0 x_9 >= 1
|
||||
a1: 0 x_0 + 0 x_1 + 1 x_2 + 0 x_3 + 0 x_4 + 0 x_5 + 1 x_6 + 0 x_7 + 0 x_8 + 1 x_9 >= 1
|
||||
a2: 0 x_0 + 1 x_1 + 0 x_2 + 0 x_3 + 1 x_4 + 0 x_5 + 0 x_6 + 0 x_7 + 1 x_8 + 0 x_9 >= 1
|
||||
a3: 0 x_0 + 0 x_1 + 0 x_2 + 1 x_3 + 0 x_4 + 0 x_5 + 0 x_6 + 0 x_7 + 0 x_8 + 0 x_9 >= 1
|
||||
a4: 0 x_0 + 0 x_1 + 0 x_2 + 0 x_3 + 0 x_4 + 1 x_5 + 0 x_6 + 0 x_7 + 0 x_8 + 0 x_9 >= 1
|
||||
b0: 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 >= 3
|
||||
c0: 8 x_5 <= 10
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
End
|
||||
32
PI4/modelos/gurobi/ej3.lp
Normal file
32
PI4/modelos/gurobi/ej3.lp
Normal file
@@ -0,0 +1,32 @@
|
||||
Minimize
|
||||
|
||||
1 x_0_0 + 7 x_0_1 + 1 x_0_2 + 1 x_0_3 + 10 x_0_4 + 8 x_0_5 + 15 x_0_6 + 9 x_0_7 + 1 x_0_8 + 1 x_0_9 + 25 x_1_0 + 3 x_1_1 + 8 x_1_2 + 1 x_1_3 + 1 x_1_4 + 1 x_1_5 + 1 x_1_6 + 1 x_1_7 + 11 x_1_8 + 1 x_1_9 + 1 x_2_0 + 1 x_2_1 + 1 x_2_2 + 25 x_2_3 + 15 x_2_4 + 1 x_2_5 + 30 x_2_6 + 10 x_2_7 + 7 x_2_8 + 1 x_2_9
|
||||
|
||||
|
||||
Subject To
|
||||
|
||||
a0: x_0_0 + x_1_0 + x_2_0 >= 3
|
||||
a1: x_0_1 + x_1_1 + x_2_1 >= 1
|
||||
a2: x_0_2 + x_1_2 + x_2_2 >= 8
|
||||
a3: x_0_3 + x_1_3 + x_2_3 >= 5
|
||||
a4: x_0_4 + x_1_4 + x_2_4 >= 1
|
||||
a5: x_0_5 + x_1_5 + x_2_5 >= 3
|
||||
a6: x_0_6 + x_1_6 + x_2_6 >= 1
|
||||
a7: x_0_7 + x_1_7 + x_2_7 >= 10
|
||||
a8: x_0_8 + x_1_8 + x_2_8 >= 2
|
||||
a9: x_0_9 + x_1_9 + x_2_9 >= 6
|
||||
b0: x_0_0 + x_0_1 + x_0_2 + x_0_3 + x_0_4 + x_0_5 + x_0_6 + x_0_7 + x_0_8 + x_0_9 <= 12
|
||||
b1: x_1_0 + x_1_1 + x_1_2 + x_1_3 + x_1_4 + x_1_5 + x_1_6 + x_1_7 + x_1_8 + x_1_9 <= 15
|
||||
b2: x_2_0 + x_2_1 + x_2_2 + x_2_3 + x_2_4 + x_2_5 + x_2_6 + x_2_7 + x_2_8 + x_2_9 <= 13
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
General
|
||||
|
||||
x_0_0 x_0_1 x_0_2 x_0_3 x_0_4 x_0_5 x_0_6 x_0_7 x_0_8 x_0_9 x_1_0 x_1_1 x_1_2 x_1_3 x_1_4 x_1_5 x_1_6 x_1_7 x_1_8 x_1_9 x_2_0 x_2_1 x_2_2 x_2_3 x_2_4 x_2_5 x_2_6 x_2_7 x_2_8 x_2_9
|
||||
|
||||
|
||||
|
||||
End
|
||||
Reference in New Issue
Block a user