DEV Community

Cover image for cpm-rs, a rust crate for Critical Path Method
Gergely B. B.
Gergely B. B.

Posted on

4 1

cpm-rs, a rust crate for Critical Path Method

Introduction

The Critical Path Method is a widely used methodology to identify the rigid points of a graph of tasks, where the connections between the tasks are the dependencies. Some things cannot be started without finishing others. There are a lot of real-life examples for this case.

The network of these tasks can be analyzed with different algorithms to get more detailed information about the 'batch', like selecting tasks for high priority. These tasks form a path in the graph alongside their connections. This path is called a 'critical path'. If any of the tasks on this path is being delayed it delays the whole batch, meaning the finishing time for the whole set of tasks will be late.

cpm-rs

I do not want to bring up the details of the CPM here. There are a lot of very detailed articles and books about the methodology. This article aims to introduce the cpm-rs Rust crate.
The goal is to have a well tested, reliable library that covers the CPM and still is optimized and scalable.

Aim

This library should be able to be used in project-management tools and in automated task scheduling for large amount of progressive tasks.

What do we have

At the moment, the latest published version is v0.1.6 and it is far away from being production-ready. The following features are working:

  • File parser for predefined tasks. May be removed later, it is a bit over-engineered and still not so well implemented.
  • Critical path calculation.
  • Calculation of number of maximum parallel tasks at a time. It means that the Scheduler can calculate the maximal number of parallel tasks in the batch.
  • Indexed integer or floating point time units.

Example


fn main() {
    let mut scheduler = Scheduler<i32>::new();
    scheduler.add_task(CustomTask::new(
        "Task_A".to_string()
        , 1
        , vec!{}
    ));
    scheduler.add_task(CustomTask::new(
        "Sidetask_B".to_string()
        , 3
        , vec!{"Task_A".to_string()}
    ));
    scheduler.add_task(CustomTask::new(
        "Sidetask_C".to_string()
        , 2
        , vec!{"Task_B".to_string()}
    ));
    scheduler.add_task(CustomTask::new(
        "Finish".to_string()
        , 1
        , vec!{"Sidetask_B".to_string(), "Sidetask_C".to_string()}
    ));
    match scheduler.schedule() {
        Ok(()) => {},
        Err(e) => {eprintln!("Error: {}", e); exit(1);},
    }

}

Enter fullscreen mode Exit fullscreen mode

What we need

The following features are very crucial to have, but not yet implemented:

  • Dependency circle check.
  • Shiftable tasks.
  • Graph visualization.
  • Crate features.
  • Proper unit tests.
  • Stress tests.
  • Resource-wise estimation.
  • Priority-wise estimation.
  • Task grouping.
  • Resource type groups.
  • Group priority.
  • Resource state management.
  • Actual time type unit types.
  • OPTIMIZATION.
  • CI/CD pipeline.

Call for contribution

CPM-rs cover

If you feel the ambition to participate in this project, you are warmly welcome to contribute!
If you have any questions, please open a pull request on the repository.

Crates.io
GIT repository
crates.io page

References

The ABCs of the Critical Path Method by F. K. Levy, G. L. Thompson, and J. D. Wiest

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

Heroku

This site is powered by Heroku

Heroku was created by developers, for developers. Get started today and find out why Heroku has been the platform of choice for brands like DEV for over a decade.

Sign Up

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay