2017 © Pedro Peláez
 

library solvice-client

Solvice client library

image

skmedia/solvice-client

Solvice client library

  • Monday, September 26, 2016
  • by skmedia
  • Repository
  • 2 Watchers
  • 0 Stars
  • 15 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

# Solvice client

Installation

composer require skmedia/solvice-client, (*1)

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();
        }
    }
}

The Versions

08/09 2016

0.0.1

0.0.1.0

Solvice client library

  Sources   Download

The Requires

 

The Development Requires