Skip to content

Commit

Permalink
Re-enable support for string values in domains.
Browse files Browse the repository at this point in the history
  • Loading branch information
9thbit committed Sep 17, 2013
1 parent ef3fd1d commit 9741fd2
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/Numberjack.py
Expand Up @@ -71,6 +71,11 @@ def flatten(x):
return result


def numeric(x):
tx = type(x)
return tx is int or tx is float


class Domain(list):
def __init__(self, arg1, arg2=None):
"""
Expand Down Expand Up @@ -231,7 +236,9 @@ def __str__(self):
return self.domain()

def is_str(self):
return hasattr(self, 'model')
if hasattr(self, 'lb'):
return not numeric(self.lb)
return False

def getVar(self, solver_id):
return self.var_list[solver_id - 1]
Expand Down Expand Up @@ -286,6 +293,9 @@ def get_domain(self, solver=None):
else:
return Domain(self.lb, self.ub)

def get_name(self):
return self.operator

## Current value of the expression
# @param solver solver reference for solver from which current value will be sourced
# @return current value of expression
Expand Down Expand Up @@ -588,7 +598,7 @@ def close(self):
if self.closed == len(self.__expressions):
tmp_strings = []
for var in self.variables:
if var.get_lb() is None:
if var.is_str():
var.model = self
for value in var.domain_:
tmp_strings.append(value)
Expand Down Expand Up @@ -672,10 +682,6 @@ def __init__(self, argopt1=None, argopt2=None, argopt3=None):
Variable(list, 'x') :- Variable with domain specified as a list called 'x'
'''

def numeric(x):
tx = type(x)
return tx is int or tx is float

domain = None
lb = 0
ub = 1
Expand Down

0 comments on commit 9741fd2

Please sign in to comment.