https://github.com/makao/lpsolve
LPSolve extension as simple PHP library
https://github.com/makao/lpsolve
constraint linear lpsolve php programming simplex
Last synced: 10 days ago
JSON representation
LPSolve extension as simple PHP library
- Host: GitHub
- URL: https://github.com/makao/lpsolve
- Owner: makao
- Created: 2016-03-20T12:35:08.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-03-20T12:45:55.000Z (about 9 years ago)
- Last Synced: 2025-01-07T18:39:24.391Z (5 months ago)
- Topics: constraint, linear, lpsolve, php, programming, simplex
- Language: PHP
- Size: 6.84 KB
- Stars: 11
- Watchers: 2
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LPSolve
[LPSolve](http://lpsolve.sourceforge.net) is a PHP extension for solving linear programming problems. This library provides a wrapper for standard lpsolve() function.## Installation
Run composer
```
composer require makao/lpsolve
```
Require autoloader
```php
require 'vendor/autoload.php'
```## Usage
```php
use makao\LPSolve\Constraint;
use makao\LPSolve\Problem;
use makao\LPSolve\Solver;// Define constraints
$constraints = [
new Constraint([120, 210, 150.75], LE, 15000),
new Constraint([110, 30, 125], LE, 4000),
new Constraint([1, 1, 1], LE, 75)
];// Or initialize them from string
// $constraints = [
// Constraint::fromString('120x + 210y + 150.75z <= 15000'),
// Constraint::fromString('110x + 30y + 125z <= 4000'),
// Constraint::fromString('1x + 1y + 1z <= 75')
// ];// Define problem
$problem = new Problem([143, 60, 195], $constraints);// Solve it!
$solver = new Solver(Solver::MAX); // Can be either Solver::MIN for minimalization
$solution = $solver->solve($problem);var_dump($solution);
```**Note:** Do not omit coefficient value when create constraint from string.
There are 3 examples provided in example.php.
For more information please visit: http://lpsolve.sourceforge.net
## License
MIT