Optimizes the configuration of each node in the solution based on the cases. Args: case_list (list[Case]): The list of cases. solution (Solution): The solution to be optimized. Returns: dict: A dictionary with the optimization status and
(self, case_list: list[Case], solution: Solution)
| 173 | case.dump(os.path.join(save_dir, f"{case.case_id}.json")) |
| 174 | |
| 175 | def optimize_node(self, case_list: list[Case], solution: Solution): |
| 176 | """ |
| 177 | Optimizes the configuration of each node in the solution based on the cases. |
| 178 | |
| 179 | Args: |
| 180 | case_list (list[Case]): The list of cases. |
| 181 | solution (Solution): The solution to be optimized. |
| 182 | |
| 183 | Returns: |
| 184 | dict: A dictionary with the optimization status and method for each node. |
| 185 | """ |
| 186 | node_name_list = [] |
| 187 | for state in case_list[0].trajectory.states: |
| 188 | # Get unique node names based on case0's information and node_name is not duplicated |
| 189 | if state.node.node_name not in node_name_list: |
| 190 | node_name_list.append(state.node.node_name) |
| 191 | |
| 192 | # Do optimization for each node and get the optimization method |
| 193 | op_info = {} |
| 194 | for node_name in node_name_list: |
| 195 | new_node, op_status, op_method = self.optimize_single_node(case_list, solution.sop.nodes[node_name]) |
| 196 | solution.sop.nodes[node_name] = new_node |
| 197 | op_info[node_name] = {"optim_status": op_status, "optim_method": op_method} |
| 198 | |
| 199 | return op_info |
| 200 | |
| 201 | def optimize_single_node(self, case_list: list[Case], node: Node): |
| 202 | """ |
no test coverage detected