Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

BCVTB: how to install new python modules?

asked 2016-06-27 12:27:59 -0500

I've created a control algorithm in Python that is leveraging some modules such as Numpy or PuLP (for interfacing for MILP solver GLPK).

I was trying to use the Building Control Virtual Test Bed and the underlying Ptolemy, but so far I've found it really hard to use and not user friendly at all, the lack of examples and tutorials out there is really not helping. Anyways, among the many hurdles I'm facing, there's one that will be a deal breaker for me: whether I can actually run my program or not. Note that I could do without NumPy since I know it's problematic at best on Jython but I could not do without PuLP.

It seems that Ptolemy is using some kind of weird Jython. Is there any way to use the system python instead? Or can you install new python modules to Jython?

Alternatively, are there any workarounds I could use?

(at this point I'd even accept a dirty workaround such as exporting values to a csv, call a shell command to execute my system python with my given program, and reimport the value from the CSV?)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-06-27 13:52:00 -0500

updated 2016-06-27 15:33:52 -0500

The python actors rely indeed on Jython and have thus the limitations you encountered. Have you tried using the SystemCommand actor which allows to call any script?

edit flag offensive delete link more


I wasn't aware of this component, thanks! I will try to use it, that if I can figure out how to log my variables into a csv file. There's a CSVWriter module, but after an hour and a half I couldn't make it work. Bad data types, and couldn't even figure how to pass the "filename" argument.

Julien Marrec's avatar Julien Marrec  ( 2016-06-27 15:33:33 -0500 )edit

Hi, were you able to use the SystemCommand Actor for python script ?

niharkopal's avatar niharkopal  ( 2017-06-06 00:52:58 -0500 )edit

Yeah I ended up using it to call my own system python.

Julien Marrec's avatar Julien Marrec  ( 2017-06-06 03:05:46 -0500 )edit

Hi thanks a lot for replying. I have python 2.7 installed through conda on my system. And I plan to use numpy, theano libraries. So can you please guide me as to how you called your own system python through bcvtb ?

niharkopal's avatar niharkopal  ( 2017-06-06 03:55:13 -0500 )edit

Figure 5.36 in the link given by Thierry is pretty clear.

Actually in my specific case I now remember what I've really done: I had to trigger my python script every day of the simulation at midnight only, and I couldn't do that with the systemCommand actor. So I used a PythonActor, and I would test if it was midnight, if so I would use subprocess.Popen to run a python script file with my local Anaconda python.

Julien Marrec's avatar Julien Marrec  ( 2017-06-06 04:07:36 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Training Workshops


Question Tools



Asked: 2016-06-27 12:27:59 -0500

Seen: 913 times

Last updated: Jun 27 '16