DCCP package provides an organized heuristic for convex-concave programming. It tries to solve nonconvex problems where every function in the objective and the constraints has any known curvature according to the rules of disciplined convex programming (DCP). For instance, DCCP can be used to maximize a convex function. The full details of our approach are discussed in the associated paper. DCCP is built on top of CVXPY, a domain-specific language for convex optimization embedded in Python.
You should first install CVXPY 1.5 or greater.
You can install the latest DCCP package via pip:
pip install dccp
To install the development version, clone this repository and install in development mode:
git clone https://github.com/cvxgrp/dccp.git
cd dccp
pip install -e .
A problem satisfies the rules of disciplined convex-concave programming (DCCP) if it has the form
where
In a disciplined convex program, the curvatures of
The variables, parameters, and constants in DCCP should be real numbers. Problems containing complex numbers may not be supported by DCCP.
The following code uses DCCP to approximately solve a simple nonconvex problem.
import cvxpy as cp
import dccp
x = cp.Variable(2)
y = cp.Variable(2)
myprob = cp.Problem(cp.Maximize(cp.norm(x - y, 2)), [0 <= x, x <= 1, 0 <= y, y <= 1])
print("problem is DCP:", myprob.is_dcp()) # False
print("problem is DCCP:", dccp.is_dccp(myprob)) # True
result = myprob.solve(method='dccp', seed=3)
print("x =", x.value.round(3))
print("y =", y.value.round(3))
print("cost value =", result)
The output of the above code is as follows.
problem is DCP: False
problem is DCCP: True
x = [1. 0.]
y = [0. 1.]
cost value = 1.4142135623730951
The solutions obtained by DCCP can depend on the initial point of the CCP algorithm.
The algorithm starts from the values of any variables that are already specified; for any that are not specified, random values are used.
You can specify an initial value manually by setting the value
field of the variable.
For example, the following code runs the CCP algorithm with the specified initial values for x
and y
:
import numpy
x.value = numpy.array([1, 2])
y.value = numpy.array([-1, 1])
result = myprob.solve(method='dccp')
By first clearing the variable values using x.value = None
and y.value = None
, the CCP algorithm will use random initial values.
Setting the parameter k_ccp
specifies the number of times that the CCP algorithm runs, starting from random initial values for all variables. The best solution found is returned.
For all available parameters, see the documentation.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
If you wish to cite DCCP, please cite the DCCP papers listed in our citation guide or copy the text below.
@article{shen2016disciplined,
author = {Xinyue Shen and Steven Diamond and Yuantao Gu and Stephen Boyd},
title = {Disciplined convex-concave programming},
journal = {2016 IEEE 55th Conference on Decision and Control (CDC)},
pages = {1009--1014},
year = {2016},
url = {https://stanford.edu/~boyd/papers/dccp.html},
}