Skip to content

Commit

Permalink
More instances to be replaced
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmundt committed Nov 20, 2023
1 parent 1edc3b5 commit f23ed71
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pyomo/solver/IPOPT.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ def _write_options_file(self, ostream: io.TextIOBase, options: Mapping):
def _create_command_line(self, basename: str, config: IPOPTConfig):
cmd = [
str(config.executable),
basename + '.nl',
os.path.join(basename, '.nl'),
'-AMPL',
'option_file_name=' + basename + '.opt',
'option_file_name=' + os.path.join(basename, '.opt'),
]
if 'option_file_name' in config.solver_options:
raise ValueError(
Expand Down Expand Up @@ -232,10 +232,11 @@ def solve(self, model, **kwds):
if not os.path.exists(dname):
os.mkdir(dname)
basename = os.path.join(dname, model.name)
if os.path.exists(basename + '.nl'):
if os.path.exists(os.path.join(basename, '.nl')):
raise RuntimeError(
f"NL file with the same name {basename + '.nl'} already exists!"
)
print(basename, os.path.join(basename, '.nl'))
with (
open(os.path.join(basename, '.nl'), 'w') as nl_file,
open(os.path.join(basename, '.row'), 'w') as row_file,
Expand All @@ -248,7 +249,7 @@ def solve(self, model, **kwds):
col_file,
symbolic_solver_labels=config.symbolic_solver_labels,
)
with open(basename + '.opt', 'w') as opt_file:
with open(os.path.join(basename, '.opt'), 'w') as opt_file:
self._write_options_file(
ostream=opt_file, options=config.solver_options
)
Expand Down Expand Up @@ -288,7 +289,7 @@ def solve(self, model, **kwds):
else:
# TODO: Make a context manager out of this and open the file
# to pass to the results, instead of doing this thing.
with open(basename + '.sol', 'r') as sol_file:
with open(os.path.join(basename, '.sol'), 'r') as sol_file:
results = self._parse_solution(sol_file, self.info)

if (
Expand Down

0 comments on commit f23ed71

Please sign in to comment.