// // CHANGED QUAY was WaterSim.WaterSimU _ws public static void RangeCheckWaterSupply(WaterSimU _ws) { ProviderIntArray One = new ProviderIntArray(0); // default variable must be placed in the first and second position string tag = "Water Supply to various: parameters-"; int pdefault1 = 70; int pdefault2 = 20; int[] Res = new int[numModeledProviders]; int[] Com = new int [numModeledProviders]; int[] Ind = new int[numModeledProviders]; for (int num = 0; num < numModeledProviders; ++num) { RangeCheckTwo_twoDefaults(num, set_parmWaterSupplyToResPct, set_parmWaterSupplyToComPct, pdefault1, pdefault2, tag); // } for (int i = 0; i < numModeledProviders; i++) { Res[i] = set_parmWaterSupplyToResPct[i]; Com[i] = set_parmWaterSupplyToComPct[i]; Ind[i] = set_parmWaterSupplyToIndPct[i]; } for (int j = 0; j < numModeledProviders; j++) { _ws.parmWaterSupplyToResPct[j] = Res[j]; _ws.parmWaterSupplyToComPct[j] = Com[j]; _ws.parmWaterSupplyToIndPct[j] = Ind[j]; } }
//================================================== //Total Supply // ----------------------------------------------------------- private int[] get_TotalSupply() { ProviderIntArray TSA = new ProviderIntArray(0); // get all supplies int[] GW = Groundwater_Pumped_Municipal.getvalues().Values; int[] Salt = SaltVerde_Annual_Deliveries_SRP.getvalues().Values; int[] Coldo = Colorado_Annual_Deliveries.getvalues().Values; int[] GWBank = Groundwater_Bank_Used.getvalues().Values; int[] Reclaimed = Reclaimed_Water_Used.getvalues().Values; int[] ROReclaimed = RO_Reclaimed_Water_Used.getvalues().Values; int[] AugWater = WaterAugmentationUsed.getvalues().Values; // 08.21.16 das // int[] RainHarvested = RainWaterHarvested.getvalues().Values; for (int i = 0; i < TSA.Length; i++) { int TS = 0; //TS = GW[i] + Salt[i] + Coldo[i] + GWBank[i] + Reclaimed[i] + ROReclaimed[i] + AugWater[i] + RainHarvested[i]; TS = GW[i] + Salt[i] + Coldo[i] + GWBank[i] + Reclaimed[i] + ROReclaimed[i] + AugWater[i]; TSA[i] = TS; //TotalSupply[i] = TS; } return(TSA.Values); // TotalSupply.Values; }
///------------------------------------------------------------------------------------------------- /// <summary> Constructor. </summary> /// /// <remarks> Ray, 12/7/2011. </remarks> /// /// <param name="pm"> The Paramerter Manager </param> /// <param name="modelparam"> The emodelparam value </param> /// <param name="DefaultValues"> The default values. </param> ///------------------------------------------------------------------------------------------------- public ShadowProviderArrayProperty(ParameterManagerClass pm, int modelparam, ProviderIntArray DefaultValues) { Fpm = pm; Femp = modelparam; Defaults = DefaultValues; Values = Defaults; }
private int[] get_FutureYearsSustainedPumping() { ProviderIntArray FYSP = new ProviderIntArray(); ProviderIntArray Balance = new ProviderIntArray(); ProviderIntArray Pumped = new ProviderIntArray(); Balance = Groundwater_Balance.getvalues(); Pumped = Groundwater_Pumped_Municipal.getvalues(); foreach (eProvider ep in ProviderClass.providers()) { int yrs = 0; if (Pumped[ep] > 0) { if (Balance[ep] > 0) { yrs = Balance[ep] / Pumped[ep]; } else { yrs = 0; } } else { yrs = 100; } if (yrs > 100) { yrs = 100; } FYSP[ep] = yrs; } return(FYSP.Values); }
// internal bool parameterZeroOut(ModelParameterBaseClass MP, MyParameterInfo MPC) { ModelParameterClass TheMP = ws.ParamManager.Model_Parameter(MP.Fieldname); bool result = true; int[] Data = new int[33]; for (int j = 0; j < 33; j++) { Data[j] = 0; } switch (TheMP.ParamType) { case modelParamtype.mptInputBase: TempParam.Value = Data[0]; break; case modelParamtype.mptInputProvider: ProviderIntArray PData = new ProviderIntArray(); PData.Values = Data; TheMP.ProviderProperty.setvalues(PData); break; } int data = 0; for (int j = 0; j < 33; j++) { MPC.Data[j] = 0; } return(result); }
// ===================================================================================== void InitSpecial(ProviderIntArray one, ProviderIntArray two) { ws.PCT_Reclaimed_Outdoor_Use.setvalues(one); ws.PCT_Wastewater_Reclaimed.setvalues(one); ws.PCT_Reclaimed_to_Water_Supply.setvalues(two); ws.RainFallFactor = 100; }
private int[] get_CreditDeficit_Years() { ProviderIntArray temp = new ProviderIntArray(0); for (int i = 0; i < temp.Length; i++) { temp.Values[i] = CountList_2.Values[i]; } return(temp.Values); }
///------------------------------------------------------------------------------------------------- /// <summary> Constructor. </summary> /// <param name="modelparam"> The emodelparam value. </param> ///------------------------------------------------------------------------------------------------- public ShadowProviderArrayProperty(int modelparam) { Femp = modelparam; Defaults = new ProviderIntArray(0); for (int i = 0; i < Defaults.Length; i++) { Defaults[i] = 0; } Values = Defaults; }
//================================================== // Projected Population //------------------------------------------------- private int[] get_Projected_Pop() { int year = Sim_CurrentYear; ProviderIntArray Pop = new ProviderIntArray(0); for (int i = 0; i < Pop.Length; i++) { Pop[i] = PopData.GetYearPopData(year).Values[i]; } return(Pop.Values); }
static public void ManagePolicies(WaterSimManager WSim, int year, ProviderIntArray BeingManaged, ProviderIntArray TriggerCnt) { for (int i = 0; i < 2; i++) { if (0 < BeingManaged[i]) { } else { } } }
//========================================================= //Count of Years during which Groundwater can not neet Assured Supply rule. //--------------------------------------- private int[] get_Years_Negative() { ProviderIntArray YearsNegative = new ProviderIntArray(0); // get deficit and demand for (int i = 0; i < YearsNegative.Length; i++) { YearsNegative[i] = FYearsNegative[i]; } return(YearsNegative.Values); }
//========================================================= //Years of GW zero or Below //--------------------------------------- private int[] get_YearsOfZero() { ProviderIntArray YearsOfZero = new ProviderIntArray(0); // get deficit and demand for (int i = 0; i < YearsOfZero.Length; i++) { YearsOfZero[i] = FYearsOfZeroOrBelow[i]; } return(YearsOfZero.Values); }
private int[] get_Year_CreditsGoNegative() { ProviderIntArray FYEAR_Credits = new ProviderIntArray(0); // get deficit and demand for (int i = 0; i < FYEAR_Credits.Length; i++) { FYEAR_Credits[i] = FYearCreditsGoNeg[i]; } return(FYEAR_Credits.Values); }
//========================================================= //Percent Credits water Available //--------------------------------------- private int[] get_PCT_CreditsAvail() { ProviderIntArray FPCT_GW = new ProviderIntArray(0); // get deficit and demand for (int i = 0; i < FPCT_GW.Length; i++) { FPCT_GW[i] = FPctCreditsAvail[i]; } return(FPCT_GW.Values); }
///------------------------------------------------------------------------------------------------- /// <summary> Initializes the data. </summary> /// <param name="Years"> The years. </param> /// <param name="StartYear"> the AnnualSimulationResults . </param> /// <param name="SimResults"> The simulation results. </param> /// <param name="IncludeAggregates"> true to include, false to exclude the aggregates. </param> ///------------------------------------------------------------------------------------------------- internal void initializeData(int Years, int StartYear, ref SimulationResults SimResults, bool IncludeAggregates) { if ((SimResults != null) && (Years == (SimResults.LastYear - SimResults.StartYear) + 1)) // if not new then zero it out from last use Added 5 22 12 { // Only supporting Aggregates in Output right now ProviderIntArray OutBlank = new ProviderIntArray(0, IncludeAggregates); ProviderIntArray InBlank = new ProviderIntArray(0, false); for (int yr = 0; yr < Years; yr++) { AnnualSimulationResults TheASR = SimResults[yr]; int cnt = 0; cnt = ParamManager.NumberOfParameters(modelParamtype.mptOutputBase); for (int parmi = 0; parmi < cnt; parmi++) { TheASR.Outputs.BaseOutput[parmi] = 0; TheASR.Outputs.BaseOutputModelParam[parmi] = -1; } cnt = 0; cnt = ParamManager.NumberOfParameters(modelParamtype.mptOutputProvider); for (int parmi = 0; parmi < cnt; parmi++) { TheASR.Outputs.ProviderOutput[parmi] = OutBlank; TheASR.Outputs.ProviderOutputModelParam[parmi] = -1; } cnt = 0; cnt = ParamManager.NumberOfParameters(modelParamtype.mptInputBase); for (int parmi = 0; parmi < cnt; parmi++) { TheASR.Inputs.BaseInput[parmi] = 0; TheASR.Inputs.BaseInputModelParam[parmi] = -1; } cnt = 0; cnt = ParamManager.NumberOfParameters(modelParamtype.mptInputProvider); for (int parmi = 0; parmi < cnt; parmi++) { TheASR.Inputs.ProviderInput[parmi] = InBlank; TheASR.Inputs.ProviderInputModelParam[parmi] = -1; } } } else { SimResults = new SimulationResults(Years, StartYear, ParamManager.NumberOfParameters(modelParamtype.mptOutputBase), ParamManager.NumberOfParameters(modelParamtype.mptOutputProvider), ParamManager.NumberOfParameters(modelParamtype.mptInputBase), ParamManager.NumberOfParameters(modelParamtype.mptInputProvider), IncludeAggregates); } }
///------------------------------------------------------------------------------------------------- /// <summary> Method that is called before each annual run. </summary> /// <param name="year"> The year about to be run. </param> /// <param name="WSim"> The WaterSimManager that is making call. </param> /// <returns> true if it succeeds, false if it fails. Error should be placed in FErrorMessage. /// </returns> ///------------------------------------------------------------------------------------------------- public override bool PreProcess(int year, WaterSimManagerClass WSimClass) { WaterSimManager WSim = (WSimClass as WaterSimManager); // ProviderIntArray NewPopOff = new ProviderIntArray(0); bool TempLock = WSim.isLocked(); WSim.UnLockSimulation(); //bool ManagingPop = false; // for 2000 to 2010 just grab the projections if (year < 2015) { } //WSim.Simulation_Start_Year + 1)) else { ProviderIntArray YearForZero = WSim.ParamManager.Model_ParameterBaseClass(eModelParam.epYearCreditsGoesNeg).ProviderProperty.getvalues(); ProviderIntArray IsTriggered = new ProviderIntArray(0); // Check which are in unassured year range for (int i = 0; i < YearForZero.Length; i++) { if (TestPolicy(YearForZero[i], (WSim as WaterSimManager))) { ConsecutiveDeficitYears[i]++; if (ConsecutiveDeficitYears[i] > Max_Years_Deficit_Trigger) { IsTriggered[i] = 1; // Once triggered always being managed BeingManaged[i] = 1; } } else { ConsecutiveDeficitYears[i] = 0; } } PolicyClass.ManagePolicies(WSim, year, BeingManaged, IsTriggered); //PopulationClass.LimitAndReallocateGrowth(WSim, year, BeingManaged, IsTriggered, FMaxUnassuredYears, ref NewPopOn, ref NewPopOff); } // Ok Set PopOverride Values // for (int i = 0; i < NewPopOn.Length; i++) // { // WSim.Population_Override_On[i] = NewPopOn[i]; // } // for (int i = 0; i < NewPopOff.Length; i++) // { // WSim.Population_Override_Other[i] = NewPopOff[i]; // } // if (TempLock) WSim.LockSimulation(); return(base.PreProcess(year, WSim)); }
///------------------------------------------------------------------------------------------------- /// <summary> Method called when Sumulation is stopped. </summary> /// <param name="WSim"> The simulation. </param> /// <returns> true if it succeeds, false if it fails. </returns> ///------------------------------------------------------------------------------------------------- public override bool ProcessStop(WaterSimManagerClass WSimClass) { WaterSimManager WSim = (WSimClass as WaterSimManager); // Reset Pop Overide ProviderIntArray Reset = new ProviderIntArray(-1); WSim.Population_Override_On.setvalues(Reset); WSim.Population_Override_Other.setvalues(Reset); return(base.ProcessStop(WSim)); }
//================================================== // POP Difference From Projected Population //------------------------------------------------- private int[] get_Difference_Projected_Pop() { int year = Sim_CurrentYear; ProviderIntArray PopDiff = new ProviderIntArray(0); for (int i = 0; i < PopDiff.Length; i++) { PopDiff[i] = Population_Used[i] - PopData.GetYearPopData(year).Values[i]; } return(PopDiff.Values); }
//========================================================= //Count of Years during which Groundwater can not neet Assured Supply rule. //--------------------------------------- private int[] get_Years_NotAssured() { ProviderIntArray YearsNotAssured = new ProviderIntArray(0); // get deficit and demand for (int i = 0; i < YearsNotAssured.Length; i++) { YearsNotAssured[i] = FYearsNotAssured[i]; } return(YearsNotAssured.Values); }
bool LoadPopDataFile(string DataPathName, ref string errString, ref List <ProviderIntArray> PopByYearList) { bool test = true; string MyErrString = ""; List <UniDB.Tools.DynamicTextData> DataList = new List <UniDB.Tools.DynamicTextData>(); List <string> DataLines = new List <string>(); DataLines = UniDB.Tools.ReadLinesFromTextFile(DataPathName, ref MyErrString); if (MyErrString != "") { test = false; errString = MyErrString; } int linecnt = 0; foreach (string line in DataLines) { if (line.Length > 0) { int cnt = 0; int index = 0; ProviderIntArray DataYear = new ProviderIntArray(0); DataList.Clear(); DataList = UniDB.Tools.FetchDataFromTextLine(line, UniDB.Tools.DataFormat.SpaceDelimited); foreach (UniDB.Tools.DynamicTextData dtd in DataList) { if (WaterSimU.ProvNameIndicies[cnt] > -1) { if (dtd.CanBeInt()) { DataYear.Values[index] = dtd.ValueInt; } index++; } cnt++; } if (index != ProviderClass.NumberOfProviders) { test = false; errString += " Line " + linecnt.ToString() + " Field Cnt = " + cnt.ToString(); } PopByYearList.Add(DataYear); } linecnt++; } return(test); }
public void SetData() { switch (TheMP.ParamType) { case modelParamtype.mptInputBase: TheMP.Value = Data[0]; break; case modelParamtype.mptInputProvider: ProviderIntArray PData = new ProviderIntArray(); PData.Values = Data; TheMP.ProviderProperty.setvalues(PData); break; } }
public void SetModelParameterValue() { if (FMP != null) { double HoldCurrentValue = FCurrentValue; try { if (FMP.isBaseParam) { // The event of change value is unreliable, only occurs when focus is lost force change FCurrentValue = (double)numericUpDownParAM.Value; FMP.Value = (int)FCurrentValue; } else if (FMP.isProviderParam) { if (!FChangeAllValues) { // The event of change value is unreliable, only occurs when focus is lost force change FCurrentValue = (double)numericUpDownParAM.Value; int[] CurrentValues = FMP.ProviderProperty.getvalues().Values; CurrentValues[FregionIdex] = (int)FCurrentValue; ProviderIntArray Temp = new ProviderIntArray(); Temp.Values = CurrentValues; FMP.ProviderProperty.setvalues(Temp); } else { FCurrentValue = (double)numericUpDownParAM.Value; int[] CurrentValues = FMP.ProviderProperty.getvalues().Values; for (int i = 0; i < CurrentValues.Length; i++) { CurrentValues[i] = (int)FCurrentValue; } ProviderIntArray Temp = new ProviderIntArray(); Temp.Values = CurrentValues; FMP.ProviderProperty.setvalues(Temp); } } } catch { // numericUpDownParAM.Value = (decimal)HoldCurrentValue; numericUpDownParAM.BackColor = Color.LightCoral; } } }
//============================================================ // Percent Reclaimed of Total Supply //--------------------------------------------- #region private int[] get_PCT_Reclaimed_Of_Total() { ProviderIntArray FPCT_Rec = new ProviderIntArray(0); // get deficit and demand ProviderIntArray PTotal = Total_Water_Supply_Used.getvalues(); ProviderIntArray PRec = Total_Reclaimed_Used.getvalues(); for (int i = 0; i < PRec.Length; i++) { // caculated percent as integer 100=100% if (PTotal[i] > 0) { FPCT_Rec[i] = (PRec[i] * 100) / PTotal[i]; } } return(FPCT_Rec.Values); }
//================================================== //Total Effluent //------------------------------------------------- private int[] get_Total_Effluent() { ProviderIntArray TSA = new ProviderIntArray(0); // get deficit and demand int[] EffluentUsed = Total_Effluent_Reused.getvalues().Values; int[] get_EffluentDischarged = Effluent_Discharged.getvalues().Values; for (int i = 0; i < TSA.Length; i++) { int TS = 0; TS = (EffluentUsed[i] + get_EffluentDischarged[i]); TSA[i] = TS; //TotalSupply[i] = TS; } return(TSA.Values); // TotalSupply.Values; }
//================================================== //Total Reclaimed Water //------------------------------------------------- private int[] get_Reclaimed_Used() { ProviderIntArray TSA = new ProviderIntArray(0); // get deficit and demand int[] Reclaimed = Reclaimed_Water_Used.getvalues().Values; int[] ROReclaimed = RO_Reclaimed_Water_Used.getvalues().Values; for (int i = 0; i < TSA.Length; i++) { int TS = 0; TS = Reclaimed[i] + ROReclaimed[i]; TSA[i] = TS; //TotalSupply[i] = TS; } return(TSA.Values); // TotalSupply.Values; }
// end of Personal Indicator //========================================================= //Percent Deficit // THIS NEEDS CHANGING!!!!! // DAS 09.24.15... this is demand deficit //--------------------------------------- #region private int[] get_PCT_Deficit() { ProviderIntArray FPCT_Deficit = new ProviderIntArray(0); // get deficit and demand int[] PDeficit = Demand_Deficit.getvalues().Values; int[] PDemand = Total_Demand.getvalues().Values; for (int i = 0; i < FPCT_Deficit.Length; i++) { // caculated percent as integer 100=100% if (PDemand[i] > 0) { FPCT_Deficit[i] = (PDeficit[i] * 100) / PDemand[i]; } } return(FPCT_Deficit.Values); }
//================================================== //Effluent To Ag //------------------------------------------------- private int[] get_Effluent_To_Ag() { ProviderIntArray TSA = new ProviderIntArray(0); // get deficit and demand int[] Effluent = Total_Effluent_Reused.getvalues().Values; int[] Power = Effluent_To_PowerPlant.getvalues().Values; int[] Vadose = Effluent_To_Vadose.getvalues().Values; for (int i = 0; i < TSA.Length; i++) { int TS = 0; TS = Effluent[i] - (Power[i] + Vadose[i]); TSA[i] = TS; //TotalSupply[i] = TS; } return(TSA.Values); // TotalSupply.Values; }
//================================================== //Percent GW of demand //------------------------------------------------- private int[] get_PCT_GWofDemand() { ProviderIntArray GWofDemand = new ProviderIntArray(0); // get deficit and demand int[] GWPumped = Groundwater_Pumped_Municipal.getvalues().Values; int[] PDemand = Total_Demand.getvalues().Values; for (int i = 0; i < GWofDemand.Length; i++) { // caculated percent as integer 100=100% // DAS added the double and moved the *100 if (PDemand[i] > 0) { GWofDemand[i] = Convert.ToInt32((Convert.ToDouble(GWPumped[i])) / (Convert.ToDouble(PDemand[i])) * 100); } } return(GWofDemand.Values); }
//---------------------------------------------------- /// <summary> /// This is the ProcessMethod that keeps track of Deficits by provider /// </summary> /// <param name="year">Simulation Year (not used)</param> /// <param name="WSim">The WaterSimManager object (used to get data)</param> /// <returns></returns> override public bool PostProcess(int year, WaterSimManagerClass WSimClass) { WaterSimManager WSim = (WSimClass as WaterSimManager); ProviderIntArray Deficits = new ProviderIntArray(); ProviderIntArray CreditDeficits = new ProviderIntArray(); // get the deficit data Deficits = WSim.Demand_Deficit.getvalues(); CreditDeficits = WSim.AF_water_CreditDeficits.getvalues(); foreach (eProvider ep in ProviderClass.providers()) { if (Deficits[ep] > FMaxDeficit) { CountList[ep]++; TotalList[ep] += Deficits[ep]; ContinuousList[ep]++; if (LongestContinuous[ep] < ContinuousList[ep]) { LongestContinuous[ep] = ContinuousList[ep]; } } else { ContinuousList[ep] = 0; } // if (CreditDeficits[ep] > FMaxCreditDeficit) { CountList_2[ep]++; TotalList_2[ep] += CreditDeficits[ep]; ContinuousList_2[ep]++; if (LongestContinuous_2[ep] < ContinuousList_2[ep]) { LongestContinuous_2[ep] = ContinuousList_2[ep]; } } } return(true); }
//================================================== // POP Percent Difference From Projected Population //------------------------------------------------- private int[] get_PCTDifference_Projected_Pop() { int year = Sim_CurrentYear; ProviderIntArray PopDiff = new ProviderIntArray(0); ProviderIntArray PopPCTDiff = new ProviderIntArray(0); for (int i = 0; i < PopDiff.Length; i++) { PopDiff[i] = Population_Used[i] - PopData.GetYearPopData(year).Values[i]; int pu = Population_Used[i]; if (pu == 0) { PopPCTDiff[i] = 100; } else { PopPCTDiff[i] = (PopDiff[i] * 100) / Population_Used[i]; } } return(PopPCTDiff.Values); }