Skip to content

Comments

Time bound solvers#57

Merged
Jetison333 merged 8 commits intoReduxISU:CSharpAPIfrom
wrigjl:time-bound-solvers
Jan 15, 2026
Merged

Time bound solvers#57
Jetison333 merged 8 commits intoReduxISU:CSharpAPIfrom
wrigjl:time-bound-solvers

Conversation

@wrigjl
Copy link
Collaborator

@wrigjl wrigjl commented Nov 24, 2025

This is an implementation of time-bound solvers using cooperative threading. There's no functional change for most of the solvers, but the idea is that each solver can check to see if it has run out of time to find a solution. If so, it should gracefully return. The main loop of a solver using this framework would look like:

for (int i = 0; i < Math.pow(2,N); i++) {
   try_one_combination();
  if (timerHasExpired)
    return "timeout";
}

Note: it's not possible in modern threading systems, C# included, to abort a thread AND have a consistent system (what if it was holding a lock? a semaphore? etc.). So, the best you can do is cooperative threading where you ask politely for a thread to finish what it's doing and then wait.

It's annoying that interfaces can't define instance variables, which is the only reason I had to modify every solver. I considered using a class, but that was even uglier.

TODO:

  • don't hard code the solution time to 5 seconds (maybe a variable in the json config?)
  • go through the solvers and add timer expired checks (can be done after this is merged)

closes #56

@Jetison333 Jetison333 merged commit 481301b into ReduxISU:CSharpAPI Jan 15, 2026
@wrigjl wrigjl deleted the time-bound-solvers branch January 15, 2026 21:18
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

Successfully merging this pull request may close these issues.

bounding solution times

2 participants