Skip to content

Commit 99026b5

Browse files
added result flag to get_extra_info
1 parent 223df40 commit 99026b5

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

pyoptgra/optgra.py

Lines changed: 14 additions & 1 deletion
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:
@@ -604,6 +609,7 @@ def extract_trailing_integer(s):
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 = (

0 commit comments

Comments
 (0)