Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: list indices must be integers or slices, not VariableInteger #31

Closed
jarandaf opened this issue Dec 13, 2022 · 3 comments
Closed

Comments

@jarandaf
Copy link

jarandaf commented Dec 13, 2022

I am trying to reproduce the Warehouse Location problem shown in the docs. I am getting the title error as soon as I use the variable w for indexing:

minimize(
    # minimizing the cost of supplying stores
    Sum(costs[i][w[i]] for i in range(nStores))
);

Any hints?

@jarandaf
Copy link
Author

I managed to make it work by wrapping the list of costs with pycsp3.tools.curser.ListInt. I take the opportunity to ask if float is a supported type when minimizing/maximizing an objective.

@xcsp3team
Copy link
Owner

Hi,

indeed, when data are directly given in the code (and not loaded from a file),
you may need to get the right type for lists of integers (and lists of variables)
by calling cp_array as in:
costs = cp_array(costs)

For the moment, float is not supported (but it may be the case in the future).

@jarandaf
Copy link
Author

Thank you for the quick answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants