Skip to content

Commit 86d1282

Browse files
Merge pull request #15 from esa/fix/get_extra_info4
Fix/get extra info4
2 parents 223df40 + 62bf0e3 commit 86d1282

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

pyoptgra/optgra.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,11 @@ def extract_trailing_integer(s):
583583
)
584584

585585
best_x, best_f, finopt = result
586+
# FINOPT
587+
# -> 1= MATCHED & OPTIMAL
588+
# -> 2= MATCHED & NOT OPTIMAL
589+
# -> 3=NOT MATCHED & NOT OPTIMAL
590+
# -> 4=NOT FEASIBL & NOT OPTIMAL
586591

587592
# if a Khan function is used we first need to convert to pagmo parameters
588593
if khanf:
@@ -597,13 +602,14 @@ def extract_trailing_integer(s):
597602
# pagmo_fitness = [best_f[-1]] + best_f[0 : problem.get_nc()]
598603
population.set_x(idx, best_x) # , list(pagmo_fitness))
599604

600-
# store last result for output
605+
# store last result for get_extra_info() method
601606
self.__last_result = {
602607
"f": population.champion_f,
603608
"x": best_x,
604609
"con_tol": problem.c_tol,
605610
"nec": problem.get_nec(),
606611
"has_gradient": problem.has_gradient(),
612+
"finopt": finopt,
607613
}
608614

609615
return population
@@ -865,8 +871,15 @@ def get_extra_info(self) -> str:
865871
+ "Final objective value ............. {obj}\n"
866872
+ "Final constraint violation ........ {con_vio}\n"
867873
+ "Final num. of violated constraints {num_vio}\n"
868-
+ "Successful termination: Optimal Solution Found.\n"
869874
).format(obj=self.__last_result["f"][0], con_vio=con_vio, num_vio=num_vio)
875+
if self.__last_result["finopt"] == 1:
876+
result_str += "Successful termination: Optimal Solution Found.\n"
877+
elif self.__last_result["finopt"] == 2:
878+
result_str += "Successful termination: Constraints matched.\n"
879+
elif self.__last_result["finopt"] == 3:
880+
result_str += "Not converged.\n"
881+
elif self.__last_result["finopt"] == 4:
882+
result_str += "Problem appears infeasible.\n"
870883
else:
871884
grad_str = ""
872885
result_str = (

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ license = { text = "GPL-3.0 or ESCL-2.4" }
1010
name = "pyoptgra"
1111
readme = "README.rst"
1212
requires-python = ">=3.9"
13-
version = "1.2.1"
13+
version = "1.2.2"
1414

1515
[build-system]
1616
build-backend = "scikit_build_core.build"

0 commit comments

Comments
 (0)