Skip to content
This repository has been archived by the owner on Jul 18, 2022. It is now read-only.

Profile plot #51

Merged
merged 6 commits into from
Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

CLI for running Hierarchical Engine for Large-scale Infrastructure Co-Simulations (HELICS).

![](https://user-images.githubusercontent.com/1813121/118163708-8bd4f380-b3df-11eb-8e18-99e9de81836f.png)

- Supports configurations of federates using plugins
- Allows running of federation using a runner configuration

Expand Down Expand Up @@ -48,9 +46,16 @@ Usage: helics run [OPTIONS]
Run HELICS federation

Options:
--path PATH
--path PATH Path to config.json that describes how to
run a federation [required]
--silent
--help Show this message and exit.
--no-log-files
--no-kill-on-error Do not kill all federates on error
-l, --broker-loglevel, --loglevel TEXT
Log level for HELICS broker
--profile Profile flag
-w, --web Run the web interface on startup
--help Show this message and exit.
```

```bash
Expand All @@ -65,6 +70,17 @@ Options:
--help Show this message and exit.
```

```bash
$ helics profile-plot --help

Usage: helics profile-plot [OPTIONS]

Options:
--path PATH Path to profile.txt that describes profiling results of a
federation [required]
--help Show this message and exit.
```

### Usage

```bash
Expand All @@ -86,6 +102,11 @@ Hello from Federate 2

```

```bash
helics run --path examples/pi-exchange/runner.json --profile
helics profile-plot examples/pi-exchange/profile.txt
```

### Installation

```
Expand Down
5 changes: 3 additions & 2 deletions examples/pi-exchange/pireceiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
h.helicsFederateInfoSetTimeProperty(fedinfo, h.helics_property_time_delta, 0.01)

vfed = h.helicsCreateValueFederate(federate_name, fedinfo)

print(f"{federate_name}: Value federate created")

sub = h.helicsFederateRegisterSubscription(vfed, f"globaltopic{sys.argv[1]}", "")
Expand All @@ -28,9 +29,9 @@

currenttime = -1

while currenttime <= 100:
while currenttime <= 10:

currenttime = h.helicsFederateRequestTime(vfed, 100)
currenttime = h.helicsFederateRequestTime(vfed, 10)

value = h.helicsInputGetString(sub)
print(f"{federate_name}: Received value = {value} at time {currenttime}")
Expand Down
14 changes: 6 additions & 8 deletions examples/pi-exchange/pisender.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from math import pi
import helics as h
import random

federate_name = f"SenderFederate{sys.argv[1]}"

Expand All @@ -17,14 +18,10 @@
h.helicsFederateInfoSetTimeProperty(fedinfo, h.helics_property_time_delta, 0.01)

vfed = h.helicsCreateValueFederate(federate_name, fedinfo)

print(f"{federate_name}: Value federate created")

pub = h.helicsFederateRegisterGlobalTypePublication(
vfed, f"globaltopic{sys.argv[1]}", "double", ""
)
pub = h.helicsFederateRegisterTypePublication(
vfed, f"localtopic{sys.argv[1]}", "double", ""
)
pub = h.helicsFederateRegisterGlobalTypePublication(vfed, f"globaltopic{sys.argv[1]}", "double", "")

print(f"{federate_name}: Publication registered")

Expand All @@ -34,15 +31,16 @@
this_time = 0.0
value = pi

for t in range(5, 10):
for t in range(0, 10):
val = value

currenttime = h.helicsFederateRequestTime(vfed, t)

h.helicsPublicationPublishDouble(pub, val)
print(f"{federate_name}: Sending value pi = {val} at time {currenttime}")

time.sleep(1)
# Computing user needs
time.sleep(float(sys.argv[1]) * (1 + (0.5 - random.random()) / 10))

h.helicsFederateFinalize(vfed)
print(f"{federate_name}: Federate finalized")
Expand Down
84 changes: 84 additions & 0 deletions examples/pi-exchange/runner.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,48 @@
"host": "localhost",
"name": "pisender3"
},
{
"directory": ".",
"exec": "python -u pisender.py 4",
"host": "localhost",
"name": "pisender4"
},
{
"directory": ".",
"exec": "python -u pisender.py 5",
"host": "localhost",
"name": "pisender5"
},
{
"directory": ".",
"exec": "python -u pisender.py 6",
"host": "localhost",
"name": "pisender6"
},
{
"directory": ".",
"exec": "python -u pisender.py 7",
"host": "localhost",
"name": "pisender7"
},
{
"directory": ".",
"exec": "python -u pisender.py 8",
"host": "localhost",
"name": "pisender8"
},
{
"directory": ".",
"exec": "python -u pisender.py 9",
"host": "localhost",
"name": "pisender9"
},
{
"directory": ".",
"exec": "python -u pisender.py 10",
"host": "localhost",
"name": "pisender10"
},
{
"directory": ".",
"exec": "python -u pireceiver.py 1",
Expand All @@ -36,6 +78,48 @@
"exec": "python -u pireceiver.py 3",
"host": "localhost",
"name": "pireceiver3"
},
{
"directory": ".",
"exec": "python -u pireceiver.py 4",
"host": "localhost",
"name": "pireceiver4"
},
{
"directory": ".",
"exec": "python -u pireceiver.py 5",
"host": "localhost",
"name": "pireceiver5"
},
{
"directory": ".",
"exec": "python -u pireceiver.py 6",
"host": "localhost",
"name": "pireceiver6"
},
{
"directory": ".",
"exec": "python -u pireceiver.py 7",
"host": "localhost",
"name": "pireceiver7"
},
{
"directory": ".",
"exec": "python -u pireceiver.py 8",
"host": "localhost",
"name": "pireceiver8"
},
{
"directory": ".",
"exec": "python -u pireceiver.py 9",
"host": "localhost",
"name": "pireceiver9"
},
{
"directory": ".",
"exec": "python -u pireceiver.py 10",
"host": "localhost",
"name": "pireceiver10"
}
],
"name": "pi-exchange"
Expand Down
Loading