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