GithubHelp home page GithubHelp logo

junjiedong / lp-solver Goto Github PK

View Code? Open in Web Editor NEW
5.0 0.0 1.0 49 KB

A simple Linear Programming (LP) solver in Python

Python 100.00%
optimization linear-programming interior-point-method convex-optimization

lp-solver's Introduction

LP-Solver

This repo implements a simple standard form Linear Programming (LP) solver in Python.

The solver uses the barrier method which involves solving an LP centering problem in every iteration (see Chapter 11 of Boyd and Vandenberghe's Convex Optimization textbook).

Files

  • lp_solver.py implements the LPSolver class, which can be used as follows:
# Randomly generate a feasible LP problem
m, n = 100, 500
A = np.random.randn(m, n)
A[0,:] = np.random.rand(n) + 0.1  # make sure problem is bounded
b = np.dot(A, np.random.rand(n) + 0.01)
c = np.random.rand(n)

# Solve the problem
solver = LPSolver(mu=10, tol=1e-4)
solver.solve(A, b, c)
assert solver.status == 'optimal'
print("optimal value: {}".format(solver.value))
  • test.py verifies LPSolver's basic functionalities by running it on both feasible and infeasible LP problems. The results are verified against the output from CVXPY.

Algorithms

Barrier Method

The feasible start barrier method can be summarized as follows:

barrier

The centering problem is an equality constrained optimization problem that can be solved using Newton's method with backtracking line search (see LPCenteringSolver in lp_solver.py)

Feasibility Check

Strict feasibility can be first determined by solving the following LP problem, of which a feasible starting point can be easily identified:

The original LP is strictly feasible if and only if the optimal value of this problem is less than 1. The optimal x obtained from this problem can be used as the starting point for the barrier method.

lp-solver's People

Contributors

junjiedong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Forkers

tigermlt

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.