-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
36 lines (30 loc) · 1.41 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import logging
from argparse import ArgumentParser
from representation.hrep import Hrep
from enum import Enum
module_logger = logging.getLogger('main')
class Linearisation(Enum):
COMPACT = 1
EXTENDED = 2
GLOVER_WOOLSEY = 3
cmd_parser = ArgumentParser(description='Export linear representation of the selection problem.')
cmd_parser.add_argument('--lin', type=int, choices=range(1, 4), required=True,
help='Specifies which linearisation should be used: 1-compact, 2-extended, 3-glover_woolsey')
cmd_parser.add_argument('--input', metavar='size', action='store', type=int, nargs='+', required=True,
help='Specifies the respective sizes of the input sets as a sequence of numbers.')
if __name__ == '__main__':
cmd_args = cmd_parser.parse_args()
logging.basicConfig(level=logging.INFO)
logging.info(f'Given input: {cmd_args.input}')
if (length := len(cmd_args.input)) < 2:
logging.error(f'Expected len(input) >= 2. Found len(input) = {length}.')
hrep = Hrep(cmd_args.input)
lin = Linearisation(cmd_args.lin)
if lin == Linearisation.GLOVER_WOOLSEY:
print(hrep.get_glover_woolsey_rep())
elif lin == Linearisation.COMPACT:
print(hrep.get_compact_rep())
elif lin == Linearisation.EXTENDED:
print(hrep.get_extended_linearisation(f_weight=1., z_weight=1.))
else:
logging.error('Unexpected linearisation.')