skmedia/solvice-client

There is no license information available for the latest version (0.0.1) of this package.

Solvice client library

0.0.1 2016-09-08 09:18 UTC

This package is not auto-updated.

Last update: 2024-05-11 17:39:55 UTC


README

Installation

composer require skmedia/solvice-client

Create a client

$solviceClient = new SolviceClient('https://api.solvice.io', 'username', 'password');

Create a cluster solver

use Solvice\Http\Client as SolviceClient
use Solvice\Collection as SolviceCollection;
use Solvice\Entity as SolviceEntity;
use Solvice\Solver as SolviceSolver;

$clusterSolver = new SolviceSolver\ClusterSolver();
$clusterSolver->addCluster(SolviceEntity\Cluster::make('Cluster 1', 'single_paper', 3));
$clusterSolver->addCluster(SolviceEntity\Cluster::make('Cluster 2', 'single_paper', 1));

$clusterSolver->addEntity(
    SolviceEntity\Entity::make(
        'Single Paper 1',
        'single_paper',
        SolviceCollection\KeywordCollection::make(
            SolviceEntity\Keyword::make('sig_1'),
            SolviceEntity\Keyword::make('sig_2')
        )
    )
);

$clusterSolver->addEntity(
    SolviceEntity\Entity::make(
        'Single Paper 2',
        'single_paper',
        SolviceCollection\KeywordCollection::make(
            SolviceEntity\Keyword::make('sig_1'),
            SolviceEntity\Keyword::make('sig_2')
        )
    )
);

$clusterSolver->addEntity(
    SolviceEntity\Entity::make(
        'Single Paper 3',
        'single_paper',
        SolviceCollection\KeywordCollection::make(
            SolviceEntity\Keyword::make('sig_1'),
            SolviceEntity\Keyword::make('sig_2')
        )
    )
);

$clusterSolver->addEntity(
    SolviceEntity\Entity::make(
        'Single Paper 4',
        'single_paper',
        SolviceCollection\KeywordCollection::make(
            SolviceEntity\Keyword::make('sig_5'),
            SolviceEntity\Keyword::make('sig_6')
        )
    )
);

$response = $solviceClient->solve($clusterSolver)

Create a conference solver

if ($job->isSolved()) {

    $response->getScore()->isFeasible();
    
    // Error messages (hard and soft constraints)
    echo $response->getUnresolvedItems()
        ->byLevel(SolviceEntity\UnresolvedItemLevel::HARD)
        ->joinBy('name');
    
    echo $response->getUnresolvedItems()
        ->byLevel(SolviceEntity\UnresolvedItemLevel::SOFT)
        ->joinBy('name');
    
    foreach ($response->getAssignments() as $assignment) {
        if ($assignment->hasRoomSlot()) {
            echo $assignment->getCluster()->getName()
                . ' is assigned to '
                . $assignment->getRoomSlot()->getRoom()->getName();
        }
    }
}