LogicGrowsOnTrees-1.1.0.2: a parallel implementation of logic programming using distributed tree exploration

Safe HaskellNone

LogicGrowsOnTrees.Parallel.Main

Contents

Description

This module provides a framework for creating a program that explores a tree in parallel. There are two families of functions that are available. The first is more general and allows you to construct your tree using arguments given on the command-line; they are described in the section linked to by LogicGrowsOnTrees.Parallel.Main. If you do not need run-time information via a command-line argument to construct the tree, then you may prefer the simpler family of functions which are described in the section linked to by LogicGrowsOnTrees.Parallel.Main.

All of this functionality is adapter independent, so if you want to use a different back end you only need to change the driver argument and recompile.

Synopsis

Types

Driver types

data Driver result_monad shared_configuration supervisor_configuration m n exploration_mode Source

The Driver is the core type that abstracts the various adapters behind a common interface that can be invoked by the main functions; it specifies a function that is called to start the run with a set of parameters specified in DriverParameters.

(Unfortunately in haddock the type signature below can be difficult to read because it puts all of the type on a single line; the type is essentially just a map from DriverParameters to result_monad (), but involving a bunch of type variables and some constraints on them. It might be easier to click the link to go to the source.)

Note that the controller_monad type parameter is within an existential type; this is because the user of the driver should not need to know what it is.

Constructors

forall controller_monad . (RequestQueueMonad (controller_monad exploration_mode), ExplorationModeFor (controller_monad exploration_mode) ~ exploration_mode) => Driver ((Serialize (ProgressFor exploration_mode), MonadIO result_monad) => DriverParameters shared_configuration supervisor_configuration m n exploration_mode controller_monad -> result_monad ()) 

data DriverParameters shared_configuration supervisor_configuration m n exploration_mode controller_monad Source

The DriverParameters type specifies the information that is given to the driver in the main functions.

Constructors

DriverParameters 

Fields

shared_configuration_term :: Term shared_configuration

configuration information shared between the supervisor and the worker

supervisor_configuration_term :: Term supervisor_configuration

configuration information specific to the supervisor

program_info :: TermInfo

program information; should at a minimum put a brief description of the program in the termDoc field

initializeGlobalState :: shared_configuration -> IO ()

action that initializes the global state of each process --- that is, once for each running instance of the executable, which depending on the adapter might be a supervisor, a worker, or both

getStartingProgress :: shared_configuration -> supervisor_configuration -> IO (ProgressFor exploration_mode)

in the supervisor, gets the starting progress for the exploration; this is where a checkpoint is loaded, if one exists

notifyTerminated :: shared_configuration -> supervisor_configuration -> RunOutcomeFor exploration_mode -> IO ()

in the supervisor, responds to the termination of the run

constructExplorationMode :: shared_configuration -> ExplorationMode exploration_mode

constructs the exploration mode given the shared configuration

constructTree :: shared_configuration -> TreeT m (ResultFor exploration_mode)

constructs the tree given the shared configuration

purity :: Purity m n

the purity of the constructed tree

constructController :: shared_configuration -> supervisor_configuration -> controller_monad exploration_mode ()

construct the controller, which runs in the supervisor and handles things like periodic checkpointing

Outcome types

data RunOutcome progress final_result Source

A type that represents the outcome of a run.

Constructors

RunOutcome 

Fields

runStatistics :: RunStatistics

statistics gathered during the run, useful if the system is not scaling with the number of workers as it should

runTerminationReason :: TerminationReason progress final_result

the reason why the run terminated

Instances

(Eq progress, Eq final_result) => Eq (RunOutcome progress final_result) 
(Show progress, Show final_result) => Show (RunOutcome progress final_result) 

type RunOutcomeFor exploration_mode = RunOutcome (ProgressFor exploration_mode) (FinalResultFor exploration_mode)Source

A convenient type alias for the type of RunOutcome associated with the given exploration mode.

data RunStatistics Source

Statistics gathered about the run.

Constructors

RunStatistics 

Fields

runStartTime :: !UTCTime

the start time of the run

runEndTime :: !UTCTime

the end time of the run

runWallTime :: !NominalDiffTime

the wall time of the run

runSupervisorOccupation :: !Float

the fraction of the time the supervisor spent processing events

runSupervisorMonadOccupation :: !Float

the fraction of the time the supervisor spent processing events while inside the SupervisorMonad

runNumberOfCalls :: !Int

the number of calls made to functions in LogicGrowsOnTrees.Parallel.Common.Supervisor

runAverageTimePerCall :: !Float

the average amount of time per call made to functions in LogicGrowsOnTrees.Parallel.Common.Supervisor

runWorkerCountStatistics :: !(FunctionOfTimeStatistics Int)

statistics for the number of workers waiting for a workload

runWorkerOccupation :: !Float

the fraction of the total time that workers were occupied

runWorkerWaitTimes :: !(FunctionOfTimeStatistics NominalDiffTime)

statistics for how long it took for workers to obtain a workload

runStealWaitTimes :: !IndependentMeasurementsStatistics

statistics for the time needed to steal a workload from a worker

runWaitingWorkerStatistics :: !(FunctionOfTimeStatistics Int)

statistics for the number of workers waiting for a workload

runAvailableWorkloadStatistics :: !(FunctionOfTimeStatistics Int)

statistics for the number of available workloads waiting for a worker

runInstantaneousWorkloadRequestRateStatistics :: !(FunctionOfTimeStatistics Float)

statistics for the instantaneous rate at which workloads were requested (using an exponentially decaying sum)

runInstantaneousWorkloadStealTimeStatistics :: !(FunctionOfTimeStatistics Float)

statistics for the instantaneous time needed for workloads to be stolen (using an exponentially decaying weighted average)

data TerminationReason progress final_result Source

A type that represents the reason why a run terminated.

Constructors

Aborted progress

the run was aborted with the given progress

Completed final_result

the run completed with the given final result

Failure progress String

the run failed with the given progress for the given reason

Instances

(Eq progress, Eq final_result) => Eq (TerminationReason progress final_result) 
(Show progress, Show final_result) => Show (TerminationReason progress final_result) 

type TerminationReasonFor exploration_mode = TerminationReason (ProgressFor exploration_mode) (FinalResultFor exploration_mode)Source

A convenient type alias for the type of TerminationReason associated with the given exploration mode.

Main functions

The functions in this section all provide a main function that starts up the system that explores a tree in parallel using the given tree (constructed possibly using information supplied on the command line) and the given adapter provided via the driver argument.

All of the functionality of this module can be accessed through genericMain, but we nonetheless also provide specialized versions of these functions for all of the supported tree purities and exploration modes. This is done for two reasons: first, in order to make the types more concrete to hopefully improve usability, and second, because often the type of the tree is generalized so it could be one of several types, and using a specialized function automatically specializes the type rather than requiring a type annotation. The convention is mainForExploreTreeXY where X is empty for pure trees, IO for trees with side-effects in the IO monad, and Impure for trees with side-effects in some general monad, and Y specifies the exploration mode, which is empty for AllMode (sum over all results), UntilFirst for FirstMode (stop when first result found), UntilFoundUsingPull for FoundModeUsingPull (sum all results until a condition has been met, only sending results to the supervisor upon request) and UntilFoundUsingPush for FoundModeUsingPush (sum all results until a condition has been met, pushing all found results immediately to the supervisor).

If you do not need to use command-line arguments to construct the tree and don't care about what the name of the program is on the help screen then you might be interested in the simpler version of these functions in the following section (follow LogicGrowsOnTrees.Parallel.Main).

Sum over all results

The functions in this section are for when you want to sum over all the results in (the leaves of) the tree.

mainForExploreTreeSource

Arguments

:: (Monoid result, Serialize result, MonadIO result_monad) 
=> Driver result_monad (SharedConfiguration tree_configuration) SupervisorConfiguration Identity IO (AllMode result)

the driver for the desired adapter (note that all drivers can be specialized to this type)

-> Term tree_configuration

a term with any configuration information needed to construct the tree

-> TermInfo

information about the program; should look something like the following:

 defTI { termDoc = "count the number of n-queens solutions for a given board size" }
-> (tree_configuration -> RunOutcome (Progress result) result -> IO ())

a callback that will be invoked with the outcome of the run and the tree configuration information; note that if the run was Completed then the checkpoint file will be deleted if this function finishes successfully

-> (tree_configuration -> Tree result)

the function that constructs the tree given the tree configuration information

-> result_monad () 

