Skip to content

Demo wrapping linear solver in rust web service 🧮

License

Notifications You must be signed in to change notification settings

bkspace/web-lp-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WEB_LP_RS

This is a small demo, showing one possible way of using an existing linear programming solver in a rust web service. Thanks to the lp-modeler package, we could also easily swap the solver for another, but for now let's stick with GLPK.

Running

To run this example you need to have GLPK installed. You can validate this by:

glpsol --version

If not, you can install with brew: brew install glpk

Then run cargo build and execute the binary.

Or simply use the included Dockerfile:

docker build -t web-lp-rs . docker run -p 8080:8080 web-lp-rs

HTTP GET http://localhost:8080/api/optimise will return a set of results if the problem is solveable:

{
    results: {
        B_E: 1,
        B_F: 0,
        A_E: 0,
        C_E: 0,
        A_D: 0,
        B_D: 0,
        C_F: 0,
        C_D: 1,
        A_F: 1
    }
}

Performance

Seems ok with low concurrent connections, but there is a bottle neck somewhere (I believe lp-modeler -> GLPK via writing temporary files) that needs to be addressed.

You can use a software like wrk to test the performance, e.g:

wrk http://localhost:8080/api/optimise --latency -t 1 -c 10 -d 2s

About

Demo wrapping linear solver in rust web service 🧮

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages