Skip to content

Commit

Permalink
Merge pull request smdogroup#47 from gjkennedy/pyoptsparse-wrapper
Browse files Browse the repository at this point in the history
added small fixes to the wrapper
  • Loading branch information
gjkennedy authored Dec 7, 2023
2 parents 9e0199a + 80dbbf5 commit 33343ab
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions paropt/paropt_pyoptsparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
# External modules
import numpy as np

from paropt import ParOpt as ParOpt
from paropt import ParOpt
from mpi4py import MPI

# Local modules
from pyoptsparse.pyOpt_error import Error
from pyoptsparse.pyOpt_optimizer import Optimizer
from pyoptsparse.pyOpt_utils import INFINITY, IROW, ICOL
from pyoptsparse.pyOpt_utils import extractRows, INFINITY, IROW, ICOL


class ParOptSparseProblem(ParOpt.Problem):
Expand Down Expand Up @@ -244,12 +244,14 @@ def __call__(
if self.optProb.comm.rank == 0:
optTime = MPI.Wtime()

# Get the constraint Jacobian data
# Build the sparsity pattern for the Jacobian
gcon = {}
for iCon in self.optProb.constraints:
gcon[iCon] = self.optProb.constraints[iCon].jac
jac = self.optProb.processConstraintJacobian(gcon)
jac = extractRows(jac, indices)

# Extract the non-zero CSR pattern
rowp = jac["csr"][IROW]
cols = jac["csr"][ICOL]

Expand Down Expand Up @@ -288,6 +290,8 @@ def __call__(
# are switch since ParOpt uses a formulation with c(x) >= 0, while pyOpt
# uses g(x) = -c(x) <= 0. Therefore the multipliers are reversed.
sol_inform = {}
sol_inform["value"] = ""
sol_inform["text"] = ""

# If number of constraints is zero, ParOpt returns z as None.
# Thus if there is no constraints, should pass an empty list
Expand Down

0 comments on commit 33343ab

Please sign in to comment.