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

Support for upcoming knitro python package #3478

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
16 changes: 16 additions & 0 deletions pyomo/solvers/plugins/solvers/ASL.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
# ___________________________________________________________________________


from pathlib import Path
import os
import subprocess

from pyomo.common import Executable
from pyomo.common.errors import ApplicationError
from pyomo.common.collections import Bunch
from pyomo.common.tempfiles import TempfileManager
from pyomo.common.fileutils import find_executable

from pyomo.opt.base import ProblemFormat, ResultsFormat
from pyomo.opt.base.solvers import _extract_version, SolverFactory
Expand All @@ -39,6 +41,20 @@ class ASL(SystemCallSolver):

def __init__(self, **kwds):
#
# If solving with knitroampl, check if Knitro Python package is installed in the same environment.
# If yes, use the knitroampl executable from the package instead of searching in PATH.
#
if 'executable' in kwds and kwds['executable'] == 'knitroampl':
candidate_knitroampl_dir = (
Path(__file__).resolve().parents[4] / 'knitro' / 'knitroampl'
)
if find_executable(
'knitroampl',
include_PATH=False,
pathlist=[str(candidate_knitroampl_dir)],
):
kwds['executable'] = str(candidate_knitroampl_dir / 'knitroampl')
#
# Call base constructor
#
if not 'type' in kwds:
Expand Down