ankane/cbc

Mixed-integer programming for PHP

Maintainers

Package info

github.com/ankane/cbc-php

pkg:composer/ankane/cbc

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-04-13 23:09 UTC

This package is not auto-updated.

Last update: 2026-04-14 21:30:08 UTC


README

Cbc - the mixed-integer programming solver - for PHP

Build Status

Installation

First, install Cbc. For Homebrew, use:

brew install cbc

And for Ubuntu, use:

sudo apt-get install coinor-libcbc-dev

Then run:

composer require ankane/cbc

Getting Started

The API is fairly low-level at the moment

Load a problem

$model = Cbc\Model::loadProblem(
    sense: Cbc\Sense::Minimize,
    start: [0, 3, 6],
    index: [0, 1, 2, 0, 1, 2],
    value: [2, 3, 2, 2, 4, 1],
    colLower: [0, 0],
    colUpper: [1e30, 1e30],
    obj: [8, 10],
    rowLower: [7, 12, 6],
    rowUpper: [1e30, 1e30, 1e30],
    colType: [Cbc\ColType::Integer, Cbc\ColType::Continuous]
);

Solve

$model->solve();

Write the problem to an LP or MPS file

$model->writeLp('hello.lp');
// or
$model->writeMps('hello'); // adds .mps.gz

Read a problem from an LP or MPS file

$model = Cbc\Model::readLp('hello.lp');
// or
$model = Cbc\Model::readMps('hello.mps.gz');

Reference

Set the log level

$model->solve(logLevel: 1); // 0 = off, 3 = max

Set the time limit in seconds

$model->solve(timeLimit: 30);

History

View the changelog

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

To get started with development:

git clone https://github.com/ankane/cbc-php.git
cd cbc-php
composer install
composer test