Exemplo n.º 1
0
        /// <summary>
        ///   Adds a transition to the <paramref name="model" />'s current state.
        /// </summary>
        /// <param name="model">The model the transition should be added for.</param>
        /// <param name="continuationId">The id of the transition.</param>
        public void Add(ExecutableModel <TExecutableModel> model, int continuationId)
        {
            if (_transitionsWithContinuationIdCount >= _capacity)
            {
                throw new OutOfMemoryException("Unable to store an additional transition. Try increasing the successor state capacity.");
            }

            // 1. Notify all fault activations, so that the correct activation is set in the run time model
            //    (Needed to persist persistent faults)
            model.NotifyFaultActivations();

            // 2. Serialize the model's computed state; that is the successor state of the transition's source state
            //    _including_ any changes resulting from notifications of fault activations
            var successorState = _targetStateMemory + _stateVectorSize * _transitionsWithContinuationIdCount;

            model.Serialize(successorState);

            // 3. Store the transition
            var activatedFaults      = FaultSet.FromActivatedFaults(model.NondeterministicFaults);
            var positionOfTransition = _transitionsWithContinuationIdCount;

            _transitionsWithContinuationIdMemory[positionOfTransition] = new LtmdpTransition
            {
                TargetStatePointer = successorState,
                Formulas           = new StateFormulaSet(_formulas),
                ActivatedFaults    = activatedFaults,
                Flags = TransitionFlags.IsValidFlag,
                Index = positionOfTransition
            };
            ++_transitionsWithContinuationIdCount;
            LtmdpStepGraph.SetTargetOfFinalOrUnsplitChoice(continuationId, positionOfTransition);
        }
        /// <summary>
        ///   Adds a transition to the <paramref name="model" />'s current state.
        /// </summary>
        /// <param name="model">The model the transition should be added for.</param>
        /// <param name="probability">The probability of the transition.</param>
        public void Add(ExecutableModel <TExecutableModel> model, double probability)
        {
            if (_count >= _capacity)
            {
                throw new OutOfMemoryException("Unable to store an additional transition. Try increasing the successor state capacity.");
            }

            // 1. Notify all fault activations, so that the correct activation is set in the run time model
            //    (Needed to persist persistent faults)
            model.NotifyFaultActivations();

            // 2. Serialize the model's computed state; that is the successor state of the transition's source state
            //    _including_ any changes resulting from notifications of fault activations
            var successorState = _targetStateMemory + _stateVectorSize * _count;

            model.Serialize(successorState);

            // 3. Store the transition
            var activatedFaults = FaultSet.FromActivatedFaults(model.NondeterministicFaults);

            _transitions[_count] = new LtmcTransition
            {
                TargetStatePointer = successorState,
                Formulas           = new StateFormulaSet(_formulas),
                ActivatedFaults    = activatedFaults,
                Flags       = TransitionFlags.IsValidFlag,
                Probability = probability
            };
            ++_count;
        }
Exemplo n.º 3
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;
            }
        }
Exemplo n.º 4
0
 public RunCmd(ExecutableModel exe)
 {
     this.Exe = exe;
     Exe.Path = Exe.Path.Replace("%user%", Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
     Exe.Path = Exe.Path.Replace("%windir%", Environment.GetFolderPath(Environment.SpecialFolder.Windows));
     Exe.Path = Exe.Path.Replace("%Dropbox%", Environment.GetEnvironmentVariable("Dropbox", EnvironmentVariableTarget.User));
 }
Exemplo n.º 5
0
        private void doneBtn_Click(object sender, EventArgs e)
        {
            // Save settings.

            SettingsModal data = new SettingsModal();

            foreach (ListViewItem item in ScriptCommandList.Items)
            {
                CommandModel cmd = new CommandModel();
                cmd.Name       = item.SubItems[0].Text;
                cmd.Help       = item.SubItems[1].Text;
                cmd.SourceCode = item.SubItems[2].Text;
                data.Commands.Add(cmd);
            }

            foreach (ListViewItem item in ExecutablesList.Items)
            {
                ExecutableModel exe = new ExecutableModel();
                exe.Name      = item.SubItems[0].Text;
                exe.Path      = item.SubItems[1].Text;
                exe.Arguments = item.SubItems[2].Text;
                data.Executables.Add(exe);
            }

            SettingsManager.SaveSettings(data);

            DialogResult = DialogResult.OK;
            Close();
        }
Exemplo n.º 6
0
        public ActionResult Executable(ExecutableModel model)
        {
            if (ModelState.IsValid)
            {
                service.SaveExecutable(model);
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
        /// <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 LtmcTransitionSetBuilder(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;
            _capacity        = capacity;

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

            _targetStateBuffer.Resize(capacity * model.StateVectorSize, zeroMemory: true);
            _targetStateMemory = _targetStateBuffer.Pointer;
        }
Exemplo n.º 8
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 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;
        }
Exemplo n.º 9
0
        /// <summary>
        ///   Adds a transition to the <paramref name="model" />'s current state.
        /// </summary>
        /// <param name="model">The model the transition should be added for.</param>
        /// <param name="probability">The probability of the transition.</param>
        public void Add(ExecutableModel <TExecutableModel> model, double probability)
        {
            _totalCount++;

            // 1. Notify all fault activations, so that the correct activation is set in the run time model
            //    (Needed to persist persistent faults)
            model.NotifyFaultActivations();

            // 2. Serialize the model's computed state; that is the successor state of the transition's source state
            //    _including_ any changes resulting from notifications of fault activations
            var temporaryState = _temporalStateStorage.ZeroedSpecialAddress1();

            model.Serialize(temporaryState);

            // 3. Store the transition
            var activatedFaults = FaultSet.FromActivatedFaults(model.NondeterministicFaults);

            AddTransition(temporaryState, new StateFormulaSet(_formulas), activatedFaults, probability);
        }
Exemplo n.º 10
0
        /// <summary>
        ///   Adds a transition to the <paramref name="model" />'s current state.
        /// </summary>
        /// <param name="model">The model the transition should be added for.</param>
        public void Add(ExecutableModel <TExecutableModel> model)
        {
            if (_count >= _capacity)
            {
                throw new OutOfMemoryException("Unable to store an additional transition. Try increasing the successor state capacity.");
            }

            ++_computedCount;

            // 1. Serialize the model's computed state; that is the successor state of the transition's source state
            //    modulo any changes resulting from notifications of fault activations
            var successorState  = _targetStateMemory + _stateVectorSize * _count;
            var activatedFaults = FaultSet.FromActivatedFaults(model.NondeterministicFaults);

            model.Serialize(successorState);

            // 2. Make sure the transition we're about to add is activation-minimal
            if (!Add(successorState, activatedFaults))
            {
                return;
            }

            // 3. Execute fault activation notifications and serialize the updated state if necessary
            if (model.NotifyFaultActivations())
            {
                model.Serialize(successorState);
            }

            // 4. Store the transition
            _transitions[_count] = new CandidateTransition
            {
                TargetStatePointer = successorState,
                Formulas           = new StateFormulaSet(_formulas),
                ActivatedFaults    = activatedFaults,
                Flags = TransitionFlags.IsValidFlag,
            };
            ++_count;
        }
Exemplo n.º 11
0
        public void SaveExecutable(ExecutableModel model)
        {
            var json = JsonConvert.SerializeObject(model);

            File.WriteAllText(configurationService.GetExecutableFilePath(model.Name), json);
        }