Coder Social home page Coder Social logo

highs's Introduction

highs

highs docs badge

Safe rust bindings to the Highs MILP Solver. Best used from the good_lp linear programming modeler.

Usage examples

Building a problem variable by variable

use highs::{ColProblem, Sense};

fn main() {
    let mut pb = ColProblem::new();
    // We cannot use more then 5 units of sugar in total.
    let sugar = pb.add_row(..=5);
    // We cannot use more then 3 units of milk in total.
    let milk = pb.add_row(..=3);
    // We have a first cake that we can sell for 2€. Baking it requires 1 unit of milk and 2 of sugar.
    pb.add_integer_column(2., 0.., &[(sugar, 2.), (milk, 1.)]);
    // We have a second cake that we can sell for 8€. Baking it requires 2 units of milk and 3 of sugar.
    pb.add_integer_column(8., 0.., &[(sugar, 3.), (milk, 2.)]);
    // Find the maximal possible profit
    let solution = pb.optimise(Sense::Maximise).solve().get_solution();
    // The solution is to bake one cake of each sort
    assert_eq!(solution.columns(), vec![1., 1.]);
}

Building a problem constraint by constraint

use highs::*;

fn main() {
    let mut pb = RowProblem::new();
    // Optimize 3x - 2y with x<=6 and y>=5
    let x = pb.add_column(3., ..6);
    let y = pb.add_column(-2., 5..);
    pb.add_row(2.., &[(x, 3.), (y, 8.)]); // 2 <= x*3 + y*8
}

highs's People

Contributors

lovasoa avatar mmghannam avatar coloquinte avatar yongqli avatar

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.