示例#1
0
import logging
import saport.simplex.model as m

model = m.Model("Zad2")

x1 = model.create_variable("x1")
x2 = model.create_variable("x2")
x3 = model.create_variable("x3")
x4 = model.create_variable("x4")

model.add_constraint(0.8 * x1 + 2.4 * x2 + 0.9 * x3 + 0.4 * x4 >= 1200)
model.add_constraint(0.6 * x1 + 0.6 * x2 + 0.3 * x3 + 0.3 * x4 >= 600)

model.minimize(9.6 * x1 + 14.4 * x2 + 10.8 * x3 + 7.2 * x4)

solution = model.solve()

logging.basicConfig(level=logging.INFO, format='%(message)s')
logging.info(solution)



示例#2
0
import saport.simplex.model as m

model = m.Model("Assignment 4")

# x1 - produkcja samego zwoju 105cm = 105cm i 95cm odpadu
# x12 - produkcja naraz zwojów 105cm i 75cm = 180cm i 20cm odpadu
# x13 - produkcja naraz zwojów 105cm i 35cm = 140cm i 60cm odpadu
# x133 - produkcja naraz zwojów 105cm i 2*35cm = 175cm i 25cm odpadu
# x2 - produkcja samego zwoju 75cm = 75cm i 125cm odpadu
# x22 - produkcja naraz dwóch zwojów 75cm = 150cm i 50cm odpadu
# x223 - produkcja naraz zwojów 2*75cm i 35cm = 185cm i 15cm odpadu
# x23 - produkcja naraz zwojów 75cm i 35cm = 110cm i 90cm odpadu
# x233 - produkcja naraz zwojów 75cm i 2*35cm = 145cm i 55cm odpadu
# x2333 - produkcja naraz zwojów 75cm i 3*35cm = 180cm i 20cm odpadu
# x3 - produkcja samego zwoju 35cm = 35cm i 165cm odpadu
# x33 - produkcja dwóch zwojów 35cm = 70cm i 130cm odpadu
# x333 - produkcja trzech zwojów 35cm = 105xcm i 95cm odpadu
# x3333 - produkcja czterech zwojów 35cm = 140cm i 60cm odpadu
# x33333 - produkcja czterech zwojów 35cm = 175cm i 25cm odpadu
x1 = model.create_variable("x1")
x12 = model.create_variable("x12")
x13 = model.create_variable("x13")
x133 = model.create_variable("x133")
x2 = model.create_variable("x2")
x22 = model.create_variable("x22")
x223 = model.create_variable("x223")
x23 = model.create_variable("x23")
x233 = model.create_variable("x233")
x2333 = model.create_variable("x2333")
x3 = model.create_variable("x3")
x33 = model.create_variable("x33")
示例#3
0
import logging
import saport.simplex.model as m

model = m.Model("Zad3")

x1 = model.create_variable("x1")
x2 = model.create_variable("x2")

model.add_constraint(5 * x1 + 15 * x2 >= 50)
model.add_constraint(20 * x1 + 5 * x2 >= 40)
model.add_constraint(15 * x1 + 2 * x2 <= 60)

model.minimize(8 * x1 + 4 * x2)

solution = model.solve()

logging.basicConfig(level=logging.INFO, format='%(message)s')
logging.info(solution)
示例#4
0
import saport.simplex.model as m

model = m.Model("Assignment 2")

p1 = model.create_variable("P1")
p2 = model.create_variable("P2")
p3 = model.create_variable("P3")
p4 = model.create_variable("P4")

model.add_constraint(0.8*p1 + 2.4*p2 + 0.9*p3 + 0.4*p4 >= 1200)
model.add_constraint(0.6*p1 + 0.6*p2 + 0.3*p3 + 0.3*p4 >= 600)

model.minimize(9.6*p1 + 14.4*p2 + 10.8*p3 + 7.2*p4)

print(model)

model.solve()
示例#5
0
import logging
import saport.simplex.model as m

model = m.Model("Zad4")

x1 = model.create_variable("x1")
x2 = model.create_variable("x2")  # jeden zwój o długości 105, jeden 75
x3 = model.create_variable("x3")
x4 = model.create_variable("x4")
x5 = model.create_variable("x5")
x6 = model.create_variable("x6")
x7 = model.create_variable("x7")  # 2 zwoje 75, 1 zwój 35
x8 = model.create_variable("x8")
x9 = model.create_variable("x9")
x10 = model.create_variable("x10")
x11 = model.create_variable("x11")
x12 = model.create_variable("x12")
x13 = model.create_variable("x13")
x14 = model.create_variable("x14")
x15 = model.create_variable("x15")  # 5 zwojów 35

model.add_constraint(x1 + x2 + x3 + x4 == 150)
model.add_constraint(x2 + x5 + 2 * x6 + 2 * x7 + x8 + x9 + x10 == 200)
model.add_constraint(x3 + 2 * x4 + x7 + x8 + 2 * x9 + 3 * x10 + x11 + 2 * x12 +
                     3 * x13 + 4 * x14 + 5 * x15 == 150)

model.minimize(95 * x1 + 20 * x2 + 60 * x3 + 25 * x4 + 125 * x5 + 50 * x6 +
               15 * x7 + 90 * x8 + 55 * x9 + 20 * x10 + 165 * x11 + 130 * x12 +
               95 * x13 + 60 * x14 + 25 * x15)

solution = model.solve()
示例#6
0
import logging
import saport.simplex.model as m

model = m.Model("Zad1")

x1 = model.create_variable("x1")
x2 = model.create_variable("x2")
x3 = model.create_variable("x3")

model.add_constraint(x1 + x2 + x3 <= 30)
model.add_constraint(x1 + 2 * x2 + x3 >= 10)
model.add_constraint(2 * x2 + x3 <= 20)

model.maximize(2 * x1 + x2 + 3 * x3)

solution = model.solve()

logging.basicConfig(level=logging.INFO, format='%(message)s')
logging.info(solution)
示例#7
0
import saport.simplex.model as m

model = m.Model("Assignment 1")

x1 = model.create_variable("x1")
x2 = model.create_variable("x2")
x3 = model.create_variable("x3")

model.add_constraint(x1 + x2 + x3 <= 30)
model.add_constraint(x1 + 2 * x2 + x3 >= 10)
model.add_constraint(2 * x2 + x3 <= 20)

model.minimize(2 * x1 + x2 + 3 * x3)

print(model)

model.solve()
示例#8
0
import saport.simplex.model as m

model = m.Model("Assignment 3")

# x1 - liczba porcji steków
# x2 - liczba porcji ziemniaków
x1 = model.create_variable("x1")
x2 = model.create_variable("x2")

model.add_constraint(5 * x1 + 15 * x2 >= 50)
model.add_constraint(20 * x1 + 5 * x2 >= 40)
model.add_constraint(15 * x1 + 2 * x2 <= 60)

model.minimize(8 * x1 + 4 * x2)

print(model)

model.solve()