Skip to content

Commit

Permalink
Refactor example directory and introduce experiments crate/folder
Browse files Browse the repository at this point in the history
  • Loading branch information
reinterpretcat committed Jan 25, 2022
1 parent 54344dd commit d2013cb
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 6 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/experiments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- run: python ./examples/experiments/collect-metrics.py ${{ github.event.inputs.config_url }}
- run: python ./experiments/etc/collect-metrics.py ${{ github.event.inputs.config_url }}

- name: Upload Results artifact
uses: actions/upload-artifact@v2
with:
name: experiments-results.csv
path: examples/experiments/collect-metrics-results.csv
path: experiments/etc/collect-metrics-results.csv


bench-scientific:
Expand All @@ -47,11 +47,11 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- run: python ./examples/experiments/bench-scientific.py ${{ github.event.inputs.config_url }}
- run: python ./experiments/etc/bench-scientific.py ${{ github.event.inputs.config_url }}

- name: Upload Results artifact
uses: actions/upload-artifact@v2
with:
name: bench-results
path: examples/experiments/results
path: experiments/etc/results

2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
## [Unreleased]


## [v1.14.0]
## [v1.14.0] - 2022-01-23

### Changed

Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ members = [
"vrp-pragmatic",
"vrp-scientific",

"examples/json-pragmatic"
"examples/json-pragmatic",
"experiments/heuristic-research"
]

[profile.release]
Expand Down
1 change: 1 addition & 0 deletions docs/src/internals/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ The project consists of the following parts:
- *data*: a data examples such as problem definition, configuration, etc.
- *json-pragmatic*: an example how to solve problem in `pragmatic` json format from rust code using the project crates
- *jvm-interop*: a gradle project which demonstrates how to use the library from java and kotlin
- **experiments**: a playground for various experiments
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions experiments/heuristic-research/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "heuristic-research"
version = "0.1.0"
edition = "2021"
authors = ["Ilya Builuk <ilya.builuk@gmail.com>"]
license = "Apache-2.0"
keywords = ["heuristics", "optimization"]
categories = ["algorithms", "science"]
readme = "README.md"
homepage = "https://github.com/reinterpretcat/vrp"
repository = "https://github.com/reinterpretcat/vrp"
description = "A playground for heuristic research"
publish = false

[dependencies]
rosomaxa = { path = "../../rosomaxa" }

[dependencies.pyo3]
version = "0.15.1"
features = ["auto-initialize"]
17 changes: 17 additions & 0 deletions experiments/heuristic-research/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use pyo3::prelude::*;
use pyo3::types::IntoPyDict;

fn main() -> PyResult<()> {
// docs: https://pyo3.rs/v0.15.1/python_from_rust.html
Python::with_gil(|py| {
let sys = py.import("sys")?;
let version: String = sys.getattr("version")?.extract()?;

let locals = [("os", py.import("os")?)].into_py_dict(py);
let code = "os.getenv('USER') or os.getenv('USERNAME') or 'Unknown'";
let user: String = py.eval(code, None, Some(&locals))?.extract()?;

println!("Hello {}, I'm Python {}", user, version);
Ok(())
})
}

0 comments on commit d2013cb

Please sign in to comment.