|
| 1 | +""" |
| 2 | +This file is the CVXPY QP extension of the Cardinal Optimizer |
| 3 | +""" |
| 4 | + |
| 5 | +import cvxpy.settings as s |
| 6 | +from cvxpy.reductions.solvers.nlp_solvers.nlp_solver import NLPsolver |
| 7 | +from cvxpy.utilities.citations import CITATION_DICT |
| 8 | + |
| 9 | + |
| 10 | +class IPOPT(NLPsolver): |
| 11 | + """ |
| 12 | + NLP interface for the IPOPT solver |
| 13 | + """ |
| 14 | + # Solve capabilities |
| 15 | + MIP_CAPABLE = True |
| 16 | + |
| 17 | + # Keyword arguments for the CVXPY interface. |
| 18 | + INTERFACE_ARGS = ["save_file", "reoptimize"] |
| 19 | + |
| 20 | + # Map between IPOPT status and CVXPY status |
| 21 | + STATUS_MAP = { |
| 22 | + 1: s.OPTIMAL, # optimal |
| 23 | + 2: s.INFEASIBLE, # infeasible |
| 24 | + 3: s.UNBOUNDED, # unbounded |
| 25 | + 4: s.INF_OR_UNB, # infeasible or unbounded |
| 26 | + 5: s.SOLVER_ERROR, # numerical |
| 27 | + 6: s.USER_LIMIT, # node limit |
| 28 | + 7: s.OPTIMAL_INACCURATE, # imprecise |
| 29 | + 8: s.USER_LIMIT, # time out |
| 30 | + 9: s.SOLVER_ERROR, # unfinished |
| 31 | + 10: s.USER_LIMIT # interrupted |
| 32 | + } |
| 33 | + |
| 34 | + def name(self): |
| 35 | + """ |
| 36 | + The name of solver. |
| 37 | + """ |
| 38 | + return 'COPT' |
| 39 | + |
| 40 | + def import_solver(self): |
| 41 | + """ |
| 42 | + Imports the solver. |
| 43 | + """ |
| 44 | + import cyipopt # noqa F401 |
| 45 | + |
| 46 | + def invert(self, solution, inverse_data): |
| 47 | + """ |
| 48 | + Returns the solution to the original problem given the inverse_data. |
| 49 | + """ |
| 50 | + pass |
| 51 | + |
| 52 | + def solve_via_data(self, data, warm_start: bool, verbose: bool, solver_opts, solver_cache=None): |
| 53 | + """ |
| 54 | + Returns the result of the call to the solver. |
| 55 | +
|
| 56 | + Parameters |
| 57 | + ---------- |
| 58 | + data : dict |
| 59 | + Data used by the solver. |
| 60 | + warm_start : bool |
| 61 | + Not used. |
| 62 | + verbose : bool |
| 63 | + Should the solver print output? |
| 64 | + solver_opts : dict |
| 65 | + Additional arguments for the solver. |
| 66 | + solver_cache: None |
| 67 | + None |
| 68 | +
|
| 69 | + Returns |
| 70 | + ------- |
| 71 | + tuple |
| 72 | + (status, optimal value, primal, equality dual, inequality dual) |
| 73 | + """ |
| 74 | + pass |
| 75 | + |
| 76 | + def cite(self, data): |
| 77 | + """Returns bibtex citation for the solver. |
| 78 | +
|
| 79 | + Parameters |
| 80 | + ---------- |
| 81 | + data : dict |
| 82 | + Data generated via an apply call. |
| 83 | + """ |
| 84 | + return CITATION_DICT["COPT"] |
0 commit comments