Explore the given pure tree in parallel; the results in the leaves will be summed up using the Monoid instance.

mainForExploreTreeIOSource

Arguments

:: (Monoid result, Serialize result, MonadIO result_monad) 
=> Driver result_monad (SharedConfiguration tree_configuration) SupervisorConfiguration IO IO (AllMode result)

the driver for the desired adapter (note that all drivers can be specialized to this type)

-> Term tree_configuration

a term with any configuration information needed to construct the tree

-> TermInfo

information about the program; should look something like the following:

 defTI { termDoc = "count the number of n-queens solutions for a given board size" }
-> (tree_configuration -> RunOutcome (Progress result) result -> IO ())

a callback that will be invoked with the outcome of the run and the tree configuration information; note that if the run was Completed then the checkpoint file will be deleted if this function finishes successfully

-> (tree_configuration -> TreeIO result)

the function that constructs the tree given the tree configuration information

-> result_monad () 

Explore the given IO tree in parallel; the results in the leaves will be summed up using the Monoid instance.

mainForExploreTreeImpureSource

Arguments

:: (Monoid result, Serialize result, MonadIO result_monad, Functor m, MonadIO m) 
=> (forall β. m β -> IO β)

a function that runs an m action in the IO monad

-> Driver result_monad (SharedConfiguration tree_configuration) SupervisorConfiguration m m (AllMode result)

the driver for the desired adapter (note that all drivers can be specialized to this type)

-> Term tree_configuration

a term with any configuration information needed to construct the tree

-> TermInfo

information about the program; should look something like the following:

 defTI { termDoc = "count the number of n-queens solutions for a given board size" }
-> (tree_configuration -> RunOutcome (Progress result) result -> IO ())

a callback that will be invoked with the outcome of the run and the tree configuration information; note that if the run was Completed then the checkpoint file will be deleted if this function finishes successfully

-> (tree_configuration -> TreeT m result)

the function that constructs the tree given the tree configuration information

-> result_monad () 

Explore the given impure tree in parallel; the results in all of the leaves will be summed up using the Monoid instance.

Stop at first result

The functions in this section are for when you want to stop as soon as you have found a result.

There are two ways in which a system running in this mode can terminate normally:

  1. A solution is found, in which case a Just-wrapped value is returned with both the found solution and the current Checkpoint, the latter allowing one to resume the search to look for more solutions later.
  2. The whole tree has been explored, in which case Nothing is returned.

mainForExploreTreeUntilFirstSource

Arguments

:: (Serialize result, MonadIO result_monad) 
=> Driver result_monad (SharedConfiguration tree_configuration) SupervisorConfiguration Identity IO (FirstMode result)

the driver for the desired adapter (note that all drivers can be specialized to this type)

-> Term tree_configuration

a term with any configuration information needed to construct the tree

-> TermInfo

information about the program; should look something like the following:

 defTI { termDoc = "count the number of n-queens solutions for a given board size" }
-> (tree_configuration -> RunOutcome Checkpoint (Maybe (Progress result)) -> IO ())

a callback that will be invoked with the outcome of the run and the tree configuration information; note that if the run was Completed then the checkpoint file will be deleted if this function finishes successfully

-> (tree_configuration -> Tree result)

the function that constructs the tree given the tree configuration information

-> result_monad () 

Explore the given pure tree in parallel, stopping if a solution is found.

mainForExploreTreeIOUntilFirstSource

Arguments

:: (Serialize result, MonadIO result_monad) 
=> Driver result_monad (SharedConfiguration tree_configuration) SupervisorConfiguration IO IO (FirstMode result)

the driver for the desired adapter (note that all drivers can be specialized to this type)

-> Term tree_configuration

a term with any configuration information needed to construct the tree

-> TermInfo

information about the program; should look something like the following:

 defTI { termDoc = "count the number of n-queens solutions for a given board size" }
-> (tree_configuration -> RunOutcome Checkpoint (Maybe (Progress result)) -> IO ())

a callback that will be invoked with the outcome of the run and the tree configuration information; note that if the run was Completed then the checkpoint file will be deleted if this function finishes successfully

-> (tree_configuration -> TreeIO result)

the function that constructs the tree given the tree configuration information

-> result_monad () 

Explore the given IO tree in parallel, stopping if a solution is found.

mainForExploreTreeImpureUntilFirstSource

Arguments

