(self, verbosity: int = 0)
| 659 | return rv |
| 660 | |
| 661 | def solve(self, verbosity: int = 0) -> Tuple[List[Location], Dict[str, Any]]: |
| 662 | |
| 663 | suppress_banner = "yes" if verbosity == 0 else "no" |
| 664 | |
| 665 | opti = self.opti |
| 666 | |
| 667 | constraints = self.constraints |
| 668 | variables = self.variables |
| 669 | start_points = self.start_points |
| 670 | |
| 671 | # construct a penalty term |
| 672 | penalty = 0.0 |
| 673 | |
| 674 | for T, R in variables: |
| 675 | penalty += ca.sumsqr(ca.vertcat(T / self.scale, R)) |
| 676 | |
| 677 | # construct the objective |
| 678 | objective = 0.0 |
| 679 | for ks, (ms, kind, params) in constraints: |
| 680 | |
| 681 | # select the relevant variables and starting points |
| 682 | s_ks: List[ca.DM] = [] |
| 683 | v_ks: List[ca.MX] = [] |
| 684 | |
| 685 | for k in ks: |
| 686 | s_ks.extend(start_points[k]) |
| 687 | v_ks.extend(variables[k]) |
| 688 | |
| 689 | c = costs[kind]( |
| 690 | opti, |
| 691 | *ms, |
| 692 | *s_ks, |
| 693 | *v_ks, |
| 694 | params, |
| 695 | scale=self.scale if scaling[kind] else 1, |
| 696 | ) |
| 697 | |
| 698 | if c is not None: |
| 699 | objective += c |
| 700 | |
| 701 | opti.minimize(objective + 1e-16 * penalty) |
| 702 | |
| 703 | # solve |
| 704 | opti.solver( |
| 705 | "ipopt", |
| 706 | {"print_time": False}, |
| 707 | { |
| 708 | "acceptable_obj_change_tol": 1e-12, |
| 709 | "acceptable_iter": 1, |
| 710 | "tol": 1e-14, |
| 711 | "hessian_approximation": "exact", |
| 712 | "nlp_scaling_method": "none", |
| 713 | "honor_original_bounds": "yes", |
| 714 | "bound_relax_factor": 0, |
| 715 | "print_level": verbosity, |
| 716 | "sb": suppress_banner, |
| 717 | "print_timing_statistics": "no", |
| 718 | "linear_solver": "mumps", |
no test coverage detected