From 997b7ee9a36eaaf194dc3e1180d23712158e73b1 Mon Sep 17 00:00:00 2001
From: David Hendriks <davidhendriks93@gmail.com>
Date: Sat, 12 Jun 2021 00:12:31 +0100
Subject: [PATCH] Added option to skip 0 prob systems

---
 binarycpython/utils/grid.py                  | 13 +++++++++++--
 binarycpython/utils/grid_options_defaults.py |  2 ++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/binarycpython/utils/grid.py b/binarycpython/utils/grid.py
index 9350ea5a4..956d232eb 100644
--- a/binarycpython/utils/grid.py
+++ b/binarycpython/utils/grid.py
@@ -1207,9 +1207,18 @@ class Population:
 
             start_runtime_binary_c = time.time()
 
-            # Evolve the system
+            # If we want to actually evolve the systems
             if self.grid_options["_actually_evolve_system"]:
-                self._evolve_system_mp(full_system_dict)
+                run_system = True
+
+                # Check option to ignore 0 probability systems
+                if not self.grid_options["run_zero_probability_system"]:
+                    if full_system_dict['probability'] == 0:
+                        run_system = False
+
+                if run_system:
+                    # Evolve the system
+                    self._evolve_system_mp(full_system_dict)
 
             end_runtime_binary_c = time.time()
 
diff --git a/binarycpython/utils/grid_options_defaults.py b/binarycpython/utils/grid_options_defaults.py
index c7f1a1077..f0f640669 100644
--- a/binarycpython/utils/grid_options_defaults.py
+++ b/binarycpython/utils/grid_options_defaults.py
@@ -41,6 +41,7 @@ grid_options_defaults_dict = {
     "_actually_evolve_system": True,  # Whether to actually evolve the systems of just act as if. for testing. used in _process_run_population_grid
     "max_queue_size": 1000,  # Maximum size of the system call queue. Can't be too big!
     "_set_ms_grid": False, # Whether the M&S grid has been loaded
+    "run_zero_probability_system": True, # Whether to run the zero probability systems
     ##########################
     # Execution log:
     ##########################
@@ -480,6 +481,7 @@ grid_options_descriptions = {
     "_actually_evolve_system": "Whether to actually evolve the systems of just act as if. for testing. used in _process_run_population_grid",
     "max_queue_size": "Maximum size of the queue that is used to feed the processes. Don't make this too big! Default: 1000. Input: int",
     "_set_ms_grid": "Internal flag whether the M&S grid has been loaded",
+    "run_zero_probability_system": "Whether to run the zero probability systems. Default: True. Input: boolean",
 }
 
 ###
-- 
GitLab