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

[WIP] Add COPT support for Pyomo #2880

Draft
wants to merge 24 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/test_branches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,13 @@ jobs:
$PYTHON_EXE -m pip install --cache-dir cache/pip highspy \
|| echo "WARNING: highspy is not available"

- name: Install COPT
if: ${{ ! matrix.slim }}
shell: bash
run: |
$PYTHON_EXE -m pip install --cache-dir cache/pip coptpy \
|| echo "WARNING: coptpy is not available"

- name: Set up coverage tracking
run: |
if test "${{matrix.TARGET}}" == win; then
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/test_pr_and_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,13 @@ jobs:
$PYTHON_EXE -m pip install --cache-dir cache/pip highspy \
|| echo "WARNING: highspy is not available"

- name: Install COPT
if: ${{ ! matrix.slim }}
shell: bash
run: |
$PYTHON_EXE -m pip install --cache-dir cache/pip coptpy \
|| echo "WARNING: coptpy is not available"

- name: Set up coverage tracking
run: |
if test "${{matrix.TARGET}}" == win; then
Expand Down
4 changes: 2 additions & 2 deletions pyomo/contrib/appsi/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1654,15 +1654,15 @@ def license_is_valid(self) -> bool:

@property
def options(self):
for solver_name in ['gurobi', 'ipopt', 'cplex', 'cbc', 'highs']:
for solver_name in ['gurobi', 'ipopt', 'cplex', 'cbc', 'highs', 'copt']:
if hasattr(self, solver_name + '_options'):
return getattr(self, solver_name + '_options')
raise NotImplementedError('Could not find the correct options')

@options.setter
def options(self, val):
found = False
for solver_name in ['gurobi', 'ipopt', 'cplex', 'cbc', 'highs']:
for solver_name in ['gurobi', 'ipopt', 'cplex', 'cbc', 'highs', 'copt']:
if hasattr(self, solver_name + '_options'):
setattr(self, solver_name + '_options', val)
found = True
Expand Down
5 changes: 4 additions & 1 deletion pyomo/contrib/appsi/plugins.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pyomo.common.extensions import ExtensionBuilderFactory
from .base import SolverFactory
from .solvers import Gurobi, Ipopt, Cbc, Cplex, Highs
from .solvers import Gurobi, Ipopt, Cbc, Cplex, Highs, Copt
from .build import AppsiBuilder


Expand All @@ -21,3 +21,6 @@ def load():
SolverFactory.register(
name='appsi_highs', doc='Automated persistent interface to Highs'
)(Highs)
SolverFactory.register(
name='appsi_copt', doc='Automated persistent interface to COPT'
)(Copt)
1 change: 1 addition & 0 deletions pyomo/contrib/appsi/solvers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
from .cbc import Cbc
from .cplex import Cplex
from .highs import Highs
from .copt import Copt, CoptResults
Loading
Loading