コード例 #1
0
        public IModel Encode()
        {
            //get variable info from ModulesFile
            varList = new VariableList(modules);

            //Collect all sync label of all modules
            synchs = modules.GetAllSynchs().ToList();

            AddVars();

            //Create Expression Encoder, use the same copy of varList, variableEncoding
            expressionEncoder = new ExpressionToBDD(varList, variableEncoding);

            EncodeSystemDef(modules.systemDef);

            // get rid of any nondet dd variables not needed
            if (modules.modelType == ModelType.MDP)
            {
                CUDDNode tmp = CUDD.GetSupport(trans);
                tmp = CUDD.Abstract.ThereExists(tmp, allRowVars);
                tmp = CUDD.Abstract.ThereExists(tmp, allColVars);

                CUDDVars ddv = new CUDDVars();
                while (!tmp.Equals(CUDD.ONE))
                {
                    ddv.AddVar(CUDD.Var(tmp.GetIndex()));
                    tmp = tmp.GetThen();
                }
                CUDD.Deref(tmp);
                allNondetVars.Deref();
                allNondetVars = ddv;
            }

            init = GetInitState();

            //
            CUDD.Deref(moduleRangeDDs, moduleIdentities, colVarRanges, syncVars, choiceVars);
            CUDD.Deref(moduleRowVars, moduleColVars, rowVars, colVars, new List <CUDDVars>()
            {
                globalRowVars, globalColVars, allSynchVars, allChoiceVars
            });

            IModel result;

            if (modules.modelType == ModelType.DTMC)
            {
                //
                allNondetVars.Deref();

                result = new ProbModel(trans, init, stateRewards, transRewards, allRowVars, allColVars, varList, allRowVarRanges,
                                       varIdentities, variableEncoding);
            }
            else
            {
                result = new NonDetModel(trans, init, stateRewards, transRewards, allRowVars, allColVars, allNondetVars,
                                         varList, allRowVarRanges, varIdentities, variableEncoding);
            }

            return(result);
        }
コード例 #2
0
        public NondetModelChecker(NonDetModel model)
            : base(model)
        {
            allNondetVars = model.allNondetVars;

            FilterStates();

            CUDD.Ref(trans01, reach);
            nondetMask = CUDD.Function.And(CUDD.Function.Not(CUDD.Abstract.ThereExists(trans01, allColVars)), reach);

            Debug.WriteLine("States: " + CUDD.GetNumMinterms(reach, allRowVars.GetNumVars()) + " (" + CUDD.GetNumMinterms(start, allRowVars.GetNumVars()) + " initial)");
            Debug.WriteLine("Transitions: " + CUDD.GetNumMinterms(trans01, allRowVars.GetNumVars() * 2 + allNondetVars.GetNumVars()));
            Debug.WriteLine("Transition matrix: " + CUDD.Print.GetInfoString(trans, allRowVars.GetNumVars() * 2 + allNondetVars.GetNumVars()) +
                            ", vars: " + allRowVars.GetNumVars() + "r/" + allColVars.GetNumVars() + "c/" + allNondetVars.GetNumVars() + "nd");
        }