Reputation: 647
I'm trying to solve a variant of the transportation problem with a constraint which makes me able to specify the amount of supplies a truck should take to from a certain source towards a certain destination.
For example:
Source S1 has a supply of 40.
Source S2 has a supply of 40.
Source S3 has a supply of 20.
Destination D1 has a a demand of 40.
I want to be able to make it so that demand of D1 is fulfilled by TWO suppliers who each deliver 20.
In constraint form I think this would be:
S1D1 = 0 OR 20
S2D1 = 0 OR 20
S3D1 = 0 or 20
S1D1 + S2D1 + S3D1 = 40
But I have no idea how to implement the OR constraint in Google OR-tools. I think I have to look at a mixed integer integer solver, but I can't find any examples or documentation that would solve my problem.
Upvotes: 1
Views: 1090
Reputation: 647
Erwin you are right.
I used a mixed integer solver and used the following constraints.
Constraints:
A variable is an integer and between 0 and 1 (so it's 1 or 0).
20 S1D1 + 20 S2D1 + 20 S3D1 = 40
this was a simplified example, in my problem I actually have more destinations. To make sure a source doesn't provide more than it has the following constraint was used (use 2 destinations as example, Destination 2 has a demand of 40 provided by once source):
20 S1D1 + 40 S1D2 <= 40 (repeat this for all sources)
Thanks for your help.
Upvotes: 2