Coder Social home page Coder Social logo

Comments (3)

Crypto-Spartan avatar Crypto-Spartan commented on June 2, 2024 2

I'm not sure exactly how the MIP solver library was implemented, I just imported and used it within my python code. I would assume it was written in C or C++, but I never actually looked into it.

However, the rust code runs substantially faster than the python code ran. The fastest iteration of the python code was around 4-5 seconds, the rust code runs in about 0.3-0.5 seconds.

Thanks for the library, and thanks for your help!

from good_lp.

lovasoa avatar lovasoa commented on June 2, 2024

Hello and thanks for getting in touch !

The first syntax you mentioned should work already

model = model.with(constraint!(team2_bools.iter().sum() == 5))

You may just need to help rust a little by adding a type annotation

model = model.with(constraint!(team2_bools.iter().sum::<Expression>() == 5))

or to make things clearer

let team1_score : Expression = team1_bools.iter().sum(); 
model = model.with(constraint!(team1_score == 5))

from good_lp.

lovasoa avatar lovasoa commented on June 2, 2024

As an aside, what do you mean exactly by

I just really want to use rust for the increased speed.

?

Whether you define your model in python or in rust, the optimizer itself is a compiled library (written in C++ most of the time). So rewriting your code from python to rust will increase speed only if your model is tiny, or if startup time is important.

from good_lp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.