:: (Serialize result, MonadIO result_monad, Functor m, MonadIO m) 
=> (forall β. m β -> IO β)

a function that runs an m action in the IO monad

-> Driver result_monad (SharedConfiguration tree_configuration) SupervisorConfiguration m m (FirstMode result)

the driver for the desired adapter (note that all drivers can be specialized to this type)

-> Term tree_configuration

a term with any configuration information needed to construct the tree

-> TermInfo

information about the program; should look something like the following:

 defTI { termDoc = "count the number of n-queens solutions for a given board size" }
-> (tree_configuration -> RunOutcome Checkpoint (Maybe (Progress result)) -> IO ())

a callback that will be invoked with the outcome of the run and the tree configuration information; note that if the run was Completed then the checkpoint file will be deleted if this function finishes successfully

-> (tree_configuration -> TreeT m result)

the function that constructs the tree given the tree configuration information

-> result_monad () 

Explore the given impure tree in parallel, stopping if a solution is found.

Stop when sum of results found

The functions in this section are for when you want sum the results as you find them until the sum matches a condition. There are two versions of this mode, based on whether one wants to regularly poll the workers for results or whether one wants workers to immediately push every result to the supervisor as soon as it is found.

Pull

In this mode, partial results are left on the workers until they receive either a workload steal request or a progress update request. The advantage of this approach is that it minimizes communication costs as partial results are sent on an occasional basis rather than as soon as they are found. The downside of this approach is that one has to poll the workers on a regular basis using a global process update, and between polls it might be the case that the sum of all results in the system meets the condition but this will not be found out until the next poll, which wastes time equal to the amount of time between polls. If you would rather have the system immediately terminate as soon as it has found the desired results (at the price of paying an additional cost as each workload is found in sending it to the supervisor), then follow LogicGrowsOnTrees.Parallel.Main to see the description of push mode.

There are three ways in which a system running in this mode can terminate:

  1. A worker finds another result and now its (new) local sum meet the condition; in this case the sum of the worker's local sum and the supervisor's local sum is returned along with the current checkpoint (which allows the search to be resumed later to find more results), all wrapped in a Right.
  2. The supervisor, having just received some new results from a worker, has its (new) local sum meet the condition; this has essentially the same effect as 1.
  3. The tree has been fully explored, in which case the full sum is returned in a Left.

WARNING: If you use this mode then you need to enable checkpointing when the program is run; if you do not do this, then you might end up in a situation where the sum of results over the entire system meets the condition but the system does not realize this because the results have not been gathered together and summed at the supervisor.

mainForExploreTreeUntilFoundUsingPullSource

Arguments

:: (Monoid result, Serialize result, MonadIO result_monad) 
=> (tree_configuration -> result -> Bool)

a condition function that signals when we have found all of the result that we wanted

-> Driver result_monad (SharedConfiguration tree_configuration) SupervisorConfiguration Identity IO (FoundModeUsingPull result)

the driver for the desired adapter (note that all drivers can be specialized to this type)

-> Term tree_configuration

a term with any configuration information needed to construct the tree

-> TermInfo

information about the program; should look something like the following:

 defTI { termDoc = "count the number of n-queens solutions for a given board size" }
-> (tree_configuration -> RunOutcome (Progress result) (Either result (Progress result)) -> IO ())

a callback that will be invoked with the outcome of the run and the tree configuration information; note that if the run was Completed then the checkpoint file will be deleted if this function finishes successfully

-> (tree_configuration -> Tree result)

the function that constructs the tree given the tree configuration information

-> result_monad () 

Explore the given pure tree in parallel until the sum of results meets the given condition.

mainForExploreTreeIOUntilFoundUsingPullSource

Arguments

:: (Monoid result, Serialize result, MonadIO result_monad) 
=> (tree_configuration -> result -> Bool)

a condition function that signals when we have found all of the result that we wanted

-> Driver result_monad (SharedConfiguration tree_configuration) SupervisorConfiguration IO IO (FoundModeUsingPull result)

the driver for the desired adapter (note that all drivers can be specialized to this type)

-> Term tree_configuration

a term with any configuration information needed to construct the tree

-> TermInfo

information about the program; should look something like the following:

 defTI { termDoc = "count the number of n-queens solutions for a given board size" }
