public void AddParameterVariable(Model model) { if (Def.Parameters != null) { for (int i = 0; i < this.Def.Parameters.Length; i++) { string parameter = this.Def.Parameters[i]; int min = Model.BDD_INT_UPPER_BOUND; int max = Model.BDD_INT_LOWER_BOUND; if (this.Def.ParameterLowerBound.ContainsKey(parameter) && this.Def.ParameterUpperLowerBound.ContainsKey(parameter)) { min = this.Def.ParameterLowerBound.GetContainsKey(parameter); max = this.Def.ParameterUpperLowerBound.GetContainsKey(parameter); } else { ExpressionBDDEncoding argumentBDD = Args[i].TranslateIntExpToBDD(model); foreach (CUDDNode argExp in argumentBDD.ExpressionDDs) { min = Math.Min(min, (int)CUDD.FindMinThreshold(argExp, Model.BDD_INT_LOWER_BOUND)); max = Math.Max(max, (int)CUDD.FindMaxThreshold(argExp, Model.BDD_INT_UPPER_BOUND)); } } //Also set the parameter as global variable to make sure that the parameters unchanged in encoding Transition model.AddGlobalVar(parameter, min, max); } } }
/// <summary> /// Add local variable including state, and parameters /// Return the variable name encoding states /// </summary> /// <param name="encoder"></param> public string AddLocalVariables(BDDEncoder encoder) { RenameLocalVars(); for (int i = 0; i < this.Parameters.Count; i++) { string parameter = this.Parameters[i]; int min = Model.BDD_INT_UPPER_BOUND; int max = Model.BDD_INT_LOWER_BOUND; if (ParameterUpperBound.ContainsKey(parameter) && ParameterLowerBound.ContainsKey(parameter)) { min = ParameterLowerBound[parameter]; max = ParameterUpperBound[parameter]; } else { ExpressionBDDEncoding argumentBDD = this.Arguments[i].TranslateIntExpToBDD(encoder.model); foreach (CUDDNode argExp in argumentBDD.ExpressionDDs) { min = Math.Min(min, (int)CUDD.FindMinThreshold(argExp, Model.BDD_INT_LOWER_BOUND)); max = Math.Max(max, (int)CUDD.FindMaxThreshold(argExp, Model.BDD_INT_UPPER_BOUND)); } } //In its old transition encoding, we don't make sure this variable must be unchanged. //We also need to add this variable to VaribleIndex of the AutomataBDD because previous process does not know this variable //if global then later processes will set this variable as unchange. encoder.model.AddLocalVar(parameter, min, max); } const string STATE = "state"; // string processVariableName = Name + Model.NAME_SEPERATOR + STATE + Model.GetNewTempVarName(); encoder.model.AddLocalVar(processVariableName, 0, this.States.Count - 1); // encoder.stateIndexOfCurrentProcess = new Dictionary <string, int>(); //collect the state index foreach (State state in this.States) { encoder.stateIndexOfCurrentProcess.Add(state.Name, encoder.stateIndexOfCurrentProcess.Count); } return(processVariableName); }