Skip to content

Commit

Permalink
matlab engine for python no bueno
Browse files Browse the repository at this point in the history
  • Loading branch information
mldiego committed Jul 11, 2024
1 parent f25350e commit 2574491
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
22 changes: 11 additions & 11 deletions code/nnv/examples/Submission/VNN_COMP2024/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@ def run_instance(category, onnx, vnnlib, timeout, outputlocation) -> None:
timeout (int): the time (in ms) to wait before proceeding to the next instance
"""

print("Looking for connections")
eng_name = matlab.engine.find_matlab()
print(eng_name)
try:
eng = matlab.engine.connect_matlab(eng_name[0])
print(eng)
except:
print("Connect to anything")
eng = matlab.engine.connect_matlab()
print(eng)
# print("Looking for connections")
# eng_name = matlab.engine.find_matlab()
# print(eng_name)
# try:
# eng = matlab.engine.connect_matlab(eng_name[0])
# print(eng)
# except:
# print("Connect to anything")
# eng = matlab.engine.connect_matlab()
# print(eng)

# print(eng)

# eng = matlab.engine.start_matlab()
eng = matlab.engine.start_matlab()

eng.addpath(os.getcwd())
eng.addpath(eng.genpath('/home/ubuntu/toolkit/code/nnv/'))
Expand Down
8 changes: 4 additions & 4 deletions code/nnv/examples/Submission/VNN_COMP2024/prepare_instance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ killall -q python3
# killall -q python
pkill -f matlab

WAIT_FOR_CONNECTION_TO_OPEN='import matlab.engine\nimport time\nwhile not matlab.engine.find_matlab(): time.sleep(1)'
#WAIT_FOR_CONNECTION_TO_OPEN='import matlab.engine\nimport time\nwhile not matlab.engine.find_matlab(): time.sleep(1)'

matlab -batch "p = parpool; p.IdleTimeout = 12000; matlab.engine.shareEngine;" &
#matlab -batch "p = parpool; p.IdleTimeout = 12000; matlab.engine.shareEngine;" &

python3 -c "exec('$WAIT_FOR_CONNECTION_TO_OPEN')"
#python3 -c "exec('$WAIT_FOR_CONNECTION_TO_OPEN')"

sleep 20 # it takes about this long to start the parpool
#sleep 20 # it takes about this long to start the parpool

exit 0

0 comments on commit 2574491

Please sign in to comment.