Code Monkey home page Code Monkey logo

operation-research's Introduction

Operation-Research

Algorithms and methods for linear programming

This repo contains some Python code for basic linear programming techniques, such as solution of optimization problems using the Simplex method.

The project is far from complete, many things are still missing for the code to be actually useful in any context, other than college-level exercises. In the main.py file you'll find a list of the features that still need to be introduced, which I'll briefly report here:

  • Not sure the program works where no admissible basis can be found. Implement Phase I simplex
  • The algo does not manage the case of an illimitate problem. Add limitation clause in the j = argmin section
  • Test the script for performance in terms of execution time and memomary management, I bet there's still a lot of room for improvement. Develop an actual benchmark, not the one currently implemented
  • Adapt the optimum outcome to the actual scope, wether a maximization or minimization
  • Implement other methods to solve a linear programming problem.

If you wish to contribute to this project, feel free to contact me on my LinkedIn.

Tutorial

Given a linear programming optimization problem written in standard form, import numpy and LinearProblem from the file src/LinearProblem.py. Create a m x n numpy array containing your constraints.

A = np.array([[1,2,3,1],
              [2,1,1,2]])

The objective function coefficients and the constraints parameters are stored as well in numpy arrays

b = np.array([3,4])
c = np.array([-1,-3,-5,-2]) 

Instantiate a LinearProgramming(A,b,c) object, the constructor takes as input the three quantities we've just defined. To calculate the solution, run the command solve("method") and specify the desired method (for now "simplex" is the only one available).

prob = LinearProblem(A,b,c)
sol = prob.solve("simplex")

To find the actual optimum of the problem, run prob.optimum().

operation-research's People

Contributors

dr4k3z avatar rikygirg avatar

Watchers

 avatar

Forkers

rikygirg

operation-research's Issues

While condition in simplex function line 65

The while checks if there's any element less than zero in self.T[0,:]. But this checks the whole row, including the objective function value in the upper right corner. Shouldn't this be modified to self.T[0:(m-1)]?

Phase I simplex: basis to start from

I got up to the simplex iteration of phase I tableau, but I can't procede any further. How do I extract the basis to start from? I believe also the __simplex() function needs to be updated

__inbase(self) function doesn't work

Surely enough for the artificial problem in Phase I simplex, but probably also for some cases of standard simplex, the __inbase() function it's not right. The condition used to check wether a variable is in base or not is simply wrong

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.