Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pause algorithm execution #30

Open
bdelespierre opened this issue Sep 6, 2021 · 3 comments
Open

Pause algorithm execution #30

bdelespierre opened this issue Sep 6, 2021 · 3 comments
Milestone

Comments

@bdelespierre
Copy link
Owner

bdelespierre commented Sep 6, 2021

Since resuming the algorithm is possible (see #28), why not give the user the ability to pause it as well?

Here's an implementation target:

$algo = new Kmeans\Algorithm(new Kmeans\RandomInitialization());

$aglo->registerIterationCallback(function ($algo) {
    if ($algo->getStatus()->startedAt() > new \DateTime('1 hour ago')) {
        return $algo->pause();
    }
});

$result = $algo->clusterize($points, $nbClusters);

if ($result->getStatus()->isPaused()) {
    echo "Clusterization ran for more than 1h and had to be paused.";
}

What do you think?

@battlecook
Copy link
Contributor

Is it serialized when paused?

@bdelespierre
Copy link
Owner Author

Is it serialized when paused?

No, only when you serialize($result).

@battlecook
Copy link
Contributor

I think it's okay to provide a pause function to the user.

@bdelespierre bdelespierre added this to the v3.0 milestone Mar 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants