From 04cd3e44d30b0fbac2008cbc3a7cbb2989fe2def Mon Sep 17 00:00:00 2001 From: Vojta Mrazek Date: Mon, 22 Jul 2024 15:09:50 +0200 Subject: [PATCH] bug in cgp indexes with constant wires, they were encouted --- ariths_gen/core/arithmetic_circuits/general_circuit.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ariths_gen/core/arithmetic_circuits/general_circuit.py b/ariths_gen/core/arithmetic_circuits/general_circuit.py index b8543e5..95d3f31 100644 --- a/ariths_gen/core/arithmetic_circuits/general_circuit.py +++ b/ariths_gen/core/arithmetic_circuits/general_circuit.py @@ -268,7 +268,9 @@ class GeneralCircuit(): if wire.is_const(): return wire.cgp_const else: - return len(self.circuit_wires)+2 + # [1] is reservation for a constant wire with value 1 + pos = max([1] + [x[2] for x in self.circuit_wires]) + return pos + 1 def get_circuit_wires(self): """Gets a list of all wires in circuit along with their index position for cgp chromosome generation and stores them inside `self.circuit_wires` list.