2017 © Pedro Peláez
 

library php-mip

A PHP Class to Create and Output Mixed-Integer Programs

image

i4h/php-mip

A PHP Class to Create and Output Mixed-Integer Programs

  • Tuesday, February 7, 2017
  • by i4h
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

PhpMIP

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)

Installation

The package can be installed into your project via composer:, (*3)

 $ php composer.phar require i4h/php-mip "*"

Usage

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

The Versions

07/02 2017

dev-master

9999999-dev https://github.com/i4h/php-mip

A PHP Class to Create and Output Mixed-Integer Programs

  Sources   Download

MIT

by Ingmar Vierhaus
by Fabian Gnegel

php optimization mixed-integer