Open metanoid opened 4 years ago
Thanks for opening the issue. The short version: This is currently not possible. There is currently no way to index an array by the value of a variable in JuMP. The package JuCP.jl will eventually make it possible I think/hope and then I need to implement it here ;) Sorry that the ConstraintSolver is currently quite limited :/
Is there a recommended workaround way of doing what I'm trying to do above, but without indexing by the value of the variable?
If not, I'm relatively confident I can do the above as a binary programming problem, I just wanted to use ConstraintSolver
to be fancy, so no stress.
I would write it as a binary problem as well. At least currently I can't think of a workaround. Nevertheless thanks for having another try at my solver :smile:
I'm getting closer with this one as you seem to only need it for constant arrays. (#213) The problem here is also that you do some boolean logic inside the indexing which I don't have an idea for how to accomplish that kind of magic yet :smile:
I have
p
products, and for each product I have a possibility ofl
price levels. For each such product and price level, I have the expected quantity sold, in aDataFrame
calledvals
. I want to add a constraint that the total quantity sold must be greater than a constant.If I used a binary programming approach, I would multiply each product's potential quantity by the binary decision variable. But I'm trying to solve this using an integer decision variable to represent the price level, and I realise I don't know how to use the value of a given variable as a lookup.
What I tried:
However, this does not work. Is this sort of "indexing by the value of a variable" even possible? If so, what would a good design for such a thing look like?