Create constraints for list variable in CVXPY

0

In CVXPY I created a variable called "contracts", which includes 126 elements.

contracts = cp.Variable(126, integer=True)

I have two pandas series (1x126) with min and max values for each of the 126 elements (called "min_contracts" and "max_contracts"). In order to massively add constraints for each of the 126 elements of my variable, I tried the following:

constraints = [min_contracts <= contracts, contracts <= max_contracts]

but I get the following AttributeError: 'Series' object has no attribute 'parameters' . What could I try? Thanks

cvxpy optimization python
2021-10-24 07:40:47
1

0

I realized that I need to transform the pandas series into lists.

Adding the following fixed the issue

min_contracts = min_contracts.tolist()
max_contracts = max_contracts.tolist()
2021-10-24 10:33:37

In other languages

This page is in other languages

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................