From 76983c9ed39b2d763a3e24aec2290191df7c439d Mon Sep 17 00:00:00 2001
From: MLErik <baerenjesus@gmail.com>
Date: Tue, 1 Oct 2019 13:56:38 -0400
Subject: [PATCH] check for feasibility

---
 examples/flatland_2_0_example.py     | 2 +-
 flatland/envs/schedule_generators.py | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/examples/flatland_2_0_example.py b/examples/flatland_2_0_example.py
index 1d3c5191..c14600b3 100644
--- a/examples/flatland_2_0_example.py
+++ b/examples/flatland_2_0_example.py
@@ -37,7 +37,7 @@ env = RailEnv(width=50,
                                                    max_tracks_in_city=4,
                                                    ),
               schedule_generator=sparse_schedule_generator(),
-              number_of_agents=10,
+              number_of_agents=100,
               stochastic_data=stochastic_data,  # Malfunction data generator
               obs_builder_object=GlobalObsForRailEnv(),
               remove_agents_at_target=True
diff --git a/flatland/envs/schedule_generators.py b/flatland/envs/schedule_generators.py
index 0a4e7e3b..bb29e07e 100644
--- a/flatland/envs/schedule_generators.py
+++ b/flatland/envs/schedule_generators.py
@@ -82,7 +82,8 @@ def sparse_schedule_generator(speed_ratio_map: Mapping[float, float] = None) ->
             agent_orientation = (agent_start_targets_nodes[agent_idx][2] + 2 * start[1]) % 4
             if not rail.check_path_exists(start[0], agent_orientation, target[0]):
                 agent_orientation = (agent_orientation + 2) % 4
-            print(rail.check_path_exists(start[0], agent_orientation, target[0]))
+            if not (rail.check_path_exists(start[0], agent_orientation, target[0])):
+                print("Infeasible")
             agents_position.append((start[0][0], start[0][1]))
             agents_target.append((target[0][0], target[0][1]))
 
-- 
GitLab