eomahony / Numberjack

Python Combinatorial Optimisation Platform
http://numberjack.ucc.ie
GNU Lesser General Public License v2.1
157 stars 36 forks source link

Fixes to support Python2 and Python3 simultaneously #33

Closed rdeits closed 8 years ago

rdeits commented 8 years ago

This pull request makes the following changes:

I've verified that all unit tests pass on this branch in both python2.7 and python3.5, with the exception of one test (which also fails on master in python2.7):

Error the solver does not support this expression: (x in {0..10} + x in {0..10} + 0.5)
Type: <class 'Numberjack.Sum'>
Children: [<Numberjack.Variable object at 0x10e2e4f10>, <Numberjack.Variable object at 0x10e2e4590>] [<class 'Numberjack.Variable'>, <class 'Numberjack.Variable'>]
Params: [[1, 1], 0.5]
E..........................................................................................................
======================================================================
ERROR: testSuccess11 (tests.LinearTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/rdeits/Projects/Numberjack/tests/LinearTest.py", line 159, in testSuccess11
    solver = LinearTest.solver(te.model)
  File "Numberjack/solvers/Mistral.py", line 977, in __init__
    Numberjack.NBJ_STD_Solver.__init__(self, "Mistral", "Mistral", model, X, FD, clause_limit, encoding)
  File "Numberjack/__init__.py", line 3138, in __init__
    self.solver.add(self.load_expr(expr))
  File "Numberjack/__init__.py", line 3249, in load_expr
    arguments = [self.load_expr(child) for child in expr.get_children()]
  File "Numberjack/__init__.py", line 3284, in load_expr
    raise e
NotImplementedError: Wrong number or type of arguments for overloaded function 'new_Mistral_Sum'.
  Possible C/C++ prototypes are:
    Mistral_Sum::Mistral_Sum(MistralExpArray &,MistralIntArray &,int const)
    Mistral_Sum::Mistral_Sum(MistralExpArray &,MistralIntArray &)
    Mistral_Sum::Mistral_Sum(Mistral_Expression *,Mistral_Expression *,MistralIntArray &,int const)
    Mistral_Sum::Mistral_Sum(Mistral_Expression *,MistralIntArray &,int const)
    Mistral_Sum::Mistral_Sum()

I've also verified that all of the examples in the examples/ folder run without error in python2 and python3, although I haven't actually verified their outputs against the problem descriptions.

I hope you find this useful :smile:

9thbit commented 8 years ago

This is excellent, thank you @rdeits! :+1: Apologies for the delay, had a busy few weeks. :)

rdeits commented 8 years ago

Happy to help :)