-> (tree_configuration -> RunOutcome (Progress result) (Either result (Progress result)) -> IO ())

a callback that will be invoked with the outcome of the run and the tree configuration information; note that if the run was Completed then the checkpoint file will be deleted if this function finishes successfully

-> (tree_configuration -> TreeIO result)

the function that constructs the tree given the tree configuration information

-> result_monad () 

Explore the given IO tree in parallel until the sum of results meets the given condition.

mainForExploreTreeImpureUntilFoundUsingPullSource

Arguments

:: (Monoid result, Serialize result, MonadIO result_monad, Functor m, MonadIO m) 
=> (tree_configuration -> result -> Bool)

a condition function that signals when we have found all of the result that we wanted

-> (forall β. m β -> IO β)

a function that runs an m action in the IO monad

-> Driver result_monad (SharedConfiguration tree_configuration) SupervisorConfiguration m m (FoundModeUsingPull result)

the driver for the desired adapter (note that all drivers can be specialized to this type)

-> Term tree_configuration

a term with any configuration information needed to construct the tree

-> TermInfo

information about the program; should look something like the following:

 defTI { termDoc = "count the number of n-queens solutions for a given board size" }
-> (tree_configuration -> RunOutcome (Progress result) (Either result (Progress result)) -> IO ())

a callback that will be invoked with the outcome of the run and the tree configuration information; note that if the run was Completed then the checkpoint file will be deleted if this function finishes successfully

-> (tree_configuration -> TreeT m result)

the function that constructs the tree given the tree configuration information

-> result_monad () 

Explore the given impure tree in parallel until the sum of results meets the given condition.

Push

In this mode, whenever a result is found it is immediately sent to the supervisor. The advantage of this approach is that the system finds out immediately when all the results found so far have met the condition, rather than waiting for a progress update to occur that gathers them together. The downside of this approach is that it costs some time for a worker to send a result to the supervisor, so if the condition will not be met until a large number of results have been found then it be better let the workers accumulate results locally and to poll them on a regular basis; to do this, follow LogicGrowsOnTrees.Parallel.Main to see the description of pull mode.

There are three ways in which a system running in this mode can terminate:

  1. The supervisor, having just received a new result from a worker, finds that its current sum meets the condition function, in which case it returns the sum as well as the current checkpoint (which allows the search to be resumed later to find more results) wrapped in a Right.
  2. The tree has been fully explored, in which case the full sum is returned in a Left.

(Note that, unlike the pull version, a partial result will not be returned upon success as the Supervisor has access to all results and so it will never be in the position of only having a partial result upon success.)

mainForExploreTreeUntilFoundUsingPushSource

Arguments

:: (Monoid result, Serialize result, MonadIO result_monad) 
=> (tree_configuration -> result -> Bool)

a condition function that signals when we have found all of the result that we wanted

-> Driver result_monad (SharedConfiguration tree_configuration) SupervisorConfiguration Identity IO (FoundModeUsingPush result)

the driver for the desired adapter (note that all drivers can be specialized to this type)

-> Term tree_configuration

a term with any configuration information needed to construct the tree

-> TermInfo

information about the program; should look something like the following:

 defTI { termDoc = "count the number of n-queens solutions for a given board size" }
-> (tree_configuration -> RunOutcome (Progress result) (Either result (Progress result)) -> IO ())

a callback that will be invoked with the outcome of the run and the tree configuration information; note that if the run was Completed then the checkpoint file will be deleted if this function finishes successfully

-> (tree_configuration -> Tree result)

the function that constructs the tree given the tree configuration information

-> result_monad () 

Explore the given pure tree in parallel until the sum of results meets the given condition.

mainForExploreTreeIOUntilFoundUsingPushSource

Arguments

:: (Monoid result, Serialize result, MonadIO result_monad) 
=> (tree_configuration -> result -> Bool)

a condition function that signals when we have found all of the result that we wanted

-> Driver result_monad (SharedConfiguration tree_configuration) SupervisorConfiguration IO IO (FoundModeUsingPush result)

the driver for the desired adapter (note that all drivers can be specialized to this type)

-> Term tree_configuration

a term with any configuration information needed to construct the tree

-> TermInfo

information about the program; should look something like the following:

 defTI { termDoc = "count the number of n-queens solutions for a given board size" }
-> (tree_configuration -> RunOutcome (Progress result) (Either result (Progress result)) -> IO ())

