Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions PEPit/pep.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,9 @@ def set_performance_metric(self, expression, name=None):
# Store performance metric in the appropriate list
self.list_of_performance_metrics.append(expression)

def solve(self, wrapper="cvxpy", return_primal_or_dual="dual", verbose=1,
dimension_reduction_heuristic=None, eig_regularization=1e-3, tol_dimension_reduction=1e-4, **kwargs):
def solve(self, wrapper="cvxpy", return_primal_or_dual="dual", safe_mode=True, verbose=1,
dimension_reduction_heuristic=None, eig_regularization=1e-3, tol_dimension_reduction=1e-4,
**kwargs):
"""
Transform the :class:`PEP` under the SDP form, and solve it. Parse the options for solving the SDPs,
instantiate the concerning wrappers and call the main internal solve option for solving the PEP.
Expand All @@ -296,6 +297,9 @@ def solve(self, wrapper="cvxpy", return_primal_or_dual="dual", verbose=1,
(primal value of the objective).
Default is "dual".
Note both value should be almost the same by strong duality.
safe_mode (bool, optional): Enable safe mode that includes basic checks such as appropriate packages
being installed or not, or licenses. Deactivating might lead to codes that
are harder to debug.

verbose (int, optional): Level of information details to print
(Override the solver verbose parameter).
Expand All @@ -315,11 +319,11 @@ def solve(self, wrapper="cvxpy", return_primal_or_dual="dual", verbose=1,
eig_regularization (float, optional): The regularization we use to make
:math:`G + \\mathrm{eig_regularization}I_d \succ 0`.
(only used when "dimension_reduction_heuristic" is not None)
The default value is 1e-5.
The default value is 1e-3.
tol_dimension_reduction (float, optional): The error tolerance in the heuristic minimization problem.
Precisely, the second problem minimizes "optimal_value - tol"
(only used when "dimension_reduction_heuristic" is not None)
The default value is 1e-5.
The default value is 1e-4.
kwargs (keywords, optional): Additional solver-specific arguments.

Returns:
Expand All @@ -330,21 +334,23 @@ def solve(self, wrapper="cvxpy", return_primal_or_dual="dual", verbose=1,

# Check that the solver is installed, if it is not, switch to CVXPY.
found_python_package = importlib.util.find_spec(wrapper_name)
if found_python_package is None:
if verbose:
print('\033[96m(PEPit) {} not found in system environment,'
' switching to cvxpy\033[0m'.format(wrapper_name))
wrapper_name = "cvxpy"
if safe_mode:
if found_python_package is None:
if verbose:
print('\033[96m(PEPit) {} not found in system environment,'
' switching to cvxpy\033[0m'.format(wrapper_name))
wrapper_name = "cvxpy"

# Initiate a wrapper to interface with the solver
wrapper = WRAPPERS[wrapper_name](verbose=verbose)

# Check that a valid license to the solver is found. Otherwise, switch to CVXPY.
if not wrapper.check_license():
if verbose:
print('\033[96m(PEPit) No valid {} license found, switching to cvxpy\033[96m'.format(wrapper_name))
wrapper_name = "cvxpy"
wrapper = WRAPPERS[wrapper_name](verbose=verbose)
if safe_mode:
if not wrapper.check_license():
if verbose:
print('\033[96m(PEPit) No valid {} license found, switching to cvxpy\033[96m'.format(wrapper_name))
wrapper_name = "cvxpy"
wrapper = WRAPPERS[wrapper_name](verbose=verbose)

# Store wrapper information in self
self.wrapper_name = wrapper_name
Expand Down
4 changes: 3 additions & 1 deletion docs/source/whatsnew/0.4.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ What's new in PEPit 0.4.1

- Added uselessly complexified tests to verify numerically that the formulations are in line.

- Fix: An integer overflow (due to previously specified dtype=int8) in :class:`MosekWrapper` has been fixed.
- Fix: An integer overflow (due to previously specified dtype=int8) in :class:`MosekWrapper` has been fixed.

- New: one can disable some software verification tools (licensing, installation, etc) to allow for fast processing time (via boolean option safe_mode).