# PERTy
A crate for constructing and analysing Program Evaluation and Review Technique (PERT) task graphs. The library provides the ability to run a single PERT analysis or a Monte-Carlo analysis where the solver can perform multiple runs and sampling from the distributions assigned to the tasks..
## Example
This example comes from the wikipedia page so you can check the results with the ones displayed on their page.

More examples can be found in the `examples` folder in the GitHub repo.
```rust
use perty::{Duration, Pert, PostProcess, Task};
fn main() {
// Create the tasks. We are using the Task struct provided by the library
// that implements `TryIntoPertTask` and features the minimum data required
// for the analysis.
// The crate provides the `TryIntoPertTask` trait that enables
// users to keep their task data structures which are likely to
// contain much more metadata relating to the task but not necessary
// for a PERT analysis.
let a = Task::new(
"A".to_string(),
vec![],
Duration::Pert {
optimistic: 2.,
most_likely: 4.,
pessimistic: 6.,
},
);
let b = Task::new(
"B".to_string(),
vec![],
Duration::Pert {
optimistic: 3.,
most_likely: 5.,
pessimistic: 9.,
},
);
let c = Task::new(
"C".to_string(),
vec!["A".to_string()],
Duration::Pert {
optimistic: 4.,
most_likely: 5.,
pessimistic: 7.,
},
);
let d = Task::new(
"D".to_string(),
vec!["A".to_string()],
Duration::Pert {
optimistic: 4.,
most_likely: 5.,
pessimistic: 10.,
},
);
let e = Task::new(
"E".to_string(),
vec!["B".to_string(), "C".to_string()],
Duration::Pert {
optimistic: 4.,
most_likely: 5.,
pessimistic: 7.,
},
);
let f = Task::new(
"F".to_string(),
vec!["D".to_string()],
Duration::Pert {
optimistic: 3.,
most_likely: 4.,
pessimistic: 8.,
},
);
let g = Task::new(
"G".to_string(),
vec!["E".to_string()],
Duration::Pert {
optimistic: 3.,
most_likely: 5.,
pessimistic: 8.,
},
);
// Put the tasks into a vec.
let tasks = vec![a, b, c, d, e, f, g];
for t in tasks.iter() {
println!("{}: {:?}", t.id, t.duration);
}
// The PERT trait provides a solve_pert function for types that
// implement the TryIntoPertTask trait.
let nodes = tasks.solve_pert(1_000).unwrap();
// Access the results. Which could be added back to your tasks.
for n in nodes.iter() {
println!("{}: {:.2} {}", n.id, n.slack(), n.is_critical());
}
println!("Total Duration: {:.2}", nodes.project_duration());
}
```
## CLI
Help is provided by:
```bash
perty pert --help
```
The CLI can accept a file path to a `json` description of your project and output the results to another file path set by the user.
```bash
perty pert <INP> <OUT> [MAX_ITER]
```
# Support
Please consider supporting the crate by:
- Downloading and using the crate.
- Raising issues and improvements on the GitHub repo.
- Recommending the crate to others.
- ⭐ the crate on GitHub.
- Sponsoring the [maintainer](https://github.com/sponsors/jamesgopsill).
# References
- <https://en.wikipedia.org/wiki/Program_evaluation_and_review_technique>