Skip to content

Commit

Permalink
Fix or_component.py tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
mariags803 committed May 21, 2024
1 parent 295d692 commit 184fd46
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions claasp/components/or_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,18 @@ def cp_xor_linear_mask_propagation_constraints(self, model):
sage: gift = GiftPermutation()
sage: or_component = gift.component_from(39, 6)
sage: cp = CpModel(gift)
sage: or_component.cp_xor_linear_mask_propagation_constraints(cp)
(['array[0..31] of var int: p_or_39_6;',
'array[0..63] of var 0..1:or_39_6_i;',
'array[0..31] of var 0..1:or_39_6_o;'],
['constraint table(or_39_6_i[0]++or_39_6_i[32]++or_39_6_o[0]++p_or_39_6[0],and2inputs_LAT);',
...
'constraint table(or_39_6_i[31]++or_39_6_i[63]++or_39_6_o[31]++p_or_39_6[31],and2inputs_LAT);',
'constraint p[0] = sum(p_or_39_6);'])
sage: declarations, constraints = or_component.cp_xor_linear_mask_propagation_constraints(cp)
sage: declarations
['array[0..31] of var 0..3200: p_or_39_6;',
'array[0..63] of var 0..1:or_39_6_i;',
'array[0..31] of var 0..1:or_39_6_o;']
sage: constraints
['constraint table([or_39_6_i[0]]++[or_39_6_i[32]]++[or_39_6_o[0]]++[p_or_39_6[0]],and2inputs_LAT);',
'constraint table([or_39_6_i[1]]++[or_39_6_i[33]]++[or_39_6_o[1]]++[p_or_39_6[1]],and2inputs_LAT);',
...
'constraint table([or_39_6_i[31]]++[or_39_6_i[63]]++[or_39_6_o[31]]++[p_or_39_6[31]],and2inputs_LAT);',
'constraint p[0] = sum(p_or_39_6);']
"""
input_size = int(self.input_bit_size)
output_size = int(self.output_bit_size)
Expand Down

0 comments on commit 184fd46

Please sign in to comment.