Comments (7)
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] = variablemodel = 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.
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.
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.
I am using Numberjack (1.1.1) which is the latest version according to my pip.
from numberjack.
@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.
Yes, that is working now. Thank you.
from numberjack.
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)
- Segfault using Table constraint HOT 6
- Support Gurobi Compute Server running in the cloud HOT 1
- Issues with .Mul operator for constraints. HOT 15
- New puzzle examples ready. HOT 1
- Get only the first solution HOT 4
- Confused why solutions do not satisfy constraints... HOT 1
- setup.py is always searching for CPLEX
- Setup fails to find xml2-config on Windows HOT 1
- If statement with constraint HOT 2
- Installation issue HOT 1
- discussion group HOT 1
- AttributeError: 'Element' object has no attribute 'domain_ while trying to add Predicate Sum HOT 1
- Deprecated built-in function __getslice__ in python 3.7 to get a slice from a list
- The docs link is dead :(
- Can't use gurobi on Debian 9 (undefined symbol)
- KeyError: 'f'
- ImportError: No module named '_Mistral' HOT 2
- AttributeError: 'float' object has no attribute 'lb'_
- Solvers not available
- arm64 support? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from numberjack.