MCPcopy Create free account
hub / github.com/cvxpy/cvxpy / get_problem_data

Method get_problem_data

cvxpy/problems/problem.py:703–900  ·  view source on GitHub ↗

Returns the problem data used in the call to the solver. When a problem is solved, CVXPY creates a chain of reductions enclosed in a :class:`~cvxpy.reductions.solvers.solving_chain.SolvingChain`, and compiles it to some low-level representation that is compatible wit

(
        self, solver,
        gp: bool = False,
        enforce_dpp: bool = False,
        ignore_dpp: bool = False,
        verbose: bool = False,
        canon_backend: str | None = None,
        solver_opts: dict | None = None,
    )

Source from the content-addressed store, hash-verified

701 cls.REGISTERED_SOLVE_METHODS[name] = func
702
703 def get_problem_data(
704 self, solver,
705 gp: bool = False,
706 enforce_dpp: bool = False,
707 ignore_dpp: bool = False,
708 verbose: bool = False,
709 canon_backend: str | None = None,
710 solver_opts: dict | None = None,
711 ):
712 """Returns the problem data used in the call to the solver.
713
714 When a problem is solved, CVXPY creates a chain of reductions enclosed
715 in a :class:`~cvxpy.reductions.solvers.solving_chain.SolvingChain`,
716 and compiles it to some low-level representation that is
717 compatible with the targeted solver. This method returns that low-level
718 representation.
719
720 For some solving chains, this low-level representation is a dictionary
721 that contains exactly those arguments that were supplied to the solver;
722 however, for other solving chains, the data is an intermediate
723 representation that is compiled even further by the solver interfaces.
724
725 A solution to the equivalent low-level problem can be obtained via the
726 data by invoking the `solve_via_data` method of the returned solving
727 chain, a thin wrapper around the code external to CVXPY that further
728 processes and solves the problem. Invoke the unpack_results method
729 to recover a solution to the original problem.
730
731 For example:
732
733 ::
734
735 objective = ...
736 constraints = ...
737 problem = cp.Problem(objective, constraints)
738 data, chain, inverse_data = problem.get_problem_data(cp.SCS)
739 # calls SCS using `data`
740 soln = chain.solve_via_data(problem, data)
741 # unpacks the solution returned by SCS into `problem`
742 problem.unpack_results(soln, chain, inverse_data)
743
744 Alternatively, the `data` dictionary returned by this method
745 contains enough information to bypass CVXPY and call the solver
746 directly.
747
748 For example:
749
750 ::
751
752 problem = cp.Problem(objective, constraints)
753 data, _, _ = problem.get_problem_data(cp.SCS)
754
755 import scs
756 probdata = {
757 'A': data['A'],
758 'b': data['b'],
759 'c': data['c'],
760 }

Callers 15

scs_conicliftFunction · 0.95
_solveMethod · 0.95
test_quad_objMethod · 0.95
test_nag_quad_objMethod · 0.95
test_param_dataMethod · 0.95
test_var_boundsMethod · 0.95
test_daqp_var_boundsMethod · 0.95
test_highs_var_boundsMethod · 0.95

Calls 13

_construct_chainMethod · 0.95
parametersMethod · 0.95
DPPErrorClass · 0.90
SolverInverseDataClass · 0.90
typeClass · 0.85
make_keyMethod · 0.80
invalidateMethod · 0.80
printFunction · 0.50
getMethod · 0.45
infoMethod · 0.45
update_parametersMethod · 0.45
applyMethod · 0.45