SGSolve
SGSolverWorker Class Reference

Class for implementing the twist algorithm within SGViewer. More...

#include <sgsolverworker.hpp>

Inheritance diagram for SGSolverWorker:
Collaboration diagram for SGSolverWorker:

Public Types

enum  STATUS { FAILED, CONVERGED, NOTCONVERGED }
 Code for status at the end of the iteration. More...
 

Public Slots

void iterate ()
 Iterates. More...
 
const SGSolution_MaxMinMaxgetSolution () const
 Returns the SGSolution object.
 
const SGSolver_MaxMinMaxgetSolver () const
 Returns the solver object.
 

Signals

void resultReady (bool)
 Signal that gets emitted when iteration finishes.
 
void exceptionCaught ()
 Signal that gets emitted when an exception is caught. More...
 

Public Member Functions

 SGSolverWorker (const SGEnv &_env, const SGGame &game, QTextEdit *_logTextEdit)
 Constructor. More...
 
STATUS getStatus () const
 Returns the status of the worker.
 
const QString & getExceptionMsg () const
 Returns the exception message (if one is caught)
 

Public Attributes

enum SGSolverWorker::STATUS status
 

Private Attributes

const SGEnvenv
 An environment object to hold settings.
 
SGSolver_MaxMinMax solver
 The main object for performing calculations.
 
QTextEdit * logTextEdit
 A pointer to the text edit in which to report progress.
 
int numIter
 Number of iterations.
 
QString exceptionMsg
 Exception message caught by solver.
 

Detailed Description

Class for implementing the twist algorithm within SGViewer.

If we just used the SGSolver class to solve the game, the algorithm would run continuously until convergence or an error. Since we want regular status updates and we want to print progress to the log window, we have to reimplement the solver routine.

This class uses SGApprox to calculate the solution. The main program assigns this object to a separate thread to preserve responsiveness of the algorithm. After each iteration, control is returned to the main process, which prints a status update if a revolution has been completed and cancels the algorithm if the cancel flag has been thrown. Communication between the SGSolverWorker and SGMainWindow is facilitated by signals and slots.

Member Enumeration Documentation

◆ STATUS

Code for status at the end of the iteration.

Enumerator
FAILED 

Could not complete the iteration. An error occured.

CONVERGED 

Algorithm completed the iteration and has converged.

NOTCONVERGED 

Algorithm completed the iteration but has not converged.

Constructor & Destructor Documentation

◆ SGSolverWorker()

SGSolverWorker::SGSolverWorker ( const SGEnv _env,
const SGGame game,
QTextEdit *  _logTextEdit 
)
inline

Constructor.

Initializes the solver object. Waits for instruction to begin iteration via the SGSolverWorker_V2::iterate slot.

Member Function Documentation

◆ exceptionCaught

void SGSolverWorker::exceptionCaught ( )
signal

Signal that gets emitted when an exception is caught.

Not currently used.

◆ iterate

void SGSolverWorker::iterate ( )
inlineslot

Iterates.

Runs one iteration of the twist algorithm and emits the resultReady signal.

Member Data Documentation

◆ status

enum SGSolverWorker::STATUS SGSolverWorker::status

Current status.


The documentation for this class was generated from the following file: