Exemplo n.º 1
0
        /// <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 ActivationMinimalTransitionSetBuilder(ExecutableModel <TExecutableModel> model, long capacity, 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;

            _transitionBuffer.Resize(capacity * sizeof(CandidateTransition), zeroMemory: false);
            _transitions = (CandidateTransition *)_transitionBuffer.Pointer;

            _targetStateBuffer.Resize(capacity * model.StateVectorSize, zeroMemory: true);
            _targetStateMemory = _targetStateBuffer.Pointer;

            _lookupBuffer.Resize(capacity * sizeof(int), zeroMemory: false);
            _faultsBuffer.Resize(capacity * sizeof(FaultSetInfo), zeroMemory: false);
            _hashedStateBuffer.Resize(capacity * _stateVectorSize, zeroMemory: false);

            _successors = new List <uint>();
            _capacity   = capacity;

            _lookup            = (int *)_lookupBuffer.Pointer;
            _faults            = (FaultSetInfo *)_faultsBuffer.Pointer;
            _hashedStateMemory = _hashedStateBuffer.Pointer;

            for (var i = 0; i < capacity; ++i)
            {
                _lookup[i] = -1;
            }
        }
		/// <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 ActivationMinimalTransitionSetBuilder(RuntimeModel model, long capacity, 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;

			_transitionBuffer.Resize(capacity * sizeof(CandidateTransition), zeroMemory: false);
			_transitions = (CandidateTransition*)_transitionBuffer.Pointer;

			_targetStateBuffer.Resize(capacity * model.StateVectorSize, zeroMemory: true);
			_targetStateMemory = _targetStateBuffer.Pointer;

			_lookupBuffer.Resize(capacity * sizeof(int), zeroMemory: false);
			_faultsBuffer.Resize(capacity * sizeof(FaultSetInfo), zeroMemory: false);
			_hashedStateBuffer.Resize(capacity * _stateVectorSize, zeroMemory: false);

			_successors = new List<uint>();
			_capacity = capacity;

			_lookup = (int*)_lookupBuffer.Pointer;
			_faults = (FaultSetInfo*)_faultsBuffer.Pointer;
			_hashedStateMemory = _hashedStateBuffer.Pointer;

			for (var i = 0; i < capacity; ++i)
				_lookup[i] = -1;
		}
Exemplo n.º 3
0
        private void ConvertTransition(int currentEnrichment, CandidateTransition *transition)
        {
            var targetEnrichment = DeriveNewEnrichment(transition->Formulas, currentEnrichment);

            *(int *)(transition->TargetStatePointer + ExtraBytesOffset) = targetEnrichment;

            var targetStateFormulaSet = DeriveNewStateFormulaSet(transition->Formulas, targetEnrichment);

            transition->Formulas = targetStateFormulaSet;
        }
Exemplo n.º 4
0
		/// <summary>
		///   Initializes a new instance.
		/// </summary>
		/// <param name="stateVectorSize">The size of the state vector in bytes.</param>
		/// <param name="capacity">The maximum number of successors that can be cached.</param>
		public TransitionSetBuilder(int stateVectorSize, long capacity)
		{
			Requires.That(capacity <= (1 << 30), nameof(capacity), $"Maximum supported capacity is {1 << 30}.");

			_stateVectorSize = stateVectorSize;

			_transitionBuffer.Resize(capacity * sizeof(CandidateTransition), zeroMemory: false);
			_transitions = (CandidateTransition*)_transitionBuffer.Pointer;

			_targetStateBuffer.Resize(capacity * _stateVectorSize, zeroMemory: false);
			_targetStateMemory = _targetStateBuffer.Pointer;
		}
Exemplo n.º 5
0
        /// <summary>
        ///   Initializes a new instance.
        /// </summary>
        /// <param name="stateVectorSize">The size of the state vector in bytes.</param>
        /// <param name="capacity">The maximum number of successors that can be cached.</param>
        public StateGraphTransitionSetBuilder(int stateVectorSize, long capacity)
        {
            Requires.That(capacity <= (1 << 30), nameof(capacity), $"Maximum supported capacity is {1 << 30}.");

            _stateVectorSize = stateVectorSize;

            _transitionBuffer.Resize(capacity * sizeof(CandidateTransition), zeroMemory: false);
            _transitions = (CandidateTransition *)_transitionBuffer.Pointer;

            _targetStateBuffer.Resize(capacity * _stateVectorSize, zeroMemory: false);
            _targetStateMemory = _targetStateBuffer.Pointer;
        }
Exemplo n.º 6
0
        private void ConvertTransition(CandidateTransition *transition)
        {
            var targetEnrichment = DeriveNewEnrichment(transition->Formulas);

            *(int *)(transition->TargetStatePointer + ExtraBytesOffset) = targetEnrichment;
        }