Git Product home page Git Product logo

demo-symuvia's Introduction

Demo on SymuVia API

This demo is an example on how to access the SymuVia API from the basics. The structure contains two folders: darwin for MacOS and windows for windows platforms.

The demo file simulation_test.py is a file containing necessary instructions to launch the script in a MacOS platform. In order to modify to windows just change the value darwin by windows and the value libSymuVia.dylib by SymuVia.dll

Note: Use absolute paths when importing the shared library.

Loading SymuVia in Python

In python execute.

In MacOS

from ctypes import cdll 
simulator = cdll.LoadLibrary('your_mac_dir/demo-symuvia/darwin/libSymuVia.dylib')  # load simulator

Replace your_mac_dir for the absolute path to the directory where demo-symuvia is placed

In Windows

from ctypes import cdll 
simulator = cdll.LoadLibrary('your_windows_dir\windows\SymuVia.dll')  # load simulator

Replace your_windows_dir for the absolute path to the directory where demo-symuvia is placed

Running a simulation in a single step

To launch the simulation, load the XML file into the simulator via SymLoadNetworkEx, then play the simulation via SymRunEx:

import os 
xml_file = os.path.join(os.getcwd(),'bottleneck_001.xml') # Absolute path of xml file 
print(xml_file)
simulator.SymLoadNetworkEx(xml_file.encode('UTF8')) # load simulation into simulator 
simulator.SymRunEx(xml_file.encode('UTF8')) # run this file 

Running a simulation step by step

Please find more details on this within the Jupyter Notebook Basics_API.ipynb

Note about launcher.py and spydsla.py

These files are dedicated to reconfigure the dependencies for shared libraries inside darwin. They are useful to import the library within python in MacOS, not in windows.

Only in MacOSX

If you get an error when doing cdll.LoadLibrary('darwin/libSymuVia.dylib'), try:

  1. Create a folder called log
  2. Install developer tools as xcode-select --install
  3. In a terminal launch python3 launcher.py.
  4. Start a python console and restart the procedure.

demo-symuvia's People

Contributors

aladinoster avatar haozhougt avatar

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.