public Int32 Generation = 0; // номер поколоения, к которому относятся ОРД #endregion Fields #region Constructors public SharedDataInfo(OracleConnection Connection, FileLogger Log, string UpdatePath, UInt32 UpdateBlockSize, CardScriptPluginsInfo CardScripts) : this() { this.Log = Log; // Порядок создания важен. Не менять! this.CardScripts = CardScripts == null ? new CardScriptPluginsInfo(Connection, this) : CardScripts; // this - for Log PCParameters = new PCParametersInfo(Connection); Owners = new OwnersInfo(Connection, this); ProcessingCenters = new ProcessingCentersInfo(Connection, this); // this - for Owners, PCParameters Calc = new ScriptCalculations(ProcessingCenters.Current.Parameters.RoundingMethod); Devices = new DevicesInfo(Connection); DevicesGroups = new DevicesGroupsInfo(Connection, this); // this for Devices Networks = new NetworksInfo(Connection, this); // this - for Owners, DevicesGroups Currencies = new CurrenciesInfo(Connection); TimeOffsetPeriods = new TimeOffsetPeriodsInfo(Connection); Regions = new RegionsInfo(Connection, this); // this - for Currencies RetailSystems = new RetailSystemsInfo(Connection, this); // this - for Owners ServicePoints = new ServicePointsInfo(Connection, this); // this - for Regions, Networks, Retail systems Terminals = new TerminalsInfo(Connection, this); // this - for Service points, Devices ProductGoods = new LogicalProductGoodsInfo(Connection, this); // this - for Retail systems ProductGroups = new LogicalProductGroupsInfo(Connection); MeasureUnits = new MeasureUnitsInfo(Connection); Products = new LogicalProductsInfo(Connection, this); // this - for Groups, MeasureUnits Purses = new PursesInfo(this); Statuses = new CardStatusesInfo(Connection); Parameters = new ParametersInfo(Connection); // параметры скриптов обработки карты ParameterSets = new ParameterSetsInfo(Connection, this); // this - for Calc, CardScripts Counters = new CountersInfo(Connection, this); // this - for Calc Graduations = new GraduationsInfo(Connection, this); // this - for Calc, Products, ProductGroups, Counters GraduationGroups = new GraduationGroupsInfo(Connection, this); // this - for Graduations Tariffs = new TariffsInfo(Connection, this); // this - for Calc, GraduationGroups, Graduations CardRanges = new CardRangesInfo(Connection, this); // this - for ProcessingCenters DataElements = new DataElementsInfo(Connection, this); // this - for Owners EventActionTypes = new EventActionTypesInfo(Connection); Events = new EventsInfo(Connection, this); // this - for Owners, Counters, EventActionTypes EmailProviders = new EmailProvidersInfo(Connection, this); // this - for Owners SMSProviders = new SMSProvidersInfo(Connection, this); // this - for Owners DBVersion = new OnlineDBVersion(Connection, this); // this - for ProcessingCenters.Current this.UpdatePath = UpdatePath; this.UpdateBlockSize = UpdateBlockSize; }
static void Main(string[] args) { var timeStr = DateTime.Now.Hour.ToString("D2") + DateTime.Now.Minute.ToString("D2"); var nodeParamsDeserialize = new ParametersSerializer<NodeParameters>(); var psoParamsDeserialize = new ParametersSerializer<PsoParameters>(); var nodeParams = nodeParamsDeserialize.Deserialize("nodeParams.xml"); var psoParams = psoParamsDeserialize.Deserialize("psoParams.xml"); MachineManager machineManager = new MachineManager(nodeParams.Ip, nodeParams.Ports.ToArray(), nodeParams.NrOfVCpu); if (nodeParams.PeerAddress != null) { try { machineManager.Register(nodeParams.PeerAddress); } catch (Exception e) { Console.WriteLine("Unexpected error occured. Plase try to connect once again."); return; } Console.WriteLine("Working..."); Console.WriteLine("Press ENTER to finish"); ConsoleKeyInfo pressed = new ConsoleKeyInfo(); while (pressed.Key != ConsoleKey.Enter) { pressed = Console.ReadKey(); }; } else { if (args.Length < 3) { Console.WriteLine("CocoClusterApp <Dim1[,Dim2,Dim3...]> <FunctionsFrom> <FunctionsTo> <Budget>"); return; } var dims = args[0]; var functionsFrom = int.Parse(args[1]); var functionsTo = int.Parse(args[2]); var budgetMultiplier = int.Parse(args[3]); var randomGenerator = RandomGenerator.GetInstance(RandomSeed); CocoLibraryWrapper.cocoSetLogLevel("warning"); var functionsToOptimize = new List<string>(); for (var i = functionsFrom; i <= functionsTo; i++) { functionsToOptimize.Add(string.Format("f{0:D3}", i)); } Console.WriteLine("Press any key on the keyboard when ready..."); Console.ReadKey(); Console.WriteLine("Running the example experiment... (might take time, be patient)"); try { /* Set some options for the observer. See documentation for other options. */ var observerOptions = "result_folder: " + String.Format("{0}P_{1}G", psoParams.ParticleIterationsToRestart, psoParams.PsoIterationsToRestart) + " algorithm_name: PSO" + " algorithm_info: \"A simple Random search algorithm\""; /* Initialize the suite and observer */ var suite = new Suite("bbob", "year: 2016", "dimensions: " + dims); var observer = new Observer("bbob", observerOptions); var benchmark = new Benchmark(suite, observer); /* Iterate over all problems in the suite */ var evalLogger = new EvaluationsLogger(); PsoServiceLocator.Instance.Register<EvaluationsLogger>(evalLogger); var fileLogger = new FileLogger("evals.csv"); fileLogger.Log("function_id,gpu_evals,cpu_evals,gpu/cpu"); int instanceCounter = 0; while ((Problem = benchmark.getNextProblem()) != null) { instanceCounter = (instanceCounter + 1) % 15; if(instanceCounter == 0) { evalLogger.RestartCounters(); } var restarts = -1; FitnessFunction function; if (!functionsToOptimize.Contains(Problem.FunctionNumber)) continue; var settings = SetupOptimizer(psoParams, out function); var evaluations = (long) settings.FunctionParameters.Dimension * budgetMultiplier; var evaluationsLeft = evaluations; do { restarts++; settings.Iterations = (int)Math.Ceiling(evaluations / ((double)settings.Particles.Sum(pc => pc.Count))); //var sendParams = new PsoParameters() //{ // Iterations = psoParams.Iterations, // TargetValueCondition = psoParams.TargetValueCondition, // IterationsLimitCondition = psoParams.IterationsLimitCondition, // PsoIterationsToRestart = psoParams.PsoIterationsToRestart, // ParticleIterationsToRestart = psoParams.ParticleIterationsToRestart, // Epsilon = psoParams.Epsilon, // FunctionParameters = psoParams.FunctionParameters, // ParticlesCount = 20, // Particles = new ParticlesCount[1] { new ParticlesCount(PsoParticleType.Standard, 20)} //}; machineManager.StartPsoAlgorithm(psoParams); machineManager.GetResult(); var evalsDone = Problem.getEvaluations(); evaluationsLeft = evaluations - evalsDone; } while (!Problem.isFinalTargetHit() && evaluationsLeft > 0 ); evalLogger.IncreaseCpuEvals((int)Problem.getEvaluations()); Console.WriteLine("{0} | {1} evaluations | {2} restarts | {3:e} BestEval ", Problem.Id, Problem.getEvaluations(), restarts, function.BestEvaluation.FitnessValue[0]); if(instanceCounter == 14) { fileLogger.Log(String.Format("{0},{1},{2},{3}", Problem.Id.Substring(5,4), evalLogger._cpuEvaluations, evalLogger._gpuEvaluations, evalLogger.Ratio)); } } fileLogger.GenerateLog(); benchmark.finalizeBenchmark(); } catch (Exception e) { Console.WriteLine(e.Message); } } Console.WriteLine("Done"); }
public RecalculationService(ChangeStatusDelegate ChangeStatus, SharedDataLoader DataLoader, string ConnectionString, string LogFileName, int PeriodMSec) { this.ChangeStatus = ChangeStatus; this.DataLoader = DataLoader; this.ConnectionString = ConnectionString; this.Log = new FileLogger(LogFileName); this.PeriodMSec = PeriodMSec; MainThread = new Thread(Execute); MainThread.Start(); Log.Message("Сервис пересчёта запущен. ThreadID: {0}", MainThread.ManagedThreadId); }
public SharedDataLoader(ChangeStatusDelegate ChangeStatus, string ConnectionString, string LogFileName, int CheckChangeNotifierIntervalMin, int CheckChangeNotifierTimeoutSec, string UpdatePath, UInt32 UpdateBlockSize/*, CardScriptPlugins CardScripts*/) { this.CurrentGeneration = 0; this.ChangeStatus = ChangeStatus; this.ConnectionString = ConnectionString; this.Log = new FileLogger(LogFileName); this.UpdatePath = UpdatePath; this.UpdateBlockSize = UpdateBlockSize; this.CheckChangeNotifierInterval = TimeSpan.FromMinutes(CheckChangeNotifierIntervalMin); this.CheckChangeNotifierTimeout = TimeSpan.FromSeconds(CheckChangeNotifierTimeoutSec); /*this.CardScripts = CardScripts;*/ Log.Message("Сервис запускается"); try { // первоначальная загрузка if (Notifier == null) { ChangeStatus("Init notifications..."); Log.Message("Инициализация отслеживания изменений в БД..."); InitNotifier(); } ChangeStatus("Initial loading..."); if (!Load()) throw new Exception("Ошибка начальной загрузки общих разделяемых данных"); if (!CurrentSharedData.DBVersion.IsBuildSupported) throw new Exception(string.Format("Установленная версия базы данных '{0}' не поддерживается программым обеспечением", CurrentSharedData.DBVersion.Build)); if (!CurrentSharedData.DBVersion.IsSignatureValid) throw new Exception("Неверная подпись безопасности базы данных"); // запускаем поток обновления данных LoadThread = new Thread(LoadThreadExecute); LoadThread.IsBackground = true; LoadThreadTerminated = false; LoadThread.Start(); Log.Message("Сервис запущен. ThreadID: {0}", LoadThread.ManagedThreadId); } catch { try { Dispose(); } catch { } throw; } }