Forum Discussion
FICO
3 years agoCommunity Manager
python API Question : dictionary with tuple keys and xpress variables
I'm trying to convert gurobi to xpress
does xpress python api has data object like tupledict in gurobi?
I want to select the variables specified by the designated index in tuple key...
Or any other options?
Thanks for your help in advance.
1 Reply
- FICOCommunity Manager
No, something like this does not exist in the Xpress Python API. However, it is not too hard to get something equivalent using list comprehension:
import xpress as xp keys = [(1,1), (1,2), (1,3), (2,1), (2,3), (3,3)] # Create a dictionary of variables x = xp.vars(keys) # prints "x((1, 1)) + x((1, 2)) + x((1, 3))" (selects only variables with first index 1) print(xp.Sum(x[k] for k in x if k[0] == 1)) # prints "x((1, 2))" (selects only variables with second index 2) print(xp.Sum(x[k] for k in x if k[1] == 2))
Related Content
Related Content
Question about the benders example
Hello, I am an ordinary student studying optimization with Xpress. First, I downloaded and ran the Python file from the xpress example to reference while implementing benders decomposition using ...1 year agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum3 unread comments3 unread9Views0likes3CommentsHow to use chgmcoef or similar functions to change constraints coefficients with indexed dictionary
Hello Xpress experts! I would appreciate if you could help me figure out the following question. Thanks in advance! I have a dummy problem with both variables and constraints defined in dictionary s...3 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum1 unread comment1 unread4Views0likes1CommentVariable names in callback (Java API)
I construct a cut in a preintsol callback using variables from the model containing the callback. When constructing the model, I give the variables names (using withName(...)) and store them in a vec...10 months agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum4 unread comments4 unread17Views0likes4Comments