private static Ages CalcAge(DateTime dteBirth, out int intAge) { Ages age = Ages.Year; intAge = 0; com.digitalwave.iCare.middletier.HIS.clsOPDoctorPlanSvc objSvc = (com.digitalwave.iCare.middletier.HIS.clsOPDoctorPlanSvc)com.digitalwave.iCare.common.clsObjectGenerator.objCreatorObjectByType(typeof(com.digitalwave.iCare.middletier.HIS.clsOPDoctorPlanSvc)); DateTime dteNow = DateTime.Now; int intYear = dteBirth.Year; int intMonth = dteBirth.Month; int intDay = dteBirth.Day; if ((dteNow.Year - intYear) > 0) { intAge = dteNow.Year - intYear; age = Ages.Year; } else if ((dteNow.Month - intMonth) > 0) { intAge = dteNow.Month - intMonth; age = Ages.Month; } else { intAge = dteNow.Day - intDay; age = Ages.Day; } return(age); }
public AgeResponse CreateAgeResponse(List <AgeEN> pAges) { AgeResponse response = new AgeResponse(); Ages ages = new Ages(); ages.agesListModel = new List <AgesListModel>(); foreach (var agesListModel in pAges) { AgesListModel _agesListModel = new AgesListModel(); _agesListModel.ageID = agesListModel.AgeID; _agesListModel.name = agesListModel.Name; _agesListModel.status = agesListModel.Status; _agesListModel.iconImage = agesListModel.IconImage; _agesListModel.mainImage = agesListModel.MainImage; ages.agesListModel.Add(_agesListModel); } response.ages = ages; response.count = ages.agesListModel.Count; return(response); }
static void Main(string[] args) { //var adding = true; while (true) { Ages newAge = new Ages(); Console.WriteLine("How old are you?"); newAge.Age = (int.Parse(Console.ReadLine())); if (newAge.Age < 18) { throw new ArithmeticException("Access denied - You must be at least 18 years old."); //adding = false; break; } else { Console.WriteLine("Access granted - You are old enough!"); //adding = false break; } } }
public IEnumerable <RuminantTypeCohort> GetCohorts(RuminantInitialCohorts initials) { List <RuminantTypeCohort> list = new List <RuminantTypeCohort>(); int index = Breeds.IndexOf((initials.Parent as RuminantType).Breed); var cohorts = GetElementNames(Numbers).Skip(1); foreach (string cohort in cohorts) { double num = GetValue <double>(Numbers.Element(cohort), index); if (num <= 0) { continue; } list.Add(new RuminantTypeCohort(initials) { Name = cohort, Number = num, Age = GetValue <int>(Ages.Element(cohort), index), Weight = GetValue <double>(Weights.Element(cohort), index), Gender = cohort.Contains("F") ? 1 : 0, Suckling = cohort.Contains("Calf") ? true : false, Sire = cohort.Contains("ire") ? true : false }); } return(list.AsEnumerable()); }
private void lstPersons_SelectionChanged(object sender, SelectionChangedEventArgs e) { ClearControls(); if (lstPersons.SelectedItem != null) { Person person = (Person)lstPersons.SelectedItem; txtName.Text = person.Name; txtFirstname.Text = person.Firstname; //lblAge.Content = person.GetAge(); lblAge.Content = Ages.AgeInYearsMonthDays(person.DayOfBirth); dtpDayOfBirth.SelectedDate = person.DayOfBirth; if (person.Gender == 'M') { rdbMale.IsChecked = true; } else if (person.Gender == 'F') { rdbFemale.IsChecked = true; } else { rdbUnkown.IsChecked = true; } lblWeight.Content = person.Weight + " kg"; } }
public RegistrationViewModel(ApplicationManager appManager) { _appManager = appManager; _countriesRepository = new CountriesRepository(); SelectedCountry = Countries.First(); SelectedSex = Sexes.First(); SelectedAge = Ages.First(); }
private void Test_PolynomialGA(Func <double, double> func) { int polynomialOrder = 5; int populationSize = 500; int sampleCount = 100; int genCount = 5000; Random rng = new Random(0); var pop = Enumerable .Range(0, populationSize) .Select(i => new CartesianIndividual(polynomialOrder, rng)) .Cast <IIndividual>() .ToList(); double[] xRange = Enumerable .Range(0, sampleCount) .Select(i => (double)i / 100) .ToArray(); double[][] allPowsOfX = new double[sampleCount][]; for (int i = 0; i < allPowsOfX.Length; ++i) { allPowsOfX[i] = new double[polynomialOrder]; double powX = 1; for (int j = 0; j < allPowsOfX[i].Length; ++j) { allPowsOfX[i][j] = powX; powX *= xRange[i]; } } double[] expectedValues = xRange .Select(i => func(i)) .ToArray(); Utils.SetRandomSeed(0); var ages = new Ages(genCount, new Evaluate((i) => ((CartesianIndividual)i).PolynomialEval(allPowsOfX, expectedValues)), CartesianIndividual.CrossOver, new Generate((r) => new CartesianIndividual(polynomialOrder, r)), pop); ages.NicheStrat = new NicheDensityStrategy( ages, (l, r) => CartesianIndividual.Distance((CartesianIndividual)l, (CartesianIndividual)r)); ages.GoThroughGenerations(); for (int i = 0; i < 4; ++i) { int ix = (ages.Champions.Count / 4) * i; Log.Info(ages.Champions[ix]); } Log.Info(ages.Champions.Last()); }
private void SearchJobs() { DataTable dataTable = GetResumes(ddlCertificate.SelectedValue, dllSalarylevel.SelectedValue, ddlLocation.SelectedValue, ddlCatelogy.SelectedValue, dllJobPosition.SelectedValue, ddlExperienceLevel.SelectedValue, ddlWorktype.SelectedValue, "0", ddlLangSkill.SelectedValue, ddlSex.SelectedValue); var fromyear = Convert.ToInt32(DateTime.Now.Year) - Convert.ToInt32(txtToAge.Text); var toyear = Convert.ToInt32(DateTime.Now.Year - Convert.ToInt32(txtFromAge.Text)); Session["SearchResult"] = dataTable; Session["Ages"] = new Ages(fromyear, toyear); }
static void Main(string[] args) { var pop = new List <IIndividual>(32); Console.WriteLine("Read from file individuals?(y/n)"); var yayornay = Console.ReadLine(); if (yayornay == "y") { Console.WriteLine("File path"); var path = Console.ReadLine(); string [] strArr = null; try{ strArr = File.ReadAllLines(path); } catch (Exception e) { Console.WriteLine(e.Message); Console.ReadKey(false); Environment.Exit(1); } foreach (var str in strArr) { Console.WriteLine("Read " + str); if (str.Trim() == string.Empty) { continue; } pop.Add(new GotchaIndividual(str)); } } else { Console.WriteLine("Creating individuals"); for (var ii = 0; ii < 32; ++ii) { pop.Add(new GotchaIndividual()); } } Ages myGA = new Ages( 1000, new CompareEvaluate(Evaluate), GotchaIndividual.GarboCrossoverOperator, (r) => new GotchaIndividual(), pop); myGA.SetRandomSeed(0); myGA.GoThroughGenerations(); Console.ReadKey(); }
public void AgeTest() { var dat = A.Fake <DateTimeProvider>(); A.CallTo(() => dat.Now).Returns(new DateTime(2001, 1, 1)); var age = new Ages(new DateTime(2000, 1, 1)); var age1 = A.Fake <Ages>(); A.CallToSet(() => age1.SetDT).Returns(new DateTime(2001, 1, 1)); var age2 = A.Dummy <Ages>(); Assert.AreEqual(1, age.age); }
/// <summary> /// Try to find the next age for a given age. Return false if there is no next age /// (in which case, the Hybrasyl year simply increments without end) /// </summary> /// <param name="age"></param> /// <param name="nextAge"></param> /// <returns></returns> public bool TryGetNextAge(HybrasylAge age, out HybrasylAge nextAge) { nextAge = null; if (Ages.Count == 1) { return(false); } // Find the age of the day after the start date. This (again) assumes the // user hasn't done something doltish like having non-contiguous ages var after = age.StartDate + new TimeSpan(1, 0, 0, 0); nextAge = Ages.FirstOrDefault(a => a.DateInAge(after)); return(nextAge != null); }
/// <summary> /// Try to find the previous age for a given age. Return false if there is no previous age /// (in which case, a Hybrasyl date before the beginning of the age is simply a negative year) /// </summary> /// <param name="age"></param> /// <param name="previousAge"></param> /// <returns></returns> public bool TryGetPreviousAge(HybrasylAge age, out HybrasylAge previousAge) { previousAge = null; if (Ages.Count == 1) { return(false); } // Find the age of the day before the start date. This assumes the // user hasn't done something doltish like having non-contiguous ages var before = age.StartDate - new TimeSpan(1, 0, 0, 0); previousAge = Ages.FirstOrDefault(a => a.DateInAge(before)); return(previousAge != null); }
public HybrasylAge GetAgeFromTerranDatetime(DateTime datetime) { if (Ages.Count == 0) { return(DefaultAge); } else if (Ages.Count == 1) { return(Ages.First()); } else { return(Ages.First(a => a.DateInAge(datetime))); } }
public void Dropdown_IndexChanged(int index) { Ages name = (Ages)index; YearsSelected.text = name.ToString(); ResponseAge = YearsSelected.text; ExportQ.SetAge(ResponseAge); if (index == 0) { YearsSelected.color = Color.red; } else { YearsSelected.color = Color.white; } }
public ViewResult StartPage(Ages ag) { if (ModelState.IsValid) { ag.dt = DateTime.Now; ag.left = ag.RetireAge - ag.Age; ag.dt2 = ag.dt.AddYears(ag.left); return(View("Next", ag)); } else { return(View()); } }
public NicheDensityStrategy(Ages parent, Distance distance, bool keepHistory = true) { _distance = distance; _parent = parent; _RadiusAdjustPower = Math.Log(_RadiusAdjustMaxFactor * _RadiusAdjustMaxFactor) / Math.Log(_parent.EliminateIndexBegin); _RadiusAdjustMinFactor = 1 / _RadiusAdjustMaxFactor; NicheRadius = 1; NichePenaltyFactor = 0.0010; KeepHistory = keepHistory; if (KeepHistory) { _Generation = 0; _HistoryRadius = new List <double>(); _HistoryNicheCount = new List <double>(); _HistoryNicheAverageDensity = new List <double>(); _HistoryNicheStandardDeviation = new List <double>(); } }
private async void SendCommandTapped(object obj) { try { if (!IsBusy) { IsBusy = true; bool result = await _pushService.SendPushNotifications(new PushMessageDto { Ages = Ages.Where(x => x.Selected).Select(x => x.Value).ToList(), Image = Image, Genders = Genders.Where(x => x.Selected).Select(x => x.Value).ToList(), Date = DateTime.Now, Description = Message, SelectRandom = Random, Tag = Tags.Where(x => x.Selected).Select(x => x.Value).ToList(), Title = $"Notificación enviada por {_userService.GetLastUser().Username}" }); if (result) { Clean(); } else { await _dialogService.DisplayAlertAsync("Error", "No se pudo enviar la notificación", "Cerrar"); } } } catch (Exception e) { await _dialogService.DisplayAlertAsync("Error", e.Message, "Cerrar"); } finally { IsBusy = false; } }
/// <summary> /// 计算年龄 /// </summary> /// <param name="dteBirth">出生日期</param> /// <returns></returns> private static string CalcAge(DateTime dteBirth) { int intAge = 0; string strAge = ""; Ages age = Ages.Year; age = CalcAge(dteBirth, out intAge); switch (age) { case Ages.Year: strAge = intAge.ToString(); break; case Ages.Month: strAge = intAge.ToString() + "个月"; break; case Ages.Day: strAge = intAge.ToString() + "天"; break; } return(strAge); }
public int GetTotalSubmissions() { return(Ages.Count()); }
public double GetAverageAge() { return(Ages.Average()); }
private void Test_PolynomialGA(Func <double, double> func) { //Settings bool adaptive = false; int seed = 0; Utils.SetRandomSeed(seed); var rng = new Random(seed); PolynomialOrder = 5; int populationSize = 100; //number of samples to use the in the polynomial approx // to test the differnce double start = -10, end = 10; //Step between the samples double step = 0.02; //Number of generations to bundle int genBundleCount = 10; //Stop at Gen GenerationStop = 500; //Get Data for tests double[] xRange, expectedValues; GetFofXForRange(func, start, step, end, out xRange, out expectedValues); double[][] allPowsOfX = GetPowersOfX(xRange, PolynomialOrder); ExpectedValsX = xRange; ExpectedValsY = expectedValues; PowsOfXForAllX = allPowsOfX; //Create Delegates Evaluate eval = (i) => ((CartesianIndividual)i).PolynomialEval(allPowsOfX, expectedValues); CrossOver crossOver = adaptive ? AdaptiveCartesianIndividual.CrossOver : (CrossOver)CartesianIndividual.CrossOver; Generate generate = adaptive ? (Generate)((r) => new AdaptiveCartesianIndividual(PolynomialOrder, 1, r: r, emptySigma: true)) : (r) => new CartesianIndividual(PolynomialOrder, 1, r); // Generate Population List <IIndividual> pop; pop = Enumerable .Range(0, populationSize) .Select(i => generate(rng)) .Cast <IIndividual>() .ToList(); Ages = new Ages(genBundleCount, eval, crossOver, generate, pop); Ages.SetRandomSeed(seed); Ages.NicheStrat = new NicheDensityStrategy( Ages, (l, r) => CartesianIndividual.Distance((CartesianIndividual)l, (CartesianIndividual)r)); }
public Ages.EvaluatedIndividual Generation() { Ages.GoThroughGenerations(); Ages.EvaluatedIndividual champ = Ages.Champions.Last(); return(champ); }