diff --git a/pyoptsparse/pyALPSO/pyALPSO.py b/pyoptsparse/pyALPSO/pyALPSO.py index f684e501..6268618c 100644 --- a/pyoptsparse/pyALPSO/pyALPSO.py +++ b/pyoptsparse/pyALPSO/pyALPSO.py @@ -2,6 +2,7 @@ pyALPSO - A pyOptSparse interface to ALPSO work with sparse optimization problems. """ + # Standard Python modules import datetime import time @@ -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) diff --git a/pyoptsparse/pyCONMIN/pyCONMIN.py b/pyoptsparse/pyCONMIN/pyCONMIN.py index 87d084ed..97b57930 100644 --- a/pyoptsparse/pyCONMIN/pyCONMIN.py +++ b/pyoptsparse/pyCONMIN/pyCONMIN.py @@ -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 @@ -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) diff --git a/pyoptsparse/pyNSGA2/pyNSGA2.py b/pyoptsparse/pyNSGA2/pyNSGA2.py index e5418f58..c6bd2e5c 100644 --- a/pyoptsparse/pyNSGA2/pyNSGA2.py +++ b/pyoptsparse/pyNSGA2/pyNSGA2.py @@ -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 @@ -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): diff --git a/pyoptsparse/pyParOpt/ParOpt.py b/pyoptsparse/pyParOpt/ParOpt.py index f08e33b4..e0e15be4 100644 --- a/pyoptsparse/pyParOpt/ParOpt.py +++ b/pyoptsparse/pyParOpt/ParOpt.py @@ -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 diff --git a/tests/testing_utils.py b/tests/testing_utils.py index fce54c26..fa94cb06 100644 --- a/tests/testing_utils.py +++ b/tests/testing_utils.py @@ -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.