1212class DiscretePainter (Painter ):
1313 def __init__ (self , search_data_sorted , bestsvalues , pcount , floatdim , optimumPoint , discreteValues ,
1414 discrete_name , mode , calc , subparameters , lb , rb , file_name , path_for_saves , calculate ,
15- optimum_value , search_data , number_of_parallel_points ):
15+ optimum_value , search_data , number_of_parallel_points , number_of_constraints ):
1616 self .path_for_saves = path_for_saves
1717 self .file_name = file_name
1818 self .calc = calc
1919 self .calculate = calculate
2020 self .optimum = optimumPoint
2121 self .optimumVal = optimum_value
2222 self .number_of_parallel_points = number_of_parallel_points
23+ self .number_of_constraints = number_of_constraints
2324
2425 self .values = []
2526 self .points = []
@@ -130,7 +131,8 @@ def __init__(self, search_data: SearchData,
130131 is_points_at_bottom ,
131132 parameter_in_nd_problem ,
132133 path_for_saves ,
133- file_name
134+ file_name ,
135+ number_of_constraints
134136 ):
135137 self .path_for_saves = path_for_saves
136138 self .file_name = file_name
@@ -139,6 +141,7 @@ def __init__(self, search_data: SearchData,
139141 self .is_points_at_bottom = is_points_at_bottom
140142
141143 self .objFunc = solution .problem .calculate
144+ self .number_of_constraints = number_of_constraints
142145
143146 # формируем массив точек итераций для графика
144147 self .points = []
@@ -153,7 +156,7 @@ def __init__(self, search_data: SearchData,
153156
154157 self .optimum = solution .best_trials [0 ].point .float_variables
155158 self .optimumC = solution .best_trials [0 ].point .float_variables [parameter_in_nd_problem ]
156- self .optimumValue = solution .best_trials [0 ].function_values [0 ].value
159+ self .optimumValue = solution .best_trials [0 ].function_values [self . number_of_constraints ].value
157160
158161 # настройки графика
159162 self .plotter = Plotter2D (parameter_in_nd_problem ,
@@ -202,14 +205,15 @@ def calculate_func(self, x):
202205 return fv .value
203206
204207class StaticPainterND (Painter ):
205- def __init__ (self , search_data , solution , parameters , mode , calc , file_name , path_for_saves ):
208+ def __init__ (self , search_data , solution , parameters , mode , calc , file_name , path_for_saves , number_of_constraints ):
206209 self .path_for_saves = path_for_saves
207210 self .file_name = file_name
208211
209212 self .objectFunctionPainterType = mode
210213 self .objectFunctionCalculatorType = calc
211214
212215 self .objFunc = solution .problem .calculate
216+ self .number_of_constraints = number_of_constraints
213217
214218 # формируем массив точек итераций для графика
215219 self .points = []
@@ -223,7 +227,10 @@ def __init__(self, search_data, solution, parameters, mode, calc, file_name, pat
223227 self .values = self .values [1 :- 1 ]
224228
225229 self .optimum = solution .best_trials [0 ].point .float_variables
226- self .optimumValue = solution .best_trials [0 ].function_values [0 ].value
230+ self .optimum_section = [solution .best_trials [0 ].point .float_variables [parameters [0 ]],
231+ solution .best_trials [0 ].point .float_variables [parameters [1 ]]]
232+
233+ self .optimumValue = solution .best_trials [0 ].function_values [self .number_of_constraints ].value
227234
228235 self .leftBounds = [float (solution .problem .lower_bound_of_float_variables [parameters [0 ]]),
229236 float (solution .problem .lower_bound_of_float_variables [parameters [1 ]])]
@@ -258,7 +265,7 @@ def paint_points(self, curr_point: SearchDataItem = None):
258265 self .plotter .plot_points (self .points , self .values , 'blue' , 'o' , 4 )
259266
260267 def paint_optimum (self , solution : Solution = None ):
261- self .plotter .plot_points ([self .optimum ], [self .optimumValue ], 'red' , 'o' , 4 )
268+ self .plotter .plot_points ([self .optimum_section ], [self .optimumValue ], 'red' , 'o' , 4 )
262269
263270 def save_image (self ):
264271 if not os .path .isdir (self .path_for_saves ):
0 commit comments