Choose acceptable sets for binary solution

38 views
Skip to first unread message

Petros Aristidou

unread,
Nov 20, 2023, 9:03:46 AM11/20/23
to Pyomo Forum
Hi,

I have a simple MILP problem and would like to input a set of acceptable binary solutions. That is, the solver should ignore any other solutions even if they have a lower cost.

I put below a simple example with 3 variables and 3 binary. Let's say I want to constraint the solutions to only u=[111, 011, 101] and ignore any other solutions. How can I input this constraint?

Thanks in advance,
Petros


from pyomo.environ import *

# define a new model
model = ConcreteModel()

# declare decision variables
model.P1 = Var(domain=NonNegativeReals)
model.P2 = Var(domain=NonNegativeReals)
model.P3 = Var(domain=NonNegativeReals)
model.uP1 = Var(domain=Binary)
model.uP2 = Var(domain=Binary)
model.uP3 = Var(domain=Binary)

# declare objective
model.objective = Objective(
    expr = (model.uP1*561+7.92*model.P1+0.001562*model.P1**2+
            model.uP2*310+7.85*model.P2+0.00194*model.P2**2+
            model.uP3*78+7.97*model.P3+0.00482*model.P3**2),
    sense = minimize)

# declare constraints
model.demand = Constraint(expr = model.P1+model.P2+model.P3==850)
model.P1max = Constraint(expr = model.P1 <= model.uP1*600)
model.P2max = Constraint(expr = model.P2 <= model.uP2*400)
model.P3max = Constraint(expr = model.P3 <= model.uP3*200)
model.P1min = Constraint(expr = model.P1 >= model.uP1*150)
model.P2min = Constraint(expr = model.P2 >= model.uP2*100)
model.P3min = Constraint(expr = model.P3 >= model.uP3*50)

# enable to save the dual variables
model.dual = Suffix(direction=Suffix.IMPORT)

# solve
SolverFactory('mindtpy').solve(model).write()

print("Cost = ", model.objective())
print("P1 = ", model.P1(), " MW")
print("P2 = ", model.P2(), " MW")
print("P3 = ", model.P3(), " MW")
print("Commit P1 = ", model.uP1())
print("Commit P2 = ", model.uP2())
print("Commit P3 = ", model.uP3())
Reply all
Reply to author
Forward
0 new messages