Giter VIP home page Giter VIP logo

Comments (7)

ehebrard avatar ehebrard commented on August 10, 2024

Hi Peter,

You want to write it this way:

from Numberjack import *

N = 1000
variables = {}
for x in range(2):
variable = Variable(N)
variables[x] = variable

vararray = VarArray([variables[i] for i in range(2)])

model = Model( Minimise( Max(vararray) ))

model.add(variables[0] + 2 <= variables[1])
model.add((variables[0] < 5) | (variables[0] > 9))

solver = model.load('Mistral2')
solver.setVerbosity(0)
solved = solver.solve()

print solved
for name in sorted(variables.keys()):
variable = variables[name]
print "{}: {}".format(name, variable.get_value())

Notice that you need to use "Max" (the constraint) and not "max" (the
python operator). Also, the argument must be either a VarArray object or
two Variable objects.

Regards,

On Thu, Aug 27, 2015 at 2:27 PM, Peter Hedinger [email protected]
wrote:

Running the following on my MacBook results in a segfault:

from Numberjack import *

N = 1000
variables = {}
for x in range(2):
variable = Variable(N)
variables[x] = variable

model = Model( Minimise( max(variables.values()) ))

model.add(variables[0] + 2 <= variables[1])
model.add((variables[0] < 5) | (variables[0] > 9))

solver = model.load('Mistral2')
solver.setVerbosity(0)
solved = solver.solve()

print solved
for name in sorted(variables.keys()):
variable = variables[name]
print "{}: {}".format(name, variable.get_value())


Reply to this email directly or view it on GitHub
#23.

-Emmanuel

from numberjack.

pthedinger avatar pthedinger commented on August 10, 2024

Thanks for your quick response. However, that still crashes with:

Process: Python [79158]
Path: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Identifier: Python
Version: 2.7.6 (2.7.6)
Code Type: X86-64 (Native)
Parent Process: bash [16985]
Responsible: iTerm [14973]
User ID: 501

PlugIn Path: /Library/Python/2.7/site-packages/_Mistral2.so
PlugIn Identifier: _Mistral2.so
PlugIn Version: ??? (0)

Date/Time: 2015-08-27 13:55:28.356 +0100
OS Version: Mac OS X 10.10.3 (14D136)
Report Version: 11
Anonymous UUID: 8520A627-424A-C68D-31C0-02BE42C87F4A

Sleep/Wake UUID: D730404A-1845-497C-AAB9-5E5078C93980

Time Awake Since Boot: 3700000 seconds
Time Since Wake: 21000 seconds

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000008

VM Regions Near 0x8:
-->
__TEXT 00000001039ae000-00000001039af000 [ 4K] r-x/rwx SM=COW /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 Mistral2.so 0x0000000103d4a59d Mistral2_or::add(Mistral2Solver, bool) + 189
1 _Mistral2.so 0x0000000103d3ed0d _wrap_Mistral2Solver_add(object, _object*) + 157
2 org.python.python 0x0000000103a3f180 PyEval_EvalFrameEx + 12778
3 org.python.python 0x0000000103a3bd62 PyEval_EvalCodeEx + 1413
4 org.python.python 0x0000000103a4257d 0x1039b8000 + 566653
5 org.python.python 0x0000000103a3f3e3 PyEval_EvalFrameEx + 13389
6 org.python.python 0x0000000103a3bd62 PyEval_EvalCodeEx + 1413
7 org.python.python 0x00000001039e030a 0x1039b8000 + 164618
8 org.python.python 0x00000001039c22ac PyObject_Call + 99
9 org.python.python 0x00000001039cd0cf 0x1039b8000 + 86223
10 org.python.python 0x00000001039c22ac PyObject_Call + 99
11 org.python.python 0x0000000103a3ec00 PyEval_EvalFrameEx + 11370
12 org.python.python 0x0000000103a3bd62 PyEval_EvalCodeEx + 1413
13 org.python.python 0x00000001039e030a 0x1039b8000 + 164618
14 org.python.python 0x00000001039c22ac PyObject_Call + 99
15 org.python.python 0x00000001039cd0cf 0x1039b8000 + 86223
16 org.python.python 0x00000001039c22ac PyObject_Call + 99
17 org.python.python 0x0000000103a093f4 0x1039b8000 + 332788
18 org.python.python 0x0000000103a04cfb 0x1039b8000 + 314619
19 org.python.python 0x00000001039c22ac PyObject_Call + 99
20 org.python.python 0x0000000103a3ec00 PyEval_EvalFrameEx + 11370
21 org.python.python 0x0000000103a3bd62 PyEval_EvalCodeEx + 1413
22 org.python.python 0x0000000103a4257d 0x1039b8000 + 566653
23 org.python.python 0x0000000103a3f3e3 PyEval_EvalFrameEx + 13389
24 org.python.python 0x0000000103a3bd62 PyEval_EvalCodeEx + 1413
25 org.python.python 0x0000000103a3b7d7 PyEval_EvalCode + 54
26 org.python.python 0x0000000103a5b7bd 0x1039b8000 + 669629
27 org.python.python 0x0000000103a5b860 PyRun_FileExFlags + 133
28 org.python.python 0x0000000103a5b3fd PyRun_SimpleFileExFlags + 769
29 org.python.python 0x0000000103a6cb23 Py_Main + 3051
30 libdyld.dylib 0x00007fff8cdd05c9 start + 1

Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x00007fb4e9f1a6f0 rcx: 0x00007fb4e9f002a0 rdx: 0x0000000000000001
rdi: 0x00007fff5c24f368 rsi: 0x0000000000000000 rbp: 0x00007fff5c24f4c0 rsp: 0x00007fff5c24f450
r8: 0x0000000000000002 r9: 0x00000000ffffffff r10: 0x0000000000000006 r11: 0x00007fb4e9f00000
r12: 0x00007fb4e9f00570 r13: 0x00007fff5c24f478 r14: 0x0000000000000001 r15: 0x00007fb4e9f1a700
rip: 0x0000000103d4a59d rfl: 0x0000000000010202 cr2: 0x0000000000000008

Logical CPU: 2
Error Code: 0x00000004
Trap Number: 14

from numberjack.

9thbit avatar 9thbit commented on August 10, 2024

Both of these models are working fine for me with Mistral and Mistral2 using the current master branch. Do you know what version you have installed @pthedinger?

By the way, you can really simplify your variable declaration further using a VarArray like so:
variables = VarArray(2, N)

from numberjack.

pthedinger avatar pthedinger commented on August 10, 2024

I am using Numberjack (1.1.1) which is the latest version according to my pip.

from numberjack.

9thbit avatar 9thbit commented on August 10, 2024

@pthedinger, would you mind testing it with latest master branch from github? you can download a zip on the right hand side of the page.
You can compile just the Mistral2 solver like so:

python setup.py build -solver Mistral2
python setup.py install -solver Mistral2

from numberjack.

pthedinger avatar pthedinger commented on August 10, 2024

Yes, that is working now. Thank you.

from numberjack.

9thbit avatar 9thbit commented on August 10, 2024

Great. You should compile the remainder of the solvers by removing those last two command line arguments. We have some other fixes also which will be released in a new version on PyPi soon.

from numberjack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.