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;
		}