a callback that will be invoked with the outcome of the run and the tree configuration information; note that if the run was Completed then the checkpoint file will be deleted if this function finishes successfully

-> (tree_configuration -> TreeIO result)

the function that constructs the tree given the tree configuration information

-> result_monad () 

Explore the given IO tree in parallel until the sum of results meets the given condition.

mainForExploreTreeImpureUntilFoundUsingPushSource

Arguments

:: (Monoid result, Serialize result, MonadIO result_monad, Functor m, MonadIO m) 
=> (tree_configuration -> result -> Bool)

a condition function that signals when we have found all of the result that we wanted

-> (forall β. m β -> IO β)

a function that runs an m action in the IO monad

-> Driver result_monad (SharedConfiguration tree_configuration) SupervisorConfiguration m m (FoundModeUsingPush result)

the driver for the desired adapter (note that all drivers can be specialized to this type)

-> Term tree_configuration

a term with any configuration information needed to construct the tree

-> TermInfo

information about the program; should look something like the following:

 defTI { termDoc = "count the number of n-queens solutions for a given board size" }
-> (tree_configuration -> RunOutcome (Progress result) (Either result (Progress result)) -> IO ())

a callback that will be invoked with the outcome of the run and the tree configuration information; note that if the run was Completed then the checkpoint file will be deleted if this function finishes successfully

-> (tree_configuration -> TreeT m result)

the function that constructs the tree given the tree configuration information

-> result_monad () 

Explore the given impure tree in parallel until the sum of results meets the given condition.

Generic main function

genericMainSource

Arguments

:: (MonadIO result_monad, ResultFor exploration_mode ~ result, Serialize (ProgressFor exploration_mode)) 
=> (tree_configuration -> ExplorationMode exploration_mode)

a function that constructs the exploration mode given the tree configuration; note that the constructor that this function returns is restricted by the value of the exploration_mode type variable

-> Purity m n

the purity of the tree

-> Driver result_monad (SharedConfiguration tree_configuration) SupervisorConfiguration m n exploration_mode

the driver for the desired adapter (note that all drivers can be specialized to this type)

-> Term tree_configuration

a term with any configuration information needed to construct the tree

-> TermInfo

information about the program; should look something like the following:

 defTI { termDoc = "count the number of n-queens solutions for a given board size" }
-> (tree_configuration -> RunOutcomeFor exploration_mode -> IO ())

a callback that will be invoked with the outcome of the run and the tree configuration information; note that if the run was Completed then the checkpoint file will be deleted if this function finishes successfully

-> (tree_configuration -> TreeT m result)

the function that constructs the tree given the tree configuration information

-> result_monad () 

This is just like the previous functions, except that it is generalized over all tree purities and exploration modes. (In fact, the specialized functions are just wrappers around this function.)

Simple main functions

The functions in this section provide simpler version of the functions in the preceding section (follow LogicGrowsOnTrees.Parallel.Main) for the case where you do not need to use command-line arguments to construct the tree and don't care about what the name of the program is on the help screen; the naming convention follows the same convention as that in the previous section.

Sum over all results

The functions in this section are for when you want to sum over all the results in (the leaves of) the tree.

simpleMainForExploreTreeSource

Arguments

:: (Monoid result, Serialize result, MonadIO result_monad) 
=> Driver result_monad (SharedConfiguration ()) SupervisorConfiguration Identity IO (AllMode result)

the driver for the desired adapter (note that all drivers can be specialized to this type)

-> (RunOutcome (Progress result) result -> IO ())

a callback that will be invoked with the outcome of the run; note that if the run was Completed then the checkpoint file will be deleted if this function finishes successfully

-> Tree result

the tree to explore

-> result_monad () 

Explore the given pure tree in parallel; the results in the leaves will be summed up using the Monoid instance.

simpleMainForExploreTreeIOSource

Arguments

:: (Monoid result, Serialize result, MonadIO result_monad) 
=> Driver result_monad (SharedConfiguration ()) SupervisorConfiguration IO IO (AllMode result)

the driver for the desired adapter (note that all drivers can be specialized to this type)

-> (RunOutcome (Progress result) result -> IO ())

a callback that will be invoked with the outcome of the run; note that if the run was Completed then the checkpoint file will be deleted if this function finishes successfully

-> TreeIO result

the tree to explore in IO

-> result_monad () 

Explore the given IO tree in parallel; the results in the leaves will be summed up using the Monoid instance.

simpleMainForExploreTreeImpureSource

Arguments

:: (Monoid result, Serialize result, MonadIO result_monad, Functor m, MonadIO m) 
=> (forall β. m β -> IO β)

a function that runs an m action in the IO monad

-> Driver result_monad (SharedConfiguration ()) SupervisorConfiguration m m (AllMode result)

the driver for the desired adapter (note that all drivers can be specialized to this type)

-> (RunOutcome (Progress result) result -> IO ())

a callback that will be invoked with the outcome of the run; note that if the run was Completed then the checkpoint file will be deleted if this function finishes successfully

-> TreeT m result

the (impure) tree to explore

-> result_monad () 

Explore the given impure tree in parallel; the results in all of the leaves will be summed up using the Monoid instance.

Stop at first result

For more details, follow this link: LogicGrowsOnTrees.Parallel.Main

simpleMainForExploreTreeUntilFirstSource

Arguments

:: (Serialize result, MonadIO result_monad) 
=> Driver result_monad (SharedConfiguration ()) SupervisorConfiguration Identity IO (FirstMode result)

the driver for the desired adapter (note that all drivers can be specialized to this type)

-> (RunOutcome Checkpoint (Maybe (Progress result)) -> IO ())

a callback that will be invoked with the outcome of the run; note that if the run was Completed then the checkpoint file will be deleted if this function finishes successfully

-> Tree result

the tree to explore

-> result_monad () 

Explore the given pure tree in parallel, stopping if a solution is found.

simpleMainForExploreTreeIOUntilFirstSource

Arguments

:: (Serialize result, MonadIO result_monad) 
=> Driver result_monad (SharedConfiguration ()) SupervisorConfiguration IO IO (FirstMode result)

the driver for the desired adapter (note that all drivers can be specialized to this type)

-> (RunOutcome Checkpoint (Maybe (Progress result)) -> IO ())

a callback that will be invoked with the outcome of the run; note that if the run was Completed then the checkpoint file will be deleted if this function finishes successfully

-> TreeIO result

the tree to explore in IO

-> result_monad () 

Explore the given tree in parallel in IO, stopping if a solution is found.

simpleMainForExploreTreeImpureUntilFirstSource

Arguments

:: (Serialize result, MonadIO result_monad, Functor m, MonadIO m) 
=> (forall β. m β -> IO β)

a function that runs an m action in the IO monad

-> Driver result_monad (SharedConfiguration ()) SupervisorConfiguration m m (FirstMode result)

the driver for the desired adapter (note that all drivers can be specialized to this type)

-> (RunOutcome Checkpoint (Maybe (Progress result)) -> IO ())

a callback that will be invoked with the outcome of the run; note that if the run was Completed then the checkpoint file will be deleted if this function finishes successfully

-> TreeT m result

the impure tree to explore

-> result_monad () 

Explore the given impure tree in parallel, stopping if a solution is found.

Stop when sum of results found

For more details, follow this link: LogicGrowsOnTrees.Parallel.Main

Pull

For more details, follow this link: LogicGrowsOnTrees.Parallel.Main

simpleMainForExploreTreeUntilFoundUsingPullSource

Arguments

:: (Monoid result, Serialize result, MonadIO result_monad) 
=> (result -> Bool)

a condition function that signals when we have found all of the result that we wanted

-> Driver result_monad (SharedConfiguration ()) SupervisorConfiguration Identity IO (FoundModeUsingPull result)

the driver for the desired adapter (note that all drivers can be specialized to this type)

-> (RunOutcome (Progress result) (Either result (Progress result)) -> IO ())

a callback that will be invoked with the outcome of the run; note that if the run was Completed then the checkpoint file will be deleted if this function finishes successfully

-> Tree result

the tree to explore

-> result_monad () 

Explore the given pure tree in parallel until the sum of results meets the given condition.

simpleMainForExploreTreeIOUntilFoundUsingPullSource

Arguments

:: (Monoid result, Serialize result, MonadIO result_monad) 
=> (result -> Bool)

a condition function that signals when we have found all of the result that we wanted

-> Driver result_monad (SharedConfiguration ()) SupervisorConfiguration IO IO (FoundModeUsingPull result)

the driver for the desired adapter (note that all drivers can be specialized to this type)

-> (RunOutcome (Progress result) (Either result (Progress result)) -> IO ())

a callback that will be invoked with the outcome of the run; note that if the run was Completed then the checkpoint file will be deleted if this function finishes successfully

-> TreeIO result

the tree to explore in IO

-> result_monad () 

Explore the given IO tree in parallel until the sum of results meets the given condition.

simpleMainForExploreTreeImpureUntilFoundUsingPullSource

Arguments

:: (Monoid result, Serialize result, MonadIO result_monad, Functor m, MonadIO m) 
=> (result -> Bool)

a condition function that signals when we have found all of the result that we wanted

-> (forall β. m β -> IO β)

a function that runs an m action in the IO monad

-> Driver result_monad (SharedConfiguration ()) SupervisorConfiguration m m (FoundModeUsingPull result)

the driver for the desired adapter (note that all drivers can be specialized to this type)

-> (RunOutcome (Progress result) (Either result (Progress result)) -> IO ())

a callback that will be invoked with the outcome of the run; note that if the run was Completed then the checkpoint file will be deleted if this function finishes successfully

-> TreeT m result

the impure tree to explore

-> result_monad () 

Explore the given impure tree in parallel until the sum of results meets the given condition.

Push

For more details, follow this link: LogicGrowsOnTrees.Parallel.Main

simpleMainForExploreTreeUntilFoundUsingPushSource

Arguments

:: (Monoid result, Serialize result, MonadIO result_monad) 
=> (result -> Bool)

a condition function that signals when we have found all of the result that we wanted

-> Driver result_monad (SharedConfiguration ()) SupervisorConfiguration Identity IO (FoundModeUsingPush result)

the driver for the desired adapter (note that all drivers can be specialized to this type)

-> (RunOutcome (Progress result) (Either result (Progress result)) -> IO ())

a callback that will be invoked with the outcome of the run; note that if the run was Completed then the checkpoint file will be deleted if this function finishes successfully

-> Tree result

the tree to explore

-> result_monad () 

Explore the given pure tree in parallel until the sum of results meets the given condition.

simpleMainForExploreTreeIOUntilFoundUsingPushSource

Arguments

:: (Monoid result, Serialize result, MonadIO result_monad) 
=> (result -> Bool)

a condition function that signals when we have found all of the result that we wanted

-> Driver result_monad (SharedConfiguration ()) SupervisorConfiguration IO IO (FoundModeUsingPush result)

the driver for the desired adapter (note that all drivers can be specialized to this type)

-> (RunOutcome (Progress result) (Either result (Progress result)) -> IO ())

a callback that will be invoked with the outcome of the run; note that if the run was Completed then the checkpoint file will be deleted if this function finishes successfully

-> TreeIO result

the tree to explore in IO

-> result_monad () 

Explore the given IO tree in parallel until the sum of results meets the given condition.

simpleMainForExploreTreeImpureUntilFoundUsingPushSource

Arguments

:: (Monoid result, Serialize result, MonadIO result_monad, Functor m, MonadIO m) 
=> (result -> Bool)

a condition function that signals when we have found all of the result that we wanted

-> (forall β. m β -> IO β)

a function that runs an m action in the IO monad

-> Driver result_monad (SharedConfiguration ()) SupervisorConfiguration m m (FoundModeUsingPush result)

the driver for the desired adapter (note that all drivers can be specialized to this type)

-> (RunOutcome (Progress result) (Either result (Progress result)) -> IO ())

a callback that will be invoked with the outcome of the run; note that if the run was Completed then the checkpoint file will be deleted if this function finishes successfully

-> TreeT m result

the impure tree to explore

-> result_monad () 

Explore the given impure tree in parallel until the sum of results meets the given condition.

Utility functions

mainMan :: [ManBlock]Source

The additional entries in the manual explaining log format strings and statistics. If you are not using the Main term info then you should add mainMan to your term information as otherwise the documentation will be incomplete; in particular when using execChoice you will want to use this for each of the modes that corresponds to the supervisor (as logging and statistics are only on the supervisor).

mainParser :: Term α -> TermInfo -> IO αSource

Parse the command line options using the given term and term info (the latter of which has the program name added to it); if successful return the result, otherwise throw an exception.