From 2ff651f1b6effe2354f76a5073197baeb0932495 Mon Sep 17 00:00:00 2001 From: paulhuynh Date: Tue, 19 Mar 2024 11:03:33 +0400 Subject: [PATCH] Merge branch 'develop' into fix/change_default_trail_search_behavior # Conflicts: # tests/unit/cipher_modules/models/cp/cp_models/cp_xor_linear_model_test.py # tests/unit/cipher_modules/models/smt/smt_models/smt_xor_differential_model_test.py # tests/unit/cipher_modules/models/smt/smt_models/smt_xor_linear_model_test.py --- claasp/cipher_modules/models/milp/utils/utils.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/claasp/cipher_modules/models/milp/utils/utils.py b/claasp/cipher_modules/models/milp/utils/utils.py index 5f435f51..3101c25e 100644 --- a/claasp/cipher_modules/models/milp/utils/utils.py +++ b/claasp/cipher_modules/models/milp/utils/utils.py @@ -710,4 +710,13 @@ def _string_to_hex( string): value = "0b" + value.bin except Exception: value = string - return value \ No newline at end of file + return value + +def _filter_fixed_variables(fixed_values, fixed_variable, id): + fixed_values_to_keep = [variable for variable in fixed_values if variable["constraint_type"] == "equal"] + if id in [value["component_id"] for value in fixed_values_to_keep]: + input_index = [value["component_id"] for value in fixed_values_to_keep].index(id) + for bit in fixed_values_to_keep[input_index]["bit_positions"]: + bit_index = fixed_variable["bit_positions"].index(bit) + del fixed_variable["bit_values"][bit_index] + del fixed_variable["bit_positions"][bit_index] \ No newline at end of file