Forum Discussion
FICO
5 years agoCommunity Manager
Storing python xp.constraint objects in numpy arrays or pandas Series
We would like to store a list of xpress xp.constraint objects in a pandas Series. We have found that the xp.constraint objects cannot be stored in numpy arrays or pandas Series. Here is example cod...
FICO
5 years agoCommunity Manager
I am using Xpress 8.11.3 conda package. Seems like it is fixed in 8.12 . So that explains it.
Unfortunately, that numpy array with a dtype of `xp.npconstraint` can't be put in a pandas `Series` in 8.11.3:
import xpress as xp
import numpy as np
import pandas as pd
v = xp.var("v")
ct = xp.constraint(v >= 0)
ctl = [ct]
na = np.array(ctl, dtype=xp.npconstraint)
print("na is ", na)
s2 = pd.Series(na)
print("s2 is ", s2)This produces:
File "/home/ubuntu/anaconda3/envs/optiwrap37/lib/python3.7/site-packages/pandas/core/series.py", line 307, in __init__
"Cannot construct a Series from an ndarray with "
ValueError: Cannot construct a Series from an ndarray with compound dtype. Use DataFrame instead.Using `DataFrame` doesn't work either.
Related Content
Related Content
How to apply termination conditions to each objective function in multi-objective model
Hello everyone, I am implementing a multi-objective model in Python, and I would like to set a time limit for each objective function. It would be best if I could set different time limits for each,...1 year agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum4 unread comments4 unread3Views0likes4CommentsVariable object mapping issue in Python Callbacks with Presolve enabled
Hi, I am implementing a Branch-and-Cut algorithm using the Xpress Python interface. I have structured my code as a class where I create variables (using xp.var) and store them in a dictionary attrib...9 months agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum6 unread comments6 unread6Views0likes6Comments