Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bonmin: ERROR: Solver (asl) returned non-zero return code (3221226356) #3188

Closed
Djinhui opened this issue Mar 8, 2024 · 5 comments
Closed
Labels

Comments

@Djinhui
Copy link

Djinhui commented Mar 8, 2024

Summary

I am using pyomo to solve a combinatorial optimization problem. I got some error message, I'm a rookie, please help me to solve it.

Here is my script

from pyomo.environ import *
model = ConcreteModel()  # Define the model
model.T = RangeSet(0, 23)  # Time periods
model.I = RangeSet(1, 10)  # Machines

Dt = {t: val for t, val in enumerate([
    10702, 12710, 16192, 16531, 18215, 17901, 17020, 13193, 31005, 32064, 
    32701, 30858, 20120, 31975, 32749, 32656, 32145, 31782, 28109, 20085, 
    17839, 16323, 16319, 14687
])}
Qmin = {i: val for i, val in enumerate([0, 0, 0, 0, 3600, 3600, 3600, 4800, 4800, 4800], start=1)}
Qmax = {i: val for i, val in enumerate([1920, 1920, 3840, 3840, 5760, 5760, 5760, 7680, 7680, 7680], start=1)}
S = {i: val for i, val in enumerate([10, 10, 20, 20, 30, 30, 30, 40, 40, 40], start=1)}
M = {i: val for i, val in enumerate([4, 4, 4, 4, 4, 4, 4, 4, 4, 4], start=1)}
a = {i: val for i, val in enumerate([0.0000012, 0.0000036, 0.0000025, 0.0000014, 0.0000017, 0.0000012, 0.0000013, 0.0000015, 0.0000013, 0.0000009], start=1)}
b = {i: val for i, val in enumerate([0.097, 0.0965, 0.113, 0.109, 0.102, 0.098, 0.096, 0.105, 0.112, 0.085], start=1)}
c = {i: val for i, val in enumerate([16, 23, 27, 22, 21, 24, 25, 36, 24, 18], start=1)}

model.U = Var(model.T, model.I, domain=Binary,initialize=1)  # On/Off status
model.Q = Var(model.T, model.I, domain=NonNegativeReals)  # Production
for i in model.I:
    for t in model.T:
        model.Q[t,i] = Qmax[i]

def cost_rule(model): # Objective Function
    return sum(model.U[t, i] * (a[i] * model.Q[t, i]**2 + b[i] * model.Q[t, i] + c[i]) for t in model.T for i in model.I) + \
        sum(S[i] * sum(model.U[t, i] * (1 - model.U[t-1, i]) for t in model.T if t > 0) for i in model.I)
model.cost = Objective(rule=cost_rule, sense=minimize)

def demand_constraint_rule(model, t): # Demand constraint
    # return sum(model.Q[t, i]  for i in model.I) == Dt[t]
    return sum(model.Q[t, i] * model.U[t, i] for i in model.I) == Dt[t]
model.demand_constraint = Constraint(model.T, rule=demand_constraint_rule)

def reserve_constraint_rule(model, t): # Reserve constraint
    return sum(Qmax[i] * model.U[t, i] for i in model.I) >= 1.05 * Dt[t]
model.reserve_constraint = Constraint(model.T, rule=reserve_constraint_rule)

def production_constraint1_rule(model, t, i): # Production constraint
    return Qmin[i] * model.U[t, i] <= model.Q[t, i]
model.production_constraint1 = Constraint(model.T, model.I, rule=production_constraint1_rule)

def production_constraint2_rule(model, t, i):
    return model.Q[t, i] <= Qmax[i] * model.U[t, i]
model.production_constraint2 = Constraint(model.T, model.I, rule=production_constraint2_rule)

def start_ups_constraint_rule(model, i): # Start-up and shutdown constraint
    # return sum(model.U[t, i] - model.U[t-1, i] for t in model.T if t > 0) <= M[i] * 2
    return sum(abs(model.U[t, i] - model.U[t-1, i]) for t in model.T if t > 0)  <= M[i]*2 # bonmin/couenne error
