private void AddTransitionConsolidate(byte *stateToAdd, StateFormulaSet formulas, FaultSet activatedFaults, double probability) { // Try to find a matching transition. If not found, then add a new one var successorState = AddStateConsolidate(stateToAdd); for (var i = 0; i < _count; i++) { var candidateTransition = _transitions[i]; if (candidateTransition.TargetStatePointer == successorState && candidateTransition.Formulas == formulas //&& //candidateTransition.ActivatedFaults == activatedFaults ) { candidateTransition.Probability += probability; _transitions[i] = candidateTransition; return; } } if (_count >= _capacity) { throw new OutOfMemoryException("Unable to store an additional transition. Try increasing the successor state capacity."); } _transitions[_count] = new LtmcTransition { TargetStatePointer = successorState, Formulas = formulas, //ActivatedFaults = activatedFaults, Flags = TransitionFlags.IsValidFlag, Probability = probability }; ++_count; }
public void AddTransition(int targetState, double probability, StateFormulaSet formulas) { // Try to find a matching transition. If not found, then add a new one var state = AddState(targetState); for (var i = 0; i < _transitionCount; i++) { var candidateTransition = _transitions[i]; if (candidateTransition.TargetStatePointer == state && candidateTransition.Formulas == formulas) { candidateTransition.Probability += probability; _transitions[i] = candidateTransition; return; } } Requires.That(_transitionCount < _capacity, "more space needed"); _transitions[_transitionCount] = new LtmcTransition { TargetStatePointer = state, Formulas = formulas, ActivatedFaults = new FaultSet(), Flags = TransitionFlags.IsValidFlag, Probability = probability }; ++_transitionCount; }
private void AddTransition(byte *stateToAdd, StateFormulaSet formulas, FaultSet activatedFaults, double probability) { if (_consolidateOnTheFly) { AddTransitionConsolidate(stateToAdd, formulas, activatedFaults, probability); } else { if (_count >= _capacity) { throw new OutOfMemoryException("Unable to store an additional transition. Try increasing the successor state capacity."); } var successorState = _temporalStateStorage.GetFreeTemporalSpaceAddress(); MemoryBuffer.Copy(stateToAdd, successorState, _temporalStateStorage.StateVectorSize); _transitions[_count] = new LtmcTransition { TargetStatePointer = successorState, Formulas = formulas, //ActivatedFaults = activatedFaults, Flags = TransitionFlags.IsValidFlag, Probability = probability }; ++_count; } }
private void UpdateNormalizedFormulaSatisfactionCount(StateFormulaSet evaluatedCompilableFormulas) { for (var i = 0; i < NormalizedFormulas.Length; i++) { if (evaluatedCompilableFormulas[i]) { NormalizedFormulaSatisfactionCount[i]++; } } }
private StateFormulaSet DeriveNewStateFormulaSet(StateFormulaSet oldStateFormulaSet, int newEnrichment) { var evaluatedStateFormulas = new bool[_newFormulaEvaluators.Length]; for (var i = 0; i < _newFormulaEvaluators.Length; i++) { var setNewBit = _newFormulaEvaluators[i](oldStateFormulaSet, newEnrichment); evaluatedStateFormulas[i] = setNewBit; } return(new StateFormulaSet(evaluatedStateFormulas)); }
private StateFormulaSet DeriveNewStateFormulaSet(StateFormulaSet oldStateFormulaSet) { var evaluatedStateFormulas = new bool[_formulas.Length]; for (var i = 0; i < _formulas.Length; i++) { var setNewBit = _formulaInStateTransitionEvaluators[i](oldStateFormulaSet); evaluatedStateFormulas[i] = setNewBit; } return(new StateFormulaSet(evaluatedStateFormulas)); }
public void CreateArtificalStateFormula() { var indexOfArtificialStateFormula = _nmdp.StateFormulaLabels.Length; Requires.That(indexOfArtificialStateFormula < 32, "Too many formulas. Cannot create a state formula for artificial states during the mdp transformation"); var satisfiedOnlyInNewIndexArray = new bool[indexOfArtificialStateFormula + 1]; satisfiedOnlyInNewIndexArray[indexOfArtificialStateFormula] = true; //other values already initialized to false _stateFormulaSetforArtificialState = new StateFormulaSet(satisfiedOnlyInNewIndexArray); FormulaForArtificalState = new AtomarPropositionFormula(); MarkovDecisionProcess.StateFormulaLabels = _nmdp.StateFormulaLabels.Concat(new[] { FormulaForArtificalState.Label }).ToArray(); }
private int DeriveNewEnrichment(StateFormulaSet oldStateFormulaSet) { int newEnrichment = 0; for (var i = 0; i < _newEnrichmentEvaluator.Length; i++) { var setNewBit = _newEnrichmentEvaluator[i](oldStateFormulaSet); if (setNewBit) { newEnrichment |= 1 << i; } } return(newEnrichment); }
/// <summary> /// Adds a transition to the <paramref name="successorState" /> to the set. /// </summary> /// <param name="successorState">The successor state of the transition that should be added.</param> /// <param name="activatedFaults">The faults activated by the transition that should be added.</param> /// <param name="formulas">The formulas holding in the successor state of the transition that should be added.</param> public void Add(byte* successorState, FaultSet activatedFaults, StateFormulaSet formulas) { var targetState = _targetStateMemory + _count * _stateVectorSize; MemoryBuffer.Copy(successorState, targetState, _stateVectorSize); _transitions[_count] = new CandidateTransition { TargetState = targetState, Formulas = formulas, ActivatedFaults = activatedFaults, IsValid = true, }; ++_count; }
internal void CreateTransition(bool[] isFormulaSatisfied, byte *targetState, double p) { var transition = _transitionCount; _transitionCount++; _transitions[transition] = new LtmcTransition { Probability = p }; var t = _transitions + transition; t->TargetStatePointer = targetState; t->Formulas = new StateFormulaSet(isFormulaSatisfied); t->Flags = TransitionFlags.IsValidFlag | TransitionFlags.IsStateTransformedToIndexFlag; t->ActivatedFaults = new FaultSet(); }
/// <summary> /// Adds a transition to the <paramref name="successorState" /> to the set. /// </summary> /// <param name="successorState">The successor state of the transition that should be added.</param> /// <param name="activatedFaults">The faults activated by the transition that should be added.</param> /// <param name="formulas">The formulas holding in the successor state of the transition that should be added.</param> public void Add(byte *successorState, FaultSet activatedFaults, StateFormulaSet formulas) { var targetState = _targetStateMemory + _count * _stateVectorSize; MemoryBuffer.Copy(successorState, targetState, _stateVectorSize); _transitions[_count] = new CandidateTransition { TargetStatePointer = targetState, Formulas = formulas, ActivatedFaults = activatedFaults, Flags = TransitionFlags.IsValidFlag, }; ++_count; }
private void CreateTransition(bool isFormulaSatisfied, int targetStateIndex, int continuationId, double p) { var transition = _transitionCount; _transitionCount++; _transitions[transition] = new LtmdpTransition { Probability = p, ContinuationId = continuationId }; var t = (Transition *)(_transitions + transition); t->SourceStateIndex = 0; t->TargetStateIndex = targetStateIndex; t->Formulas = new StateFormulaSet(new Func <bool>[] { () => isFormulaSatisfied }); t->Flags = TransitionFlags.IsValidFlag | TransitionFlags.IsStateTransformedToIndexFlag; t->ActivatedFaults = new FaultSet(); }
internal void CreateTransition(bool[] isFormulaSatisfied, int targetStateIndex, int continuationId) { var transition = _transitionCount; _transitionCount++; _transitions[transition] = new LtmdpTransition { Index = transition }; var t = (Transition *)(_transitions + transition); t->SourceStateIndex = 0; t->TargetStateIndex = targetStateIndex; t->Formulas = new StateFormulaSet(isFormulaSatisfied); t->Flags = TransitionFlags.IsValidFlag | TransitionFlags.IsStateTransformedToIndexFlag; t->ActivatedFaults = new FaultSet(); StepGraph.SetTargetOfFinalOrUnsplitChoice(continuationId, transition); }
private void AddTransition(byte *stateToAdd, StateFormulaSet formulas, FaultSet activatedFaults, double probability) { if (_consolidateOnTheFly) { AddTransitionConsolidate(stateToAdd, formulas, activatedFaults, probability); } else { var successorState = _temporalStateStorage.GetFreeTemporalSpaceAddress(); MemoryBuffer.Copy(stateToAdd, successorState, _temporalStateStorage.StateVectorSize); _transitions[_count] = new LtmcTransition { TargetStatePointer = successorState, Formulas = formulas, //ActivatedFaults = activatedFaults, Flags = TransitionFlags.IsValidFlag, Probability = probability }; ++_count; } }
protected void CheckConsistencyAfterInitialization() { StateFormulaSet.CheckFormulaCount(AtomarPropositionFormulas.Length); }
internal void SetStateLabeling(int markovChainState, StateFormulaSet formula) { StateLabeling[markovChainState] = formula; }
internal StateStorageEntry(StateFormulaSet formula, int stateStorageState) { Formula = formula; StateStorageState = stateStorageState; }
public int ColumnToState(int state) => state; //Do nothing! Just here to make the algorithms more clear. internal void SetStateLabeling(int state, StateFormulaSet formula) { StateLabeling[state] = formula; }
public EnrichedTargetState(int targetState, StateFormulaSet formulas) { TargetState = targetState; Formulas = formulas; }
private void AddEvaluatedCompilableFormulas(SimulationTraceStep step, StateFormulaSet evaluatedCompilableFormulas) { step.EvaluatedNormalizedFormulas = evaluatedCompilableFormulas; }