Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'Element' object has no attribute 'domain_ while trying to add Predicate Sum #52

Open
gorhan opened this issue Jul 4, 2018 · 1 comment

Comments

@gorhan
Copy link

gorhan commented Jul 4, 2018

Hi,

Recently, I need Python 3.7 to run the code because of some dependencies. Previously, I got no error like this by using Python 2.7. While trying to add a new constraint to the model. I get the following error stating that there is no attribute named "domain_" in the class "Element". I have checked the class with its super classes. It says the truth.

I have already checked the diff of two different versions of the module Numberjack, but there is no difference at the corresponding code segment.

Another problem is that while creating an Element object, it passes a slice object to the end of the children list which causes an error on the line 710 where it checks the following condition:
if exp.ident == -1:
because one of the exp objects comes as slice object resulting from the slice object.

Could you please help me to solve this issue? I could not cope with it by myself.

Thank you in advance!!

135 self.__model += (Sum(self.__Start[job]) == 1) # only 1 number of Start
136 self.__model += (Sum(self.__End[job]) == 1) # only 1 number of End
--> 137 self.__model += (Sum(self.__Start[job][release_time:deadline]) == 1) # only 1 number of Start between release and deadline
138 self.__model += (Sum(self.__End[job][release_time:deadline+1]) == 1) # only 1 number of End between release and deadline
139 self.__model += (Sum(self.__End[job][t+1] * (t+1) for t in range(release_time, deadline)) - Sum(self.__Start[job][t] * t for t in range(release_time, deadline)) > 0)

~/workspace/LFOS/latestPy3.7Env/lib/python3.7/site-packages/Numberjack/init.py in init(self, vars, coefs, offset)
2022
2023 def init(self, vars, coefs=None, offset=0):
-> 2024 Predicate.init(self, vars, "Sum")
2025
2026 if coefs is None:

~/workspace/LFOS/latestPy3.7Env/lib/python3.7/site-packages/Numberjack/init.py in init(self, vars, op)
1447 def init(self, vars, op):
1448 Expression.init(self, op)
-> 1449 self.set_children(vars)
1450
1451 def set_children(self, children):

~/workspace/LFOS/latestPy3.7Env/lib/python3.7/site-packages/Numberjack/init.py in set_children(self, children)
1454 ## List of children of the predicate
1455 #self.children = [child for child in children]
-> 1456 self.children = flatten(children)
1457
1458 def initial(self):

~/workspace/LFOS/latestPy3.7Env/lib/python3.7/site-packages/Numberjack/init.py in flatten(x)
29 def flatten(x):
30 result = []
---> 31 for el in x:
32 if hasattr(el, "iter") and not isinstance(el, str) and not issubclass(type(el), Expression):
33 result.extend(flatten(el))

~/workspace/LFOS/latestPy3.7Env/lib/python3.7/site-packages/Numberjack/init.py in iter(self)
243
244 def iter(self):
--> 245 return self.get_domain()
246
247 def get_solver(self):

~/workspace/LFOS/latestPy3.7Env/lib/python3.7/site-packages/Numberjack/init.py in get_domain(self, solver)
398 dom.append(v)
399 return Domain(dom)
--> 400 elif self.domain_ is not None:
401 return Domain(self.domain_)
402 else:

AttributeError: 'Element' object has no attribute 'domain_

@lgrandi
Copy link

lgrandi commented Jan 21, 2021

Hi Gorhan, did you ever fixed this? I am getting a similar error.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants