# Path: clara/common.py
# def debug(msg, *args):
#     if args:
#         msg %= tuple(args)
#     print('[debug] %s' % (msg,), file=DEBUG_DEST)
# 
# Path: clara/model.py
# SPECIAL_VARS = set([VAR_COND, VAR_RET, VAR_IN, VAR_OUT])
# 
# Path: clara/repair.py
# class Timeout(Exception):
#     pass


import time
from .common import debug
from .model import SPECIAL_VARS
from .pylpsolve import LpModel, EQ, LE, GE, TIMEOUT, SUBOPTIMAL, NUMFAILURE
from .repair import Timeout
        return self.M1[var1] * self.N2 + self.M2[var2]

    def inttovars(self, n):
        return (self.R1[n // self.N2], self.R2[n % self.N2])

    def encode_onetoone(self):

        for var1 in self.V1:
            if var1 == '-':
                continue
            cv = {}
            for var2 in self.V2:
                v = self.varstoint(var1, var2)
                # Special vars are mapped to themselves
                if (var1 in SPECIAL_VARS) or (var2 in SPECIAL_VARS):
                    x = 1 if var1 == var2 else 0
                    self.C.append(({v: 1}, EQ, x))
                    continue
                cv[v] = 1
            # Eeach var1 is mapped to exactly one var2
            if cv:
                self.C.append((cv, EQ, 1))

        for var2 in self.V2:
            if var2 == '*':
                continue
            if var2 in SPECIAL_VARS:
                continue
            cv = {}
            for var1 in self.V1:

# Path: clara/common.py
# def debug(msg, *args):
#     if args:
#         msg %= tuple(args)
#     print('[debug] %s' % (msg,), file=DEBUG_DEST)
# 
# Path: clara/model.py
# SPECIAL_VARS = set([VAR_COND, VAR_RET, VAR_IN, VAR_OUT])
# 
# Path: clara/repair.py
# class Timeout(Exception):
#     pass


# Path: clara/ilp.py
import time
from .common import debug
from .model import SPECIAL_VARS
from .pylpsolve import LpModel, EQ, LE, GE, TIMEOUT, SUBOPTIMAL, NUMFAILURE
from .repair import Timeout

        return self.M1[var1] * self.N2 + self.M2[var2]

    def inttovars(self, n):
        return (self.R1[n // self.N2], self.R2[n % self.N2])

    def encode_onetoone(self):

        for var1 in self.V1:
            if var1 == '-':
                continue
            cv = {}
            for var2 in self.V2:
                v = self.varstoint(var1, var2)
                # Special vars are mapped to themselves
                if (var1 in SPECIAL_VARS) or (var2 in SPECIAL_VARS):
                    x = 1 if var1 == var2 else 0
                    self.C.append(({v: 1}, EQ, x))
                    continue
                cv[v] = 1
            # Eeach var1 is mapped to exactly one var2
            if cv:
                self.C.append((cv, EQ, 1))

        for var2 in self.V2:
            if var2 == '*':
                continue
            if var2 in SPECIAL_VARS:
                continue
            cv = {}
            for var1 in self.V1:

                if var1 in SPECIAL_VARS: