Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 17011

Google OR Tools - applying constraints with arrays

$
0
0

I want to apply the following constraint to a MILP:

L_i - X_ij @ L_j <= 0

Where X_ij is a matrix of binary variables, Li is a length of bars and Lj is represents a vector of the lengths of orders.These have all been defined as numpy arrays.Essentially, what I want to say is "the sum of the orders satisfied for a given bar must not exceed the length of that bar". I have tried implementing this is using:

Model.add(L_i - X_ij @ L_j >= numpy.array(np.size(L_i))

This is a returning an error:

NotImplementedError: Evaluating a BoundedLinearExpression '(-(((10 * assignment_0_0) + (7 * assignment_0_1)) + (6 * assignment_0_2)) + 8)>= 0' as a Boolean value is not supported.

I'm trying to use linear algebra as it is familiar to me and my team. Is there any way of implementing this constraint in the form I am trying to use?

I seem to think that this is something to do with the fact that the matrix is a series of bool variables and not typical python Boolean data types.Any help would be appreciated.


Viewing all articles
Browse latest Browse all 17011

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>