1
$\begingroup$

I am working with a dataset that contains multiple entries for different IDs across various years. Some IDs might have a gap of years between entries. My goal is to solve an optimization problem using CVXPY, where I impose constraints based on the annualized rate of change of a variable associated with each ID across years. When there are gaps between years for a given ID, I aim to consider the rate of change as evenly distributed across the gap years. For instance, if an ID has a 20% increase from the year 2010 to 2012, I calculate the annualized rate of change as $\sqrt[2012-2010]{\frac{{\text{value2012}}}{\text{value2010}}}$

However, when incorporating this logic into my CVXPY problem, I am encountering a DCPError: "Problem does not follow DCP rules".

Below is a simplified version of my code that illustrates the issue:

import cvxpy as cp

# Define CVXPY variables
vars = {
    "value2010": cp.Variable(name="value2010"),
    "value2012": cp.Variable(name="value2012"),
}

# Initialize constraints list
constraints = []
gap_years = 2012 - 2010
c = cp.Variable(nonneg=True)

# Calculate the annualized deviation and add the constraint
annualized_deviation = cp.power(vars["value2012"] / vars["value2010"], 1/gap_years)
constraints.append(cp.square(annualized_deviation - 1) <= c)

# Additional constraints/data for value2010/value2012 would be added here

# Define the objective function and solve the problem
objective = cp.Minimize(c)
problem = cp.Problem(objective, constraints)
problem.solve()

I understand that the error arises due to the division of one CVXPY variable by another, as discussed in several posts (1, 2, 3, 4, 5). I have also read this answer that raises the possibility of variable division under certain conditions by converting the problem to QCP, but I am not entirely sure how to apply this to my specific case.

I would appreciate any guidance on how to address this issue, whether through an alternative formulation, clarification of the concepts involved, or any other means to incorporate the annualized rate of change in a optimization problem while handling year gaps.

$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.