Skip to content

Commit

Permalink
Populate inform dict for all optimizers (#394)
Browse files Browse the repository at this point in the history
* populate inform dict

* bugfix version bump

* revert version bump

* use empty string instead of None

* test print(sol)
  • Loading branch information
ewu63 authored Apr 24, 2024
1 parent 69c2a6f commit 01d5111
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
5 changes: 2 additions & 3 deletions pyoptsparse/pyALPSO/pyALPSO.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pyALPSO - A pyOptSparse interface to ALPSO
work with sparse optimization problems.
"""

# Standard Python modules
import datetime
import time
Expand Down Expand Up @@ -191,9 +192,7 @@ def objconfunc(x):
self.optProb.comm.bcast(-1, root=0)

# Store Results
sol_inform = {}
# sol_inform['value'] = inform
# sol_inform['text'] = self.informs[inform[0]]
sol_inform = {"value": "", "text": ""}

# Create the optimization solution
sol = self._createSolution(optTime, sol_inform, opt_f, opt_x)
Expand Down
5 changes: 2 additions & 3 deletions pyoptsparse/pyCONMIN/pyCONMIN.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pyCONMIN - A variation of the pyCONMIN wrapper specificially designed to
work with sparse optimization problems.
"""

# Standard Python modules
import datetime
import os
Expand Down Expand Up @@ -240,9 +241,7 @@ def cnmngrad(n1, n2, x, f, g, ct, df, a, ic, nac):
self.optProb.comm.bcast(-1, root=0)

# Store Results
sol_inform = {}
# sol_inform['value'] = inform
# sol_inform['text'] = self.informs[inform[0]]
sol_inform = {"value": "", "text": ""}

# Create the optimization solution
sol = self._createSolution(optTime, sol_inform, ff, xs)
Expand Down
3 changes: 2 additions & 1 deletion pyoptsparse/pyNSGA2/pyNSGA2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pyNSGA2 - A variation of the pyNSGA2 wrapper specificially designed to
work with sparse optimization problems.
"""

# Standard Python modules
import os
import time
Expand Down Expand Up @@ -180,7 +181,7 @@ def objconfunc(nreal, nobj, ncon, x, f, g):
self.optProb.comm.bcast(-1, root=0)

# Store Results
sol_inform = {}
sol_inform = {"value": "", "text": ""}

xstar = [0.0] * n
for i in range(n):
Expand Down
4 changes: 1 addition & 3 deletions pyoptsparse/pyParOpt/ParOpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,7 @@ def evalObjConGradient(self, x, g, A):
# Create the optimization solution. Note that the signs on the multipliers
# 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"] = None
sol_inform["text"] = None
sol_inform = {"value": "", "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
3 changes: 3 additions & 0 deletions tests/testing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ def assert_solution_allclose(self, sol, tol, partial_x=False):
):
assert_dict_allclose(sol.lambdaStar, self.lambdaStar[self.sol_index], atol=tol, rtol=tol)

# test printing solution
print(sol)

def assert_inform_equal(self, sol, optInform=None):
"""
Check that the optInform stored in the Solution object is as expected.
Expand Down

0 comments on commit 01d5111

Please sign in to comment.