pawel
pawel

Reputation: 1079

CPM constraints for continuous grids

I'm learning CPM using CPMpy mostly and I'm bashing my head trying to figure out constraints for one of my test problems.

Lets say I have a simple 2d grid 5x5. Each cell can be either a road (1) or not a road (0). I want to make sure that all the roads are connected together. Since I'm adding new roads to the grid while I'm solving it I'm not sure if I can use circuit constraint for that. I do not want to end up with something like this for instance where I have two separate roads with no connection between them:

0 1 0 1 0
0 1 0 1 1
1 1 0 0 1
0 0 0 0 1
1 1 1 1 1

another way to describe this would be to say I do not want to have separate islands but a continuous piece of land. Maybe CPM is not the right system to use for that? I have more constraints and other rules and this is the first case that defeated me. I'm also very new to CPM in general.

Upvotes: 0

Views: 40

Answers (0)

Related Questions