Struggling to Configure Solvers for MINLP Optimization with Pyomo (using NEOS or Local Installation) - Stack Overflow

时间: 2025-01-06 admin 业界

I'm working on a Mixed-Integer Nonlinear Programming (MINLP) optimization problem using Pyomo in Python, but I'm having trouble installing and configuring solvers.

I've tried both installing solvers locally and using the NEOS solver service, but it seems like I'm missing a step in my configuration.

Here's a simplified example of my code:

from pyomo.environ import ConcreteModel, Var, Objective, Constraint, SolverFactory, SolverManagerFactory

# Step 1: Define the model
model = ConcreteModel()

# Define decision variables
model.x = Var(within=NonNegativeReals)  # x >= 0
model.y = Var(within=NonNegativeReals)  # y >= 0

# Objective function
model.obj = Objective(expr=model.x**2 + model.y**2)

# Constraint
model.constr = Constraint(expr=model.x + model.y == 1)

# Step 2: Use NEOS Solver Manager with the MINLP solver
solver_manager = SolverManagerFactory('neos')
solver_manager.solve(model, solver='bonmin')

# Step 3: Print the results
model.x.display()
model.y.display()

My question:

  1. How can I ensure that Pyomo correctly connects to NEOS and uses the specified solvers like bonmin?
  2. Are there any additional configuration steps I need to follow to make sure the solvers work either locally or via NEOS?

Any help or pointers would be greatly appreciated!

What I've tried:

  • NEOS Solver Service: I used SolverManagerFactory('neos') to connect to NEOS, but I encounter issues with setting the solver executable, particularly for bonmin and ipopt.
  • Local Solver Installation: I've also attempted to install solvers like IPOPT and BONMIN locally, but I keep running into errors about missing executables or configuration issues. Note that I am using windows os, and conda environment.
最新文章