model.start_ups_constraint = Constraint(model.I, rule=start_ups_constraint_rule)

solver = SolverFactory('bonmin')
result = solver.solve(model, tee=True) 

Error Message

Bonmin 1.5.1 using Cbc 2.7.5 and Ipopt 3.10.1
bonmin: ERROR: Solver (asl) returned non-zero return code (3221226356)
ERROR: See the solver log above for diagnostic information.
Traceback (most recent call last):
File "c:/Users/DongJinhui/Desktop/AirCom/demo.py", line 73, in
result = solver.solve(model, tee=True) # tee=True for verbose output
File "D:\anaconda3\lib\site-packages\pyomo\opt\base\solvers.py", line 627, in solve
raise ApplicationError("Solver (%s) did not exit normally" % self.name)
pyomo.common.errors.ApplicationError: Solver (asl) did not exit normally

Information on your system

Pyomo version:6.6.2
Python version:3.8.18
Operating system: Windows
How Pyomo was installed (PyPI, conda, source):pip
Solver (if applicable):Bonmin 1.5.1 using Cbc 2.7.5 and Ipopt 3.10.1

Additional information

Here are some explanations:

  1. model.U[t,i] means the status for machine i at time t, model.Q[t,i] means the output for machine i at time t; There are 24 time peroids, 10 machine, t is from 0 to 23, i is from 1 to 10;
  2. model.U[t,i]=0 means at time t machine i is off work, model.U[t,i]=1 means at time t machine i is on work;
  3. the relationship(constraint) between model.U[t,i] and model.Q[t,i] is that when model.U[t,i]=1 then model.Q[t,i] >0, when model.U[t,i]=0 then model.Q[t,i]=0, that means only machine is on work then it can output;
  4. At any time t, the sum of 10 machines real output model.Q[t,i] equals to demand output at time t Dt[t];
  5. At any time t, the sum of 10 machines maximum output Qmax[i] great than or equal to demand output at time t Dt[t]*1.05;
  6. When meachine i is on work(i.e. model.U[t,i]=1),it’s output model.Q[t,i] should great than it’s minimum output Qmin[i] meanwhile less than it’s maximum output Qmax[i];
  7. always rember that when model.U[t,i]=1 then model.Q[t,i] >0, when model.U[t,i]=0 then model.Q[t,i]=0;
  8. for machine i, when model.U[t-1,i]=0 and model.U[t,i]=1, it is regarded as startup one time, when model.U[t-1,i]=1 and model.U[t,i]=0, it is regarded as shutdow one time, the total counts of startups and shutdowns during 24 time periods should less than the M[i].
@Djinhui Djinhui added the bug label Mar 8, 2024
@mrmundt
Copy link
Contributor

mrmundt commented Mar 8, 2024

@Djinhui - I ran your model on my mac off the current main branch, Python 3.11.5, using:

Bonmin 1.8.8 using Cbc 2.10.10 and Ipopt 3.13.2
bonmin (aarch64-apple-darwin22.5.0), ASL(20190605)

I don't get an error with these versions. This would lead me to guess that there is an issue in your environment somewhere. Was there more in the stack trace beyond what you posted?

@mrmundt
Copy link
Contributor

mrmundt commented Mar 12, 2024

@Djinhui - Pinging again on this. Is there more to the stack trace?

@Djinhui
Copy link
Author

Djinhui commented Mar 13, 2024

@Djinhui - Pinging again on this. Is there more to the stack trace?

Hi @mrmundt, thanks for your reply.There is no more stack trace. As you said, maybe there is an issue in my environment somewhere. I will try to fix it and run it again.

@mrmundt mrmundt closed this as completed Mar 18, 2024
@Djinhui
Copy link
Author

Djinhui commented Mar 19, 2024

@mrmundt - Yes, there is an issue in my environment, I've solved it, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants