// ===================================================================================== #endregion public void runOutputs(int i, int ScnCnt, myVariables mine, System.IO.StreamWriter SW) { string ScnName = ""; ScnName = i + ","; // if (ScnCnt == 1) { if (stopHeader) { } else { FO.WriteHeader(ws.SimulationRunResults, mine, sw); } stopHeader = true; } if (FO.WriteResults(ws.SimulationRunResults, ScnName, mine, sw)) { //ScnCnt++; } else { } ws.Simulation_Stop(); }
public bool isOutPutParam(myVariables mine, int theEmp) { bool found = false; //const int OutPutParamN = 2; //int[] eModelParametersForOutput = new int[OutPutParamN] // { // eModelParam.epGroundwater_Pumped_Municipal, // eModelParam.epRegGWpctInitial // }; //foreach (int emp in eModelParametersForOutput) // FO.ParametersForOutput(); foreach (int emp in mine.FOB.eModelParametersForOutput) { if (emp == theEmp) { found = true; break; } } return(found); }
/// <summary> /// /// </summary> /// <param name="SR"></param> /// <param name="SW"></param> /// <returns></returns> public bool WriteHeader(SimulationResults SR, myVariables mine, System.IO.StreamWriter SW) { bool result = false; int FirstYear = SR.StartYear; AnnualSimulationResults ASR = SR.ByYear(FirstYear); string BaseStr = "ID,BUILD,SCN_NAME,SIMYEAR"; //FileOutputsBase fob = this.FOB; // now loop through base outputs and set those try { int index = 0; foreach (int emp in ASR.Outputs.BaseOutputModelParam) { // check if this is one of the output fields if (isOutPutParam(mine, emp)) { ModelParameterClass MP = wsim.ParamManager.Model_Parameter(emp); BaseStr += "," + MP.Fieldname; } index++; } // lopp through base inputs index = 0; foreach (int emp in ASR.Inputs.BaseInputModelParam) { if (isOutPutParam(mine, emp)) { ModelParameterClass MP = wsim.ParamManager.Model_Parameter(emp); BaseStr += "," + MP.Fieldname; } index++; } BaseStr += ",PRVDCODE"; // loop through provider outputs index = 0; foreach (int emp in ASR.Outputs.ProviderOutputModelParam) { // check if for output if (isOutPutParam(mine, emp)) { ModelParameterClass MP = wsim.ParamManager.Model_Parameter(emp); BaseStr += "," + MP.Fieldname; } index++; } // loop through provider inputs index = 0; foreach (int emp in ASR.Inputs.ProviderInputModelParam) { // check if for output if (isOutPutParam(mine, emp)) { ModelParameterClass MP = wsim.ParamManager.Model_Parameter(emp); BaseStr += "," + MP.Fieldname; } index++; } SW.WriteLine(BaseStr); result = true; } finally { SW.Flush(); } return(result); }
public bool WriteResults(SimulationResults SR, string ScenarioName, myVariables mine, System.IO.StreamWriter SW) { bool result = false; string IDS = ""; string build = wsim.ModelBuild; // get the start year int FirstYear = SR.StartYear; // loop through all years in SR for (int yeari = 0; yeari < SR.Length; yeari++) { // Set the calender year int ThisYear = FirstYear + yeari; if (ThisYear < 2060) { // get results for this year AnnualSimulationResults ASR = SR.ByYear(ThisYear); // set the key, the scenario name and the year string BaseStr = RecCount.ToString() + "," + '"' + build + '"' + "," + ScenarioName + ThisYear.ToString(); // now loop through base outputs and set those int index = 0; foreach (int emp in ASR.Outputs.BaseOutputModelParam) { // check if this is one of the output fields if (isOutPutParam(mine, emp)) { BaseStr += "," + ASR.Outputs.BaseOutput.Values[index].ToString(); } index++; } // lopp through base inputs index = 0; foreach (int emp in ASR.Inputs.BaseInputModelParam) { if (isOutPutParam(mine, emp)) { BaseStr += "," + ASR.Inputs.BaseInput.Values[index].ToString(); } index++; } // OK, have all base stuff, now loop through providers eProvider ep = eProvider.Regional; //foreach (eProvider ep in ProviderClass.providersAll()) { // Increment the rec count RecCount++; // set the base string IDS = BaseStr + "," + '"' + ProviderClass.FieldName(ep) + '"'; // loop through provider outputs index = 0; foreach (int emp in ASR.Outputs.ProviderOutputModelParam) { // check if for output if (isOutPutParam(mine, emp)) { if ((ep < eProvider.Regional) || (ASR.Outputs.ProviderOutput[index].IncludesAggregates)) { IDS += "," + ASR.Outputs.ProviderOutput[index].Values[ProviderClass.index(ep, true)].ToString(); } else { IDS += "," + SpecialValues.MissingIntValue.ToString(); } } index++; } // loop through provider inputs index = 0; foreach (int emp in ASR.Inputs.ProviderInputModelParam) { // check if for output if (isOutPutParam(mine, emp)) { if ((ep < eProvider.Regional) || (ASR.Inputs.ProviderInput[index].IncludesAggregates)) { IDS += "," + ASR.Inputs.ProviderInput[index].Values[ProviderClass.index(ep, true)].ToString(); } else { IDS += "," + SpecialValues.MissingIntValue.ToString(); } } index++; } // ok write it out SW.WriteLine(IDS); } // provider } } // year SW.Flush(); result = true; return(result); }
void runWithCSV() { myVariables my = new myVariables(); my.myParameters(); FO = new FileOutputs(ws); SimpleFileCopy SF = new SimpleFileCopy(); int scen = 1; SF.copyScenarioFile(scen); string buid = ws.ModelBuild; ws.Simulation_Initialize(); Init(); //SF.copyScenarioFile(scen); my.Initialize(scen, ws); // 10.26.17 List <string> ProcessList = new List <string>(); ProcessList = ws.ProcessManager.ActiveProcesses; // //isSetError = SetModelParameters(InputFields, ws, ref SetErrMessage); // //ws.Colorado_Climate_Adjustment_Percent = 100; //ws.SaltVerde_Climate_Adjustment_Percent = 100; for (int i = 0; i < ProviderClass.NumberOfProviders; i++) { OneHundred[i] = 20; } myout.Values = OneHundred; ws.WaterAugmentation.setvalues(myout); ws.Simulation_AllYears(); CO = ws.Colorado_Annual_Deliveries.getvalues(); int Col = ws.Colorado_Annual_Deliveries.RegionalValue(eProvider.Regional); //for (int year = ws.Simulation_Start_Year; year < ws.Simulation_End_Year; ++year) //{ // ws.Simulation_NextYear(); // StartSimulation = false; // int Rain = ws.RainWaterHarvested_MF.RegionalValue(eProvider.Regional) + ws.RainWaterHarvested_SF.RegionalValue(eProvider.Regional) // + ws.RainWaterHarvested_PU.RegionalValue(eProvider.Regional); // int Gray = ws.ResGrayWater.RegionalValue(eProvider.Regional); // double Out = ws.PCT_Outdoor_WaterUseRes.RegionalValue(eProvider.Regional); // double res = ws.PCT_WaterSupply_to_Residential.RegionalValue(eProvider.Regional); // double indoor = ws.ResidentialHighDensityIndoorGPCD.RegionalValue(eProvider.Regional) + // ws.ResidentialLowDensityIndoorGPCD.RegionalValue(eProvider.Regional) + // ws.ResidentialMediumDensityIndoorGPCD.RegionalValue(eProvider.Regional); // int odd = year; // if (odd % 2 == 0) // { // sw.WriteLine(year // + "," // + ws.SaltVerde_Annual_Deliveries_SRP.RegionalValue(eProvider.Regional) // +"," // + ws.Colorado_Annual_Deliveries.RegionalValue(eProvider.Regional) // + "," // + ws.Groundwater_Pumped_Municipal.RegionalValue(eProvider.Regional) // + "," // + ws.Groundwater_Bank_Used.RegionalValue(eProvider.Regional) // + "," // + ws.Reclaimed_Water_Used.RegionalValue(eProvider.Regional) // + "," // //+ Rain // //+ "," // //+ Gray // + ws.RainWaterHarvtoTotalOutdoorUse.RegionalValue(eProvider.Regional) // + "," // + ws.GrayWaterToTotalOutdoorUse.RegionalValue(eProvider.Regional) // + "," // + ws.ReclaimedToTotalOutdoorUse.RegionalValue(eProvider.Regional) // //+ ws.ResidentialLowDensityOutdoorGPCD.RegionalValue(eProvider.Regional) // //+ "," // //+ ws.ResidentialLowDensityIndoorGPCD.RegionalValue(eProvider.Regional) // //+ "," // //+ ws.LowDensityDemand.RegionalValue(eProvider.Regional) // //+ "," // //+ ws.MediumDensityDemand.RegionalValue(eProvider.Regional) // //+ "," // //+ ws.HighDensityDemand.RegionalValue(eProvider.Regional) // //+ "," // //+ ws.TurfWaterDemand.RegionalValue(eProvider.Regional) // //+ "," // //+ ws.GreenwayWaterDemand.RegionalValue(eProvider.Regional) // //+ "," // //+ ws.TreeWaterDemand.RegionalValue(eProvider.Regional) // + "," // + ws.Total_Demand.RegionalValue(eProvider.Regional) // //+ ws.ResidentialMediumDensityOutdoorGPCD.RegionalValue(eProvider.Regional) // //+ "," // //+ ws.ResidentialHighDensityOutdoorGPCD.RegionalValue(eProvider.Regional) // //+ "," // //+ ws.Total_Demand.RegionalValue(eProvider.Regional) // //+ "," // //+ ws.LowDensityDemand.RegionalValue(eProvider.Regional) // //+ "," // //+ ws.MediumDensityDemand.RegionalValue(eProvider.Regional) // //+ "," // //+ ws.HighDensityDemand.RegionalValue(eProvider.Regional) // //+ ((Convert.ToDouble(ws.Total_Demand.RegionalValue(eProvider.Regional))/Convert.ToDouble( ws.Population_Used.RegionalValue(eProvider.Regional))) * 325851)/365 // //+ Rain // //+ "," // //+ Gray // //+ "," // //+ ws.Total_Demand.RegionalValue(eProvider.Regional) * Out / 100 * res / 100 // ); // } // else // { // //sw.WriteLine(year // //+ "," // // + ws.Total_Demand.RegionalValue(eProvider.Regional) // // ); // } //} CloseFiles(); sw.Flush(); sw.Close(); }
public void Run() { ScnGenForm(); myVariables my = new myVariables(); my.myParameters(); FO = new FileOutputs(ws); SimpleFileCopy SF = new SimpleFileCopy(); // String Filename = "ScenarioProject.txt"; int ScnCnt = 1; double Count = 1; double traces = FCORTraceN * FSVRTraceN * FGrowthN * FRainN * FEffiency; double total = traces;// *FScenario; sw = new System.IO.StreamWriter(Filename); String File = "ByPass.txt"; swAdd = new System.IO.StreamWriter(File); ProviderIntArray New = new ProviderIntArray(); ProviderIntArray Values = new ProviderIntArray(); for (int i = 0; i < New.Length; i++) { New[i] = 0; } for (int i = 0; i < New.Length; i++) { Values[i] = 50; } if (get_ValidModelRun == true) { // One at a time ------ int scen = 7; SF.copyScenarioFile(scen); // foreach (int st in SVtrace) { foreach (int co in COtrace) { foreach (int rain in RainFall) { foreach (int growth in Growth) { foreach (int eff in Efficiency) { string ScnName = "Base"; RunningGrowth = growth; RunningEff = eff; //if(scen >1) sScenario[scen - 1]; string ver = ws.Model_Version; string buid = ws.ModelBuild; ws.Simulation_Initialize(); Init(); InitSpecial(New, Values); my.Initialize(scen, ws); if (SetParms(st, co, rain, growth, eff)) { string Cstring = DateTime.Now.ToString("h:mm:ss tt") + " In step: " + "--" + Count + " Of: " + total + " > " + (Count / total) * 100 + " %"; Console.WriteLine(Cstring); Console.WriteLine(""); Console.WriteLine("Simulating " + scen + " " + ScnName); simpleRun(); } Count += 1; runOutputs(scen, ScnCnt, my, sw); ws.Simulation_Stop(); } } } } } } CloseFiles(); sw.Flush(); sw.Close(); swAdd.Flush(); swAdd.Close(); }