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

adding stale linking variables explicitly to pyomoNLP #43

Open
wants to merge 2 commits into
base: main_branch
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions parapint/interfaces/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,12 @@ def regularize_hessian(self, kkt, coef, copy_kkt=True):


class InteriorPointInterface(BaseInteriorPointInterface):
def __init__(self, pyomo_model):
def __init__(self, pyomo_model, export_nonlinear_variables = []):
if type(pyomo_model) is str:
# Assume argument is the name of an nl file
self._nlp = ampl_nlp.AmplNLP(pyomo_model)
else:
self._nlp = pyomo_nlp.PyomoNLP(pyomo_model, nl_file_options={'skip_trivial_constraints': True})
self._nlp = pyomo_nlp.PyomoNLP(pyomo_model, nl_file_options={'skip_trivial_constraints': True, 'export_nonlinear_variables': export_nonlinear_variables})
self._slacks = self.init_slacks()

# set the init_duals_primals_lb/ub from ipopt_zL_out, ipopt_zU_out if available
Expand Down
4 changes: 3 additions & 1 deletion parapint/interfaces/schur_complement/mpi_sc_ip_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import numpy as np
from typing import Dict, Optional, Sequence
from pyomo.common.timing import HierarchicalTimer
from pyomo.common.collections import ComponentSet
from mpi4py import MPI
from .sc_ip_interface import DynamicSchurComplementInteriorPointInterface, StochasticSchurComplementInteriorPointInterface

Expand Down Expand Up @@ -197,7 +198,8 @@ def _setup(self, start_t: float, end_t: float):
start_t=_start_t,
end_t=_end_t,
add_init_conditions=add_init_conditions)
self._nlps[ndx] = nlp = InteriorPointInterface(pyomo_model=pyomo_model)
linking_vars = [v for v in start_states] + [v for v in end_states if v not in ComponentSet(start_states)]
self._nlps[ndx] = nlp = InteriorPointInterface(pyomo_model=pyomo_model, export_nonlinear_variables=linking_vars)
assert len(start_states) == len(end_states)
if self._num_states is not None:
assert self._num_states == len(start_states)
Expand Down
4 changes: 3 additions & 1 deletion parapint/interfaces/schur_complement/sc_ip_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pyomo.core.base.var import _GeneralVarData
from pyomo.core.base.constraint import _GeneralConstraintData
from pyomo.common.timing import HierarchicalTimer
from pyomo.common.collections import ComponentSet


class DynamicSchurComplementInteriorPointInterface(BaseInteriorPointInterface, metaclass=ABCMeta):
Expand Down Expand Up @@ -159,7 +160,8 @@ def _setup(self, start_t: float, end_t: float):
start_t=_start_t,
end_t=_end_t,
add_init_conditions=add_init_conditions)
self._nlps[ndx] = nlp = InteriorPointInterface(pyomo_model=pyomo_model)
linking_vars = [v for v in start_states] + [v for v in end_states if v not in ComponentSet(start_states)]
self._nlps[ndx] = nlp = InteriorPointInterface(pyomo_model=pyomo_model, export_nonlinear_variables=linking_vars)
assert len(start_states) == len(end_states)
if self._num_states is not None:
assert self._num_states == len(start_states)
Expand Down