File size: 1,301 Bytes
d942935
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python3
"""
example_usage.py

Minimal examples showing both interfaces: natural language and JSON.
Run: python3 example_usage.py
"""

from solver_assistant_v3 import dispatch, dispatch_from_json


def main():
    print("=" * 70)
    print("Natural language interface")
    print("=" * 70)

    nl_examples = [
        "max cut on A-B:3, B-C:5, C-A:2",
        "sat (x1 or -x2 or x3) and (x2 or x3)",
        "subset sum [3, 7, 1, 8, 2, 11] target 15",
        "tsp (0,0) (10,0) (10,10) (0,10) (5,5)",
    ]
    for text in nl_examples:
        print()
        print(f"> {text}")
        dispatch(text, verbose=True)

    print()
    print("=" * 70)
    print("JSON schema interface")
    print("=" * 70)

    json_examples = [
        {"type": "maxcut", "edges": [["A", "B", 3], ["B", "C", 5],
                                     ["C", "A", 2]]},
        {"type": "sat", "n_vars": 3, "clauses": [[1, -2, 3], [2, 3]]},
        {"type": "subset_sum", "numbers": [3, 7, 1, 8, 2, 11], "target": 15},
        {"type": "tsp", "points": [[0, 0], [10, 0], [10, 10], [0, 10],
                                    [5, 5]]},
    ]
    for schema in json_examples:
        print()
        print(f"> {schema}")
        dispatch_from_json(schema, verbose=True)


if __name__ == "__main__":
    main()