public override void Display(Entity champion, CultureConfiguration cfg) { base.Display(champion, cfg); if (champion == null || champion.Mean == double.PositiveInfinity) { return; } var cluster = new Cluster(); cluster.GenerateFromStructure(champion.Genes); double totalSteps = 0; for (int i = features.Count - 1; i >= 0; i--) { var input = features[i].Input; var predictedOutput = features[i].Output; var preditcedOutput = cluster.Querry(input, out long steps); cluster.Nap(); Console.WriteLine($"{input[0]} ^ {input[1]} = {((preditcedOutput != null) ? preditcedOutput[0] : -1):0.00000}"); totalSteps += steps; } totalSteps /= features.Count; Console.WriteLine($"Mean error: {champion.Mean:0.00000} "); Console.WriteLine($"Steps: {totalSteps:0.00} "); Console.SetCursorPosition(0, Console.CursorTop - features.Count - 4); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseRequestLocalization(CultureConfiguration.GetLocalizationOptions()); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); }
private static ILocaleConfiguration CreateAppConfiguration(IComponentContext context) { var configuration = context.Resolve <IConfiguration>(); var result = new CultureConfiguration(); new ConfigureFromConfigurationOptions <ILocaleConfiguration>(configuration.GetSection("Locale")) .Configure(result); return(result); }
public virtual void Display(Entity champion, CultureConfiguration cfg) { if (champion == null || champion.Fitness == double.PositiveInfinity) { Console.WriteLine("T: Train L: Load S: Stop Q: Quit"); Console.SetCursorPosition(0, Console.CursorTop - 1); } else { Console.WriteLine("T: Train S: Stop Q: Quit "); Console.WriteLine($"Last updated: {DateTime.Now.ToLocalTime()}"); } }
/// <summary> /// Register services for MVC and localization including available languages /// </summary> /// <param name="services"></param> public static void AddMvcWithLocalization <TUserDto, TRoleDto, TUser, TRole, TKey, TUserClaim, TUserRole, TUserLogin, TRoleClaim, TUserToken, TUsersDto, TRolesDto, TUserRolesDto, TUserClaimsDto, TUserProviderDto, TUserProvidersDto, TUserChangePasswordDto, TRoleClaimsDto, TUserClaimDto, TRoleClaimDto> (this IServiceCollection services, CultureConfiguration cultureConfiguration) where TUserDto : UserDto <TKey>, new() where TRoleDto : RoleDto <TKey>, new() where TUser : IdentityUser <TKey> where TRole : IdentityRole <TKey> where TKey : IEquatable <TKey> where TUserClaim : IdentityUserClaim <TKey> where TUserRole : IdentityUserRole <TKey> where TUserLogin : IdentityUserLogin <TKey> where TRoleClaim : IdentityRoleClaim <TKey> where TUserToken : IdentityUserToken <TKey> where TUsersDto : UsersDto <TUserDto, TKey> where TRolesDto : RolesDto <TRoleDto, TKey> where TUserRolesDto : UserRolesDto <TRoleDto, TKey> where TUserClaimsDto : UserClaimsDto <TUserClaimDto, TKey> where TUserProviderDto : UserProviderDto <TKey> where TUserProvidersDto : UserProvidersDto <TUserProviderDto, TKey> where TUserChangePasswordDto : UserChangePasswordDto <TKey> where TRoleClaimsDto : RoleClaimsDto <TRoleClaimDto, TKey> where TUserClaimDto : UserClaimDto <TKey> where TRoleClaimDto : RoleClaimDto <TKey> { services.AddSingleton <ITempDataProvider, CookieTempDataProvider>(); services.AddLocalization(opts => { opts.ResourcesPath = ConfigurationConsts.ResourcesPath; }); services.TryAddTransient(typeof(IGenericControllerLocalizer <>), typeof(GenericControllerLocalizer <>)); services.AddTransient <IViewLocalizer, ResourceViewLocalizer>(); services.AddControllersWithViews(o => { o.Conventions.Add(new GenericControllerRouteConvention()); }) #if DEBUG // It is not necessary to re-build the views for new changes .AddRazorRuntimeCompilation() #endif .AddViewLocalization( LanguageViewLocationExpanderFormat.Suffix, opts => { opts.ResourcesPath = ConfigurationConsts.ResourcesPath; }) .AddDataAnnotationsLocalization() .ConfigureApplicationPartManager(m => { m.FeatureProviders.Add(new GenericTypeControllerFeatureProvider <TUserDto, TRoleDto, TUser, TRole, TKey, TUserClaim, TUserRole, TUserLogin, TRoleClaim, TUserToken, TUsersDto, TRolesDto, TUserRolesDto, TUserClaimsDto, TUserProviderDto, TUserProvidersDto, TUserChangePasswordDto, TRoleClaimsDto, TUserClaimDto, TRoleClaimDto>()); }); services.Configure <RequestLocalizationOptions>( opts => { // If cultures are specified in the configuration, use them (making sure they are among the available cultures), // otherwise use all the available cultures var supportedCultureCodes = (cultureConfiguration?.Cultures?.Count > 0 ? cultureConfiguration.Cultures.Intersect(CultureConfiguration.AvailableCultures) : CultureConfiguration.AvailableCultures).ToArray(); if (!supportedCultureCodes.Any()) { supportedCultureCodes = CultureConfiguration.AvailableCultures; } var supportedCultures = supportedCultureCodes.Select(c => new CultureInfo(c)).ToList(); // If the default culture is specified use it, otherwise use CultureConfiguration.DefaultRequestCulture ("en") var defaultCultureCode = string.IsNullOrEmpty(cultureConfiguration?.DefaultCulture) ? CultureConfiguration.DefaultRequestCulture : cultureConfiguration?.DefaultCulture; // If the default culture is not among the supported cultures, use the first supported culture as default if (!supportedCultureCodes.Contains(defaultCultureCode)) { defaultCultureCode = supportedCultureCodes.FirstOrDefault(); } opts.DefaultRequestCulture = new RequestCulture(defaultCultureCode); opts.SupportedCultures = supportedCultures; opts.SupportedUICultures = supportedCultures; }); }
public override void Display(Entity champion, CultureConfiguration cfg) { base.Display(champion, cfg); if (champion == null || champion.Mean == double.PositiveInfinity) { return; } var cluster = new Cluster(); cluster.GenerateFromStructure(champion.Genes); double totalSteps = 0; double[] errorRate = new double[10]; double[] totalElements = new double[10]; for (int i = 0; i < features.Count; i++) { var input = features[i].Input; var expectedOutput = features[i].Output; var preditcedOutput = cluster.Querry(input, out long steps); cluster.Nap(); /* * if (preditcedOutput != null) * errorRate[(int)(expectedOutput[0] * 10)] += (preditcedOutput[0] - expectedOutput[0]) * (preditcedOutput[0] - expectedOutput[0]); * else * errorRate[(int)(expectedOutput[0] * 10)] += 1; * totalElements[(int)(expectedOutput[0] * 10)]++; */ int label = GetLabel(expectedOutput); if (preditcedOutput != null) { int k = 0; for (k = 0; k < preditcedOutput.Count; ++k) { if (preditcedOutput[k] >= preditcedOutput[label] && label != k) { break; } } if (k == preditcedOutput.Count) { errorRate[label]++; } } totalElements[label]++; totalSteps += steps; } totalSteps /= features.Count; for (int i = 0; i < 10; ++i) { // errorRate[i] /= totalElements[i]; //Console.WriteLine($"{i} : {errorRate[i]:0.00000}"); Console.WriteLine($"{i} : {errorRate[i]} / {totalElements[i]} "); } Console.WriteLine($"Mean error: {champion.Mean:0.00000} "); Console.WriteLine($"Features used: {champion.FeaturesUsed} "); Console.WriteLine($"Average steps: {totalSteps:0.00} "); Console.SetCursorPosition(0, Console.CursorTop - 15); }