dev-master
9999999-dev https://github.com/i4h/php-mipA PHP Class to Create and Output Mixed-Integer Programs
MIT
by Ingmar Vierhaus
by Fabian Gnegel
php optimization mixed-integer
Wallogit.com
2017 © Pedro Peláez
A PHP Class to Create and Output Mixed-Integer Programs
PhpMIP is a PHP class representing a Linear Mixed-Integer Programm., (*1)
It comes with a writer to the IBM CPLEX LP file format and a base writer and Interface that should facilitate adding your own writer classes., (*2)
The package can be installed into your project via composer:, (*3)
$ php composer.phar require i4h/php-mip "*"
See the examples directory for two examples MIPs., (*4)
The workflow follows that of common modeling languages: - Create sets - Create variables - Create constraints - Define the objective function, (*5)
This is the example from example/trivial.php:, (*6)
$mip = new \vendor\i4h\PhpMIP\MIP();
/* Variable x */
$mip->addVariable("x", \vendor\i4h\PhpMIP\MIPvariable::TYPE_CONTINUOUS);
$mip->setVariableLB("x", 0);
/* Variable y */
$mip->addVariable("y", \vendor\i4h\PhpMIP\MIPvariable::TYPE_CONTINUOUS);
$mip->setVariableLB("y", 0);
/* Objective (default coefficient is 1) */
$mip->addObjectiveCoefficient("x");
$mip->addObjectiveCoefficient("y");
/* Constraint x + y <= 1 */
$vars = [
['name'=>'x', 'coefficient'=>1],
['name'=>'y', 'coefficient'=>1],
];
$mip->addConstraintLE($vars, 1);
/* Use Lp writer to write to a file */
$writer = new \vendor\i4h\PhpMIP\LpWriter();
$writer->setOutFile("/path/to/outfile.lp");
$writer->write(create);
The code above will create an lp file with the following content:, (*7)
Minimize obj: 1 x + 1 y Subject To 1 x + 1 y <= 1 Bounds end
A PHP Class to Create and Output Mixed-Integer Programs
MIT
php optimization mixed-integer