private void AddChoiceOfStepGraph(LtmdpStepGraph stepGraph, int continuationId, long locationForContinuationGraphElement) { var choice = stepGraph.GetChoiceOfCid(continuationId); if (choice.IsChoiceTypeUnsplitOrFinal) { AddFinalChoiceOfStepGraph(continuationId, locationForContinuationGraphElement); return; } var offsetTo = choice.To - choice.From; var numberOfChildren = offsetTo + 1; var placesForChildren = _ltmdp.GetPlaceForNewContinuationGraphElements(numberOfChildren); _ltmdp._continuationGraph[locationForContinuationGraphElement] = new ContinuationGraphElement { ChoiceType = choice.ChoiceType, From = placesForChildren, To = placesForChildren + offsetTo, }; for (var currentChildNo = 0; currentChildNo < numberOfChildren; currentChildNo++) { var originalContinuationId = choice.From + currentChildNo; var newLocation = placesForChildren + currentChildNo; AddChoiceOfStepGraph(stepGraph, originalContinuationId, newLocation); } }
private void CheckIfStepGraphCanBeProcessed(LtmdpStepGraph stepGraph) { // Need to reserve the memory for the transitions var upperBoundaryForStepGraph = _ltmdp._continuationGraphElementCount + stepGraph.Size; if (upperBoundaryForStepGraph < 0 || upperBoundaryForStepGraph >= _ltmdp._maxNumberOfContinuationGraphElements) { throw new OutOfMemoryException("Unable to store transitions. Try increasing the transition capacity."); } }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="runtimeModelCreator">A factory function that creates the model instance that should be executed.</param> /// <param name="successorStateCapacity">The maximum number of successor states supported per state.</param> /// <param name="stateHeaderBytes"> /// The number of bytes that should be reserved at the beginning of each state vector for the model checker tool. /// </param> internal LtmdpExecutedModel(CoupledExecutableModelCreator <TExecutableModel> runtimeModelCreator, int stateHeaderBytes, long successorStateCapacity) : base(runtimeModelCreator, stateHeaderBytes) { var formulas = RuntimeModel.Formulas.Select(formula => FormulaCompilationVisitor <TExecutableModel> .Compile(RuntimeModel, formula)).ToArray(); _stepGraph = new LtmdpStepGraph(); _cachedLabeledStates = new LtmdpCachedLabeledStates <TExecutableModel>(RuntimeModel, successorStateCapacity, _stepGraph, formulas); _ltmdpChoiceResolver = new LtmdpChoiceResolver(_stepGraph); ChoiceResolver = _ltmdpChoiceResolver; RuntimeModel.SetChoiceResolver(ChoiceResolver); }
private void AddStepGraph(LtmdpStepGraph stepGraph, int sourceState, bool areInitialTransitions) { var place = _ltmdp.GetPlaceForNewContinuationGraphElements(1); if (areInitialTransitions) { _ltmdp._indexOfInitialContinuationGraphRoot = place; } else { _ltmdp.SourceStates.Add(sourceState); _ltmdp._stateStorageStateToRootOfContinuationGraphMemory[sourceState] = place; } AddChoiceOfStepGraph(stepGraph, 0, place); }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="model">The model the successors are computed for.</param> /// <param name="capacity">The maximum number of successors that can be cached.</param> /// <param name="formulas">The formulas that should be checked for all successor states.</param> public LtmdpCachedLabeledStates(ExecutableModel <TExecutableModel> model, long capacity, LtmdpStepGraph ltmdpStepGraph, params Func <bool>[] formulas) { Requires.NotNull(model, nameof(model)); Requires.NotNull(formulas, nameof(formulas)); Requires.That(formulas.Length < 32, "At most 32 formulas are supported."); Requires.That(capacity <= (1 << 30), nameof(capacity), $"Maximum supported capacity is {1 << 30}."); _stateVectorSize = model.StateVectorSize; _formulas = formulas; _capacity = capacity; LtmdpStepGraph = ltmdpStepGraph; _transitionsWithContinuationIdBuffer.Resize(capacity * sizeof(LtmdpTransition), zeroMemory: false); _transitionsWithContinuationIdMemory = (LtmdpTransition *)_transitionsWithContinuationIdBuffer.Pointer; _targetStateBuffer.Resize(capacity * model.StateVectorSize, zeroMemory: true); _targetStateMemory = _targetStateBuffer.Pointer; }
/// <summary> /// Initializes a new instance. /// </summary> public LtmdpChoiceResolver(LtmdpStepGraph ltmdpStepGraph) : base() { LtmdpStepGraph = ltmdpStepGraph; }
public DirectChildrenEnumerator(LtmdpStepGraph ltmdpStepGraph, int parentContinuationId) { Choice = ltmdpStepGraph.GetChoiceOfCid(parentContinuationId); CurrentChildContinuationId = Choice.From - 1; ParentContinuationId = parentContinuationId; }