private GoalPrioritizingConfiguration ReadGoalPrioritizingConfiguration() { if (CurrentName == "GoalPrioritizing") { var currentLine = new StringReader(CurrentLine); GetNextLine(); var gp = new InputVar <string>("GoalPrioritizing"); ReadValue(gp, currentLine); var goalPrioritizingType = new InputVar <string>("GoalPrioritizingType"); ReadValue(goalPrioritizingType, currentLine); var type = (GoalPrioritizingType)Enum.Parse(typeof(GoalPrioritizingType), goalPrioritizingType.Value); switch (type) { case GoalPrioritizingType.Default: break; case GoalPrioritizingType.VBGP: { var configFile = new InputVar <string>("GoalPrioritizingConfig"); ReadValue(configFile, currentLine); return(new GoalPrioritizingConfiguration { GoalPrioritizingType = GoalPrioritizingType.VBGP, ConfigFile = configFile.Value.String }); } } } return(new GoalPrioritizingConfiguration { GoalPrioritizingType = GoalPrioritizingType.Default, ConfigFile = "" }); }
private List <AgentArchetypeVariable> ReadAgentArchetypeVariables() { SkipUntilConfiguration("AgentArchetypeVariables"); var variableName = new InputVar <string>("VariableName"); var archetypeName = new InputVar <string>("ArchetypeName"); var variableType = new InputVar <string>("VariableType"); var variableValue = new InputVar <string>("VariableValue"); var agentArchetypeVariables = new List <AgentArchetypeVariable>(); while (!CurrentName.Equals("AgentGoalAttributes")) { var currentLine = new StringReader(CurrentLine); var agentArchetypeVariable = new AgentArchetypeVariable(); // 2021-01-21 Archetype name must come first ReadValue(archetypeName, currentLine); agentArchetypeVariable.ArchetypeName = archetypeName.Value; ReadValue(variableName, currentLine); agentArchetypeVariable.VariableName = variableName.Value; ReadValue(variableType, currentLine); agentArchetypeVariable.VariableType = variableType.Value; ReadValue(variableValue, currentLine); agentArchetypeVariable.VariableValue = variableValue.Value; agentArchetypeVariables.Add(agentArchetypeVariable); GetNextLine(); } return(agentArchetypeVariables); }
private List <AgentArchetype> ReadAgentArchetypes() { SkipUntilConfiguration("AgentArchetypeAttributes"); var archetypeName = new InputVar <string>("ArchetypeName"); var archetypePrefix = new InputVar <string>("ArchetypePrefix"); var dataSetOriented = new InputVar <bool>("DataSetOriented"); var goalImportanceAdjusting = new InputVar <bool>("GoalImportanceAdjusting"); var agentArchetypes = new List <AgentArchetype>(); while (!CurrentName.Equals("AgentArchetypeVariables")) { var currentLine = new StringReader(CurrentLine); var agentArchetype = new AgentArchetype(); ReadValue(archetypeName, currentLine); agentArchetype.ArchetypeName = archetypeName.Value; ReadValue(archetypePrefix, currentLine); agentArchetype.ArchetypePrefix = archetypePrefix.Value; ReadValue(dataSetOriented, currentLine); agentArchetype.DataSetOriented = dataSetOriented.Value; ReadValue(goalImportanceAdjusting, currentLine); agentArchetype.GoalImportanceAdjusting = goalImportanceAdjusting.Value; agentArchetypes.Add(agentArchetype); GetNextLine(); } return(agentArchetypes); }
private List <Probability> ReadProbabilities() { SkipUntilConfiguration("ProbabilityAttributes"); var variableParameter = new InputVar <string>("VariableParameter"); var variableType = new InputVar <string>("VariableType"); var fileName = new InputVar <string>("FileName"); var ignoreFirstLine = new InputVar <bool>("IgnoreFirstLine"); var probabilities = new List <Probability>(); while (!string.IsNullOrEmpty(CurrentLine)) { var probability = new Probability(); var currentLine = new StringReader(CurrentLine); ReadValue(variableParameter, currentLine); probability.VariableParameter = variableParameter.Value; ReadValue(variableType, currentLine); probability.VariableType = variableType.Value; ReadValue(fileName, currentLine); probability.FileName = fileName.Value; ReadValue(ignoreFirstLine, currentLine); probability.IgnoreFirstLine = ignoreFirstLine.Value; probabilities.Add(probability); GetNextLine(); } return(probabilities); }
private List <MentalModel> ReadMentalModels() { SkipUntilConfiguration("MentalModelAttributes"); var agentArchetype = new InputVar <string>("AgentArchetype"); var name = new InputVar <string>("Name"); var modifiable = new InputVar <bool>("Modifiable"); var maxNumberOfDecisionOptions = new InputVar <int>("MaxNumberOfDecisionOptions"); var decisionOptionGoalRelationship = new InputVar <string>("DecisionOptionGoalRelationship"); var associatedWithGoals = new InputVar <string>("AssociatedWithGoals"); var consequentValueRange = new InputVar <string>("ConsequentValueRange"); var consequentRound = new InputVar <int>("ConsequentRound"); // Debugger.Launch(); var mentalModels = new List <MentalModel>(); while (CurrentName != "DecisionOptionAttributes") { var stringReader = new StringReader(CurrentLine); var mentalModel = new MentalModel(); ReadValue(agentArchetype, stringReader); mentalModel.AgentArchetype = agentArchetype.Value; ReadValue(name, stringReader); mentalModel.Name = name.Value; ReadValue(modifiable, stringReader); mentalModel.Modifiable = modifiable.Value; ReadValue(maxNumberOfDecisionOptions, stringReader); mentalModel.MaxNumberOfDecisionOptions = maxNumberOfDecisionOptions.Value; ReadValue(decisionOptionGoalRelationship, stringReader); mentalModel.DecisionOptionGoalRelationship = decisionOptionGoalRelationship.Value; ReadValue(associatedWithGoals, stringReader); mentalModel.AssociatedWithGoals = associatedWithGoals.Value; if (stringReader.Index < CurrentLine.Length) { ReadValue(consequentValueRange, stringReader); mentalModel.ConsequentValueRange = consequentValueRange.Value; ReadValue(consequentRound, stringReader); mentalModel.ConsequentRound = consequentRound.Value; } mentalModels.Add(mentalModel); GetNextLine(); } return(mentalModels); }
private List <GoalAttribute> ReadGoalAttributes() { SkipUntilConfiguration("GoalAttributes"); var agentArchetype = new InputVar <string>("AgentArchetype"); var goalName = new InputVar <string>("Goal"); var goalTendency = new InputVar <string>("GoalTendency"); var referenceVariable = new InputVar <string>("ReferenceVariable"); var changeValueOnPrior = new InputVar <bool>("ChangeValueOnPrior"); var isCumulative = new InputVar <bool>("IsCumulative"); var focalValueReferenceVariable = new InputVar <string>("FocalValueReferenceVariable"); var goals = new List <GoalAttribute>(); while (CurrentName != "MentalModelAttributes") { var currentLine = new StringReader(CurrentLine); var goal = new GoalAttribute(); ReadValue(agentArchetype, currentLine); goal.AgentArchetype = agentArchetype.Value; ReadValue(goalName, currentLine); goal.Name = goalName.Value; ReadValue(goalTendency, currentLine); goal.Tendency = (GoalTendency)Enum.Parse(typeof(GoalTendency), goalTendency.Value); ReadValue(referenceVariable, currentLine); goal.ReferenceVariable = referenceVariable.Value; ReadValue(changeValueOnPrior, currentLine); goal.ChangeValueOnPrior = changeValueOnPrior.Value; ReadValue(isCumulative, currentLine); goal.IsCumulative = isCumulative.Value; ReadValue(focalValueReferenceVariable, currentLine); goal.FocalValueReferenceVariable = focalValueReferenceVariable.Value == "-" ? "" : focalValueReferenceVariable.Value; goals.Add(goal); GetNextLine(); } return(goals); }
//read biomass coefficients from a file into matrix, (float) BioMassData(int ID,2). No Return Value //Read a ID first from the file, and ID is the size of BioMassData; //Read the two variable in to BioMassData(v1,v2) protected override BiomassParam Parse() { ReadLandisDataVar(); InputVar <int> speciesnum = new InputVar <int>("Number_of_species_class"); ReadVar(speciesnum); SpeciesParameters.biomass_util.SetBiomassNum(speciesnum.Value.Actual); InputVar <float> biomassThreshold = new InputVar <float>("minimum_DBH_for_calculating_biomass"); ReadVar(biomassThreshold); SpeciesParameters.biomass_util.BiomassThreshold = biomassThreshold.Value.Actual; InputVar <float> float_val = new InputVar <float>("V0 or V1 value for each species"); for (int i = 1; i <= speciesnum.Value.Actual; i++) { if (AtEndOfInput) { throw NewParseException("Expected a line here"); } Landis.Utilities.StringReader currentLine = new Landis.Utilities.StringReader(CurrentLine); ReadValue(float_val, currentLine); SpeciesParameters.biomass_util.SetBiomassData(i, 1, float_val.Value.Actual); ReadValue(float_val, currentLine); SpeciesParameters.biomass_util.SetBiomassData(i, 2, float_val.Value.Actual); //CheckNoDataAfter("the Ecoregion " + float_val + " column", // currentLine); GetNextLine(); } return(null); }