public Level2MessageReader(IByteReader byteReader, IMessageHeaderReader messageHeaderReader, IMessage31Reader message31Reader, IDataLogger dataLogger) { _byteReader = byteReader; _messageHeaderReader = messageHeaderReader; _message31Reader = message31Reader; _dataLogger = dataLogger; }
public SocketThread(SocketThreadClosedEvent closedEvent, IDataLogger dataLogger, MessageLogger messageLogger, Socket inputSocket, Socket outputSocket, Int32 bufferSize) { if (inputSocket == null) { throw new ArgumentNullException("inputStream"); } if (outputSocket == null) { throw new ArgumentNullException("outputSocket"); } this.messageLoggerName = (messageLogger == null) ? String.Empty : messageLogger.name; this.closedEvent = closedEvent; this.dataLogger = dataLogger; this.messageLogger = messageLogger; this.inputSocket = inputSocket; this.outputSocket = outputSocket; this.bufferSize = bufferSize; this.keepRunning = false; this.thread = null; }
/// <summary> /// Constructor /// </summary> public Controller() { this.errorLogger = new LedErrorLogger(LED_ERROR_PIN); #if !EMULATOR // check for SD presence this.CheckSD(); #endif // create sensors instances this.dataLogger = new SDDataLogger(SD_DATA_LOGGING); this.anemometer = new Anemometer(ANEMOMETER_PIN); this.sht1x = new SHT1X(SHT1X_DATA_PIN, SHT1X_CLK_PIN, SHT1X.Voltage.Vdd_3_5V); this.ldr = new Ldr(LDR_ANALOG_CHANNEL, LDR_ADC_RESOLUTION, LDR_LOAD_RESISTOR); // RTC this.rtc = Rtc.Instance; // configure and create Web Server MicroWebServerConfig uWebServerConfig = new MicroWebServerConfig { Backlog = WS_BACKLOG, HttpPort = WS_HTTP_PORT, MaxWorkerThread = WS_MAX_WORKER_THREAD, WebRoot = SD_WEBROOT }; this.uWebServer = new MicroWebServer(uWebServerConfig); }
public CustomerSearch(ICustomerSearchRepo customerSearchRepo , IDataLogger dataLogger , IMapper mapper) { _customerSearchRepo = customerSearchRepo; _dataLogger = dataLogger; _mapper = mapper; }
public DataLoggerTestForm() { this.InitializeComponent(); this.logger = DataLogger.Instance; this.logger.LogFilePath = Path.Combine(Environment.CurrentDirectory, "log.mylog"); this.logger.LogItemsChanged += UpdateLog; }
public ClientOrder(IClientOrders clientOrders , IDataLogger dataLogger , IMapper mapper) { _clientOrders = clientOrders; _dataLogger = dataLogger; _mapper = mapper; }
public PhProbe(GenericAnalogSensorSettings settings) : base(settings) { dataLogger = Factory.GetDataLogger(string.Format("{0}PhProbe", name.RemoveWhitespace())); var channelName = string.Format("{0}, pH Probe", name); Driver.PhOrp.AddChannel(channel, channelName, lowPassFilterFactor); sensorDisconnectedAlarmIndex = Alarm.Subscribe("pH probe disconnected, " + name); Subscribe(Driver.PhOrp.GetChannelEventPublisherKey(channelName)); }
/// <summary> /// Sets the data loggers for the initialization process. /// </summary> /// <param name="navigatorEvolutionDataLogger">The logger for evolution statistics.</param> /// <param name="navigatorPopulationDataLogger">The logger for recording the extant genomes throughout evolution.</param> /// /// /// <param name="navigatorGenomeDataLogger">The logger for serializing navigator genomes.</param> /// <param name="navigatorEvolutionLogFieldEnableMap">Indicates the enabled/disabled status of the evolution logger fields.</param> /// <param name="populationLoggingInterval">The batch interval at which the current population is serialized to a file.</param> public void SetDataLoggers(IDataLogger navigatorEvolutionDataLogger, IDataLogger navigatorPopulationDataLogger, IDataLogger navigatorGenomeDataLogger, IDictionary <FieldElement, bool> navigatorEvolutionLogFieldEnableMap, int?populationLoggingInterval) { NavigatorEvolutionDataLogger = navigatorEvolutionDataLogger; NavigatorPopulationDataLogger = navigatorPopulationDataLogger; NavigatorEvolutionLogFieldEnableMap = navigatorEvolutionLogFieldEnableMap; PopulationLoggingBatchInterval = populationLoggingInterval; }
/// <inheritdoc /> /// <summary> /// Runs an agent (i.e. the maze navigator) through a collection of mazes until the minimal criteria is satisfied. /// </summary> /// <param name="agent">The maze navigator brain (ANN).</param> /// <param name="currentGeneration">The current generation or evaluation batch.</param> /// <param name="evaluationLogger">Reference to the evaluation logger.</param> /// <returns>A behavior info (which is a type of behavior-based trial information).</returns> public BehaviorInfo Evaluate(IBlackBox agent, uint currentGeneration, IDataLogger evaluationLogger) { var curSuccesses = 0; // TODO: Note that this will get overwritten until the last successful attempt (may need a better way of handling this for logging purposes) var trialInfo = BehaviorInfo.NoBehavior; for (var cnt = 0; cnt < _multiMazeWorldFactory.NumMazes && curSuccesses < _agentNumSuccessesCriteria; cnt++) { ulong threadLocalEvaluationCount; lock (_evaluationLock) { // Increment evaluation count threadLocalEvaluationCount = EvaluationCount++; } // Generate new behavior characterization var behaviorCharacterization = _behaviorCharacterizationFactory.CreateBehaviorCharacterization(); // Generate a new maze world var world = _multiMazeWorldFactory.CreateMazeNavigationWorld(cnt, behaviorCharacterization); // Run a single trial trialInfo = world.RunTrial(agent, SearchType.MinimalCriteriaSearch, out var goalReached); // Set the objective distance trialInfo.ObjectiveDistance = world.GetDistanceToTarget(); // Log trial information evaluationLogger?.LogRow(new List <LoggableElement> { new LoggableElement(EvaluationFieldElements.Generation, currentGeneration), new LoggableElement(EvaluationFieldElements.EvaluationCount, threadLocalEvaluationCount), new LoggableElement(EvaluationFieldElements.StopConditionSatisfied, StopConditionSatisfied), new LoggableElement(EvaluationFieldElements.RunPhase, RunPhase.Primary), new LoggableElement(EvaluationFieldElements.IsViable, trialInfo.DoesBehaviorSatisfyMinimalCriteria) }, world.GetLoggableElements()); // If the navigator reached the goal, update the running count of successes if (goalReached) { curSuccesses++; } } // If the number of successful maze navigations was equivalent to the minimum required, // then the minimal criteria has been satisfied if (curSuccesses >= _agentNumSuccessesCriteria) { trialInfo.DoesBehaviorSatisfyMinimalCriteria = true; } return(trialInfo); }
public Keylogger(IDataLogger datalogger) { DataLogger = datalogger; _windowTitle = WindowManager.GetActiveWindowTitle(); _prevWindowTitle = _windowTitle; _keyBuffer = new StringBuilder(1024); _timerKeyMine = CreateTimer(10, TimerKeyMineElapsed); _timerBufferFlush = CreateTimer(60000, TimerBufferFlushElapsed); }
public void Start() { // force creation of instance and opening of file IDataLogger l = Instance; if (l != null) { OpenLogfile(); } }
public Order(IOrderRepo orderRepo , IDataLogger dataLogger , IMapper mapper , IClientOrderAuthorization clientOrderAuthorization) { _orderRepo = orderRepo; _dataLogger = dataLogger; _mapper = mapper; _clientOrderAuthorization = clientOrderAuthorization; }
public OrdersController(IMapper mapper , IClientOrder clientOrder , IDataLogger dataLogger , IOrder order) { _mapper = mapper; _clientOrder = clientOrder; base.DataLogger = dataLogger; _order = order; }
public CustomerSearchController(IDataLogger dataLogger , ICustomerSearch customerSearch , IMapper mapper , HtmlEncoder htmlEncoder) { _htmlEncoder = htmlEncoder; _mapper = mapper; _customerSearch = customerSearch; _dataLogger = dataLogger; }
private static ErrorResponseModel BuildErrorResponse(IDataLogger dataLogger) { ErrorResponseModel errorResponse = new ErrorResponseModel { Name = Constants.ERROR_RESPONSE, DebugId = dataLogger.Id, Message = "An error has occured.", }; return(errorResponse); }
public override void Initialize(string name, XmlElement xmlConfig, IDataLogger evolutionDataLogger, IDataLogger evaluationDataLogger) { base.Initialize(name, xmlConfig, evolutionDataLogger, evaluationDataLogger); // Read in steady-state specific parameters _batchSize = XmlUtils.GetValueAsInt(xmlConfig, "OffspringBatchSize"); _populationEvaluationFrequency = XmlUtils.GetValueAsInt(xmlConfig, "PopulationEvaluationFrequency"); // Read in log file path/name _generationalLogFile = XmlUtils.TryGetValueAsString(xmlConfig, "GenerationalLogFile"); }
/// <summary> /// Create instance of SimpleReceiver /// </summary> /// <param name="statsUrl">Stats statsUrl to monitor</param> /// <param name="interval">Timer interval (in seconds)</param> /// <param name="logger">Logger instance</param> public SimpleReceiver(string statsUrl, int interval, IDataLogger logger) { StatsUrl = statsUrl; Logger = logger; TimeInterval = interval; _timer = new Timer(1000 * interval); _timer.Elapsed += (sender, args) => { ProcessData(); }; }
public override void Initialize(string name, XmlElement xmlConfig, IDataLogger evolutionDataLogger, IDataLogger evaluationDataLogger) { base.Initialize(name, xmlConfig, evolutionDataLogger, evaluationDataLogger); // Read in number of offspring to produce in a single batch _batchSize = XmlUtils.GetValueAsInt(xmlConfig, "OffspringBatchSize"); // Read in log file path/name _evolutionDataLogger = evolutionDataLogger ?? ExperimentUtils.ReadDataLogger(xmlConfig, LoggingType.Evolution); _evaluationDataLogger = evaluationDataLogger ?? ExperimentUtils.ReadDataLogger(xmlConfig, LoggingType.Evaluation); }
public void LinkDataLogger(IDataLogger logger) { var endSearchTime = DateTime.Now.Subtract(new TimeSpan(0, 0, maxDataPoints * PointTimeDifferenceToSeconds())); logger.ValueLogEntryAddedEvent += OnValueLogEntryAdded; var valueEntries = logger.GetValueEntries(maxDataPoints, PointTimeDifferenceToSeconds(), endSearchTime); dataPoints.AddRange(valueEntries); logger.EventLogEntryAddedEvent += OnEventLogEntryAdded; var eventEntries = logger.GetEventEntries(maxDataPoints, endSearchTime); eventPoints.AddRange(eventEntries); }
public ConnectionDataLoggerDoubleLog(IDataLogger loggerAToB, IDataLogger loggerBToA) { if (loggerAToB == null) { throw new ArgumentNullException("loggerAToB"); } if (loggerBToA == null) { throw new ArgumentNullException("loggerBToA"); } this.loggerAToB = loggerAToB; this.loggerBToA = loggerBToA; }
/// <summary> /// Creates a new FuzzController. Once the snapshotBreakpoint is reached a snapshot is created. /// The snapshot gets restored once restore Breakpoint is reached /// </summary> /// <param name="connector">connector to use</param> /// <param name="snapshotBreakpoint">Location to create a snapshot</param> /// <param name="restoreBreakpoint">Location to restore the snapshot</param> public FuzzController(ITargetConnector connector, string logDestination, IDataLogger logger, FuzzDescription fuzzDescription, IFuzzLocation[] preConditions) { _connector = connector; _snapshot = null; _dataLogger = logger; _logDestination = logDestination; _errorLog = new ErrorLog (_logDestination); _fuzzDescription = fuzzDescription; _fuzzDescription.Init (); _preConditions = preConditions; }
/// <inheritdoc /> /// <summary> /// Initializes the logger and writes header. /// </summary> /// <param name="evaluationLogger">The evaluation logger.</param> public void Initialize(IDataLogger evaluationLogger) { // Set the run phase evaluationLogger?.UpdateRunPhase(RunPhase.Primary); // Log the header evaluationLogger?.LogHeader(new List <LoggableElement> { new LoggableElement(EvaluationFieldElements.Generation, 0), new LoggableElement(EvaluationFieldElements.EvaluationCount, EvaluationCount), new LoggableElement(EvaluationFieldElements.StopConditionSatisfied, StopConditionSatisfied), new LoggableElement(EvaluationFieldElements.RunPhase, RunPhase.Initialization), new LoggableElement(EvaluationFieldElements.IsViable, false) }, _multiMazeWorldFactory.CreateMazeNavigationWorld(new MazeStructure(0, 0, 1), null).GetLoggableElements()); }
public ConnectionDataLoggerPrettyLog(UInt32 socketID, IDataLogger dataLogger, String logNameAToB, String logNameBToA) { if (dataLogger == null) { throw new ArgumentNullException("dataLogger"); } this.socketID = socketID; this.dataLogger = dataLogger; this.logNameAToB = logNameAToB; this.logNameBToA = logNameBToA; this.dataLoggerAToB = new CallbackDataLogger(LogDataAToB); this.dataLoggerBToA = new CallbackDataLogger(LogDataBToA); }
public OneWaySocketTunnel(ITunnelCallback callback, Socket inputSocket, Socket outputSocket, Int32 readBufferSize, MessageLogger messageLogger, IDataLogger dataLogger) { this.callback = callback; this.inputSocket = inputSocket; this.outputSocket = outputSocket; this.readBufferSize = readBufferSize; this.messageLogger = messageLogger; this.dataLogger = dataLogger; this.keepRunning = false; }
public WaterLevelGroup( string name, float highAnalogAlarmSetpoint, bool enableHighAnalogAlarm, float lowAnalogAlarmSetpoint, bool enableLowAnalogAlarm, IEnumerable <string> floatSwitches, IEnumerable <string> waterLevelSensors) { this.name = name; level = 0f; dataLogger = Factory.GetDataLogger(string.Format("{0}WaterLevel", this.name.RemoveWhitespace())); this.highAnalogAlarmSetpoint = highAnalogAlarmSetpoint; this.enableHighAnalogAlarm = enableHighAnalogAlarm; if (this.enableHighAnalogAlarm) { highAnalogAlarmIndex = Alarm.Subscribe(string.Format("{0} High Water Level (Analog)", this.name)); } Alarm.AddAlarmHandler(highAnalogAlarmIndex, OnHighAlarm); this.lowAnalogAlarmSetpoint = lowAnalogAlarmSetpoint; this.enableLowAnalogAlarm = enableLowAnalogAlarm; if (this.enableLowAnalogAlarm) { lowAnalogAlarmIndex = Alarm.Subscribe(string.Format("{0} Low Water Level (Analog)", this.name)); } Alarm.AddAlarmHandler(lowAnalogAlarmIndex, OnLowAlarm); highSwitchAlarmIndex = Alarm.Subscribe(string.Format("{0} High Water Level (Switch)", this.name)); lowSwitchAlarmIndex = Alarm.Subscribe(string.Format("{0} Low Water Level (Switch)", this.name)); Alarm.AddAlarmHandler(highSwitchAlarmIndex, OnHighAlarm); Alarm.AddAlarmHandler(lowSwitchAlarmIndex, OnLowAlarm); this.floatSwitches = new List <string> (floatSwitches); foreach (var floatSwitch in this.floatSwitches) { Subscribe(Sensors.FloatSwitches.GetGadgetEventPublisherKey(floatSwitch)); } this.waterLevelSensors = new Dictionary <string, InternalWaterLevelSensorState> (); foreach (var waterLevelSensor in waterLevelSensors) { this.waterLevelSensors.Add(waterLevelSensor, new InternalWaterLevelSensorState()); Subscribe(Sensors.WaterLevelSensors.GetGadgetEventPublisherKey(waterLevelSensor)); } }
public FtpHandler(IFtpCommandHandler handler, NetworkStream stream, MessageLogger messageLogger, IDataLogger dataLogger) { if (handler == null) { throw new ArgumentNullException("handler"); } if (stream == null) { throw new ArgumentNullException("null"); } this.handler = handler; this.stream = stream; this.messageLogger = (messageLogger == null) ? MessageLogger.NullMessageLogger : messageLogger; this.dataLogger = (dataLogger == null) ? DataLogger.Null : dataLogger; }
/// <summary> /// Initialization algorithm constructor. /// </summary> /// <param name="evolutionDataLogger">Sets the evolution logger reference from the parent algorithm.</param> /// <param name="evaluationDataLogger">Sets the evaluation logger reference from the parent algorithm.</param> /// <param name="serializeGenomeToXml">Whether each evaluated genome should be serialized to XML.</param> public NoveltySearchMazeNavigationInitializer(ulong? maxEvaluations, IDataLogger evolutionDataLogger, IDataLogger evaluationDataLogger, bool? serializeGenomeToXml) { _maxEvaluations = maxEvaluations; _evolutionDataLogger = evolutionDataLogger; _evaluationDataLogger = evaluationDataLogger; _serializeGenomeToXml = serializeGenomeToXml ?? false; // Setup log field enable/disable map _initializationLogFieldEnableMap = new Dictionary<FieldElement, bool> { {EvolutionFieldElements.ChampGenomeFitness, true} }; if (_serializeGenomeToXml) { _initializationLogFieldEnableMap.Add(EvolutionFieldElements.ChampGenomeXml, true); } }
public async Task Invoke(HttpContext context, IDataLogger dataLogger) { try { await _next(context); } catch (Exception ex) { //if (context.Response.HasStarted) //{ LogTheException(ex, dataLogger); // throw; //} var errorResponse = BuildErrorResponse(dataLogger); await _exceptionResponse.SendExceptionResponse(context, 500, errorResponse); return; } }
public ConnectionDataLoggerSingleLog(IDataLogger dataLogger, String logNameAToB, String logNameBToA, String logPrefixFormatString) { if (dataLogger == null) { throw new ArgumentNullException("dataLogger"); } if (logPrefixFormatString == null) { throw new ArgumentNullException("logPrefixFormatString"); } this.dataLogger = dataLogger; this.logNameAToB = logNameAToB; this.logNameBToA = logNameBToA; this.logPrefixFormatString = logPrefixFormatString; this.dataLoggerAToB = new CallbackDataLogger(LogDataAToB); this.dataLoggerBToA = new CallbackDataLogger(LogDataBToA); }
/// <summary> /// Runs a agent (i.e. maze navigator brain) through a single maze trial. /// </summary> /// <param name="agent">The maze navigator brain (ANN).</param> /// <param name="currentGeneration">The current generation or evaluation batch.</param> /// <param name="evaluationLogger">Reference to the evaluation logger.</param> /// <returns>A fitness info (which is a function of the euclidean distance to the target).</returns> public BehaviorInfo Evaluate(IBlackBox agent, uint currentGeneration, IDataLogger evaluationLogger) { lock (_evaluationLock) { // Increment evaluation count EvaluationCount++; } // Generate new behavior characterization var behaviorCharacterization = _behaviorCharacterizationFactory.CreateBehaviorCharacterization(); // Instantiate the maze world var world = _multiMazeWorldFactory.CreateMazeNavigationWorld(behaviorCharacterization); // Run a single trial var trialInfo = world.RunTrial(agent, SearchType.NoveltySearch, out var goalReached); // Set the objective distance trialInfo.ObjectiveDistance = world.GetDistanceToTarget(); // Set the stop condition to the outcome if (goalReached) { StopConditionSatisfied = true; } // Log trial information (only log for non-bridging evaluations) evaluationLogger?.LogRow(new List <LoggableElement> { new LoggableElement(EvaluationFieldElements.Generation, currentGeneration), new LoggableElement(EvaluationFieldElements.EvaluationCount, EvaluationCount), new LoggableElement(EvaluationFieldElements.StopConditionSatisfied, StopConditionSatisfied), new LoggableElement(EvaluationFieldElements.RunPhase, RunPhase.Initialization) }, world.GetLoggableElements()); return(trialInfo); }
// Middleware: Custom middleware needs an Invoke method that is called when requests come in for processing. // It should have an HttpContext as its first argument and, optionally, other services that are // needed from DI. Dependencies which are injected at this level will be scoped to the lifetime of the request. public async Task Invoke(HttpContext context, IDataLogger dataLogger) { try { //First, get the incoming request var request = await FormatRequest(context.Request); dataLogger.LogInformation("Request", request); dataLogger.LogInformation("RequestHeader", FormatHeaders(context.Request)); //Copy a pointer to the original response body stream var originalBodyStream = context.Response.Body; //Create a new memory stream... using (var responseBody = new MemoryStream()) { //...and use that for the temporary response body context.Response.Body = responseBody; //Continue down the Middleware pipeline, eventually returning to this class await _next(context); //Format the response from the server var response = await FormatResponse(context.Response); dataLogger.LogInformation("Response", response); //Copy the contents of the new memory stream (which contains the response) to the original stream, which is then returned to the client. await responseBody.CopyToAsync(originalBodyStream); } } catch (Exception) { // Do nothing. We don't want to stop execution. await _next(context); } }
public override void Initialize(ExperimentDictionary experimentDictionary) { base.Initialize(experimentDictionary); // Read in the behavior characterization _behaviorCharacterizationFactory = ExperimentUtils.ReadBehaviorCharacterizationFactory( experimentDictionary, true); // Read in number of offspring to produce in a single batch _batchSize = experimentDictionary.Primary_OffspringBatchSize ?? default(int); // Read in log file path/name _evolutionDataLogger = new McsExperimentEvaluationEntityDataLogger(experimentDictionary.ExperimentName); _evaluationDataLogger = new McsExperimentOrganismStateEntityDataLogger(experimentDictionary.ExperimentName); }
public ParsedHttpRequest(NetworkStream stream, MessageLogger messageLogger, IDataLogger dataLogger) { int bytesRead; byte[] readBuffer = new byte[2048]; parserState = RequestParserState.Method; StringBuilder stringBuilder = new StringBuilder(InitialCapacityForMethod); String hValue = String.Empty; String hKey = String.Empty; String temp; Int32 bodyIndex = 0; do { switch (parserState) { case RequestParserState.Method: messageLogger.Log("Reading Request"); break; case RequestParserState.Body: messageLogger.Log("Waiting for {0} bytes for the body", body.Length - bodyIndex); break; default: messageLogger.Log("Waiting for more data (ParserState={0})...", parserState); break; } bytesRead = stream.Read(readBuffer, 0, readBuffer.Length); if (bytesRead <= 0) { break; } if (dataLogger != null) { dataLogger.LogData(readBuffer, 0, bytesRead); } int offset = 0; do { switch (parserState) { case RequestParserState.Method: if (readBuffer[offset] != ' ') { stringBuilder.Append((char)readBuffer[offset]); } else { method = stringBuilder.ToString(); stringBuilder = new StringBuilder(InitialCapacityForUrl); parserState = RequestParserState.Url; } offset++; break; case RequestParserState.Url: if (readBuffer[offset] == '?') { url = Http.UrlDecode(stringBuilder.ToString()); hKey = String.Empty; urlArguments = new Dictionary <String, String>(); parserState = RequestParserState.UrlParam; } else if (readBuffer[offset] != ' ') { stringBuilder.Append((char)readBuffer[offset]); } else { url = Http.UrlDecode(stringBuilder.ToString()); parserState = RequestParserState.Version; } offset++; break; case RequestParserState.UrlParam: if (readBuffer[offset] == '=') { offset++; hValue = String.Empty; parserState = RequestParserState.UrlParamValue; } else if (readBuffer[offset] == ' ') { offset++; url = Http.UrlDecode(url); parserState = RequestParserState.Version; } else { hKey += (char)readBuffer[offset++]; } break; case RequestParserState.UrlParamValue: if (readBuffer[offset] == '&') { offset++; hKey = Http.UrlDecode(hKey); hValue = Http.UrlDecode(hValue); if (urlArguments.TryGetValue(hKey, out temp)) { urlArguments[hKey] = String.Format("{0},{1}", temp, hValue); } else { urlArguments[hKey] = hValue; } hKey = String.Empty; parserState = RequestParserState.UrlParam; } else if (readBuffer[offset] == ' ') { offset++; hKey = Http.UrlDecode(hKey); hValue = Http.UrlDecode(hValue); if (urlArguments.TryGetValue(hKey, out temp)) { urlArguments[hKey] = String.Format("{0},{1}", temp, hValue); } else { urlArguments[hKey] = hValue; } parserState = RequestParserState.Version; } else { hValue += (char)readBuffer[offset++]; } break; case RequestParserState.Version: if (readBuffer[offset] == '\r') { offset++; } if (readBuffer[offset] != '\n') { httpVersion += (char)readBuffer[offset++]; } else { offset++; hKey = String.Empty; headers = new Dictionary <String, String>(); parserState = RequestParserState.HeaderKey; } break; case RequestParserState.HeaderKey: if (readBuffer[offset] == '\r') { offset++; } if (readBuffer[offset] == '\n') { offset++; if (headers.TryGetValue("Content-Length", out temp)) { body = new byte[Int32.Parse(temp)]; parserState = RequestParserState.Body; } else { parserState = RequestParserState.Done; } } else if (readBuffer[offset] == ':') { offset++; } else if (readBuffer[offset] != ' ') { hKey += (char)readBuffer[offset++]; } else { offset++; hValue = ""; parserState = RequestParserState.HeaderValue; } break; case RequestParserState.HeaderValue: if (readBuffer[offset] == '\r') { offset++; } if (readBuffer[offset] == '\n') { offset++; headers.Add(hKey, hValue); hKey = String.Empty; parserState = RequestParserState.HeaderKey; } else { hValue += (char)readBuffer[offset++]; } break; case RequestParserState.Body: // Append to request BodyData Array.Copy(readBuffer, offset, body, bodyIndex, bytesRead - offset); bodyIndex += bytesRead - offset; offset = bytesRead; if (bodyIndex >= ((body == null) ? 0 : body.Length)) { parserState = RequestParserState.Done; } break; default: throw new InvalidOperationException(String.Format("Unrecognized Parser State '{0}' ({1})", parserState, (int)parserState)); } }while (offset < bytesRead); } while ((parserState != RequestParserState.Done) && stream.DataAvailable); }
/// <inheritdoc /> /// <summary> /// Initializes the MCC maze navigation experiment by reading in all of the configuration parameters and /// setting up the bootstrapping/initialization algorithm. /// </summary> /// <param name="name">The name of the experiment.</param> /// <param name="xmlConfig">The reference to the XML configuration file.</param> /// <param name="navigatorEvolutionLogger">The navigator evolution data logger.</param> /// <param name="navigatorPopulationLogger">The navigator population logger.</param> /// <param name="navigatorGenomeLogger">The navigator genome logger.</param> /// <param name="mazeEvolutionLogger">The maze evolution data logger.</param> /// <param name="mazePopulationLogger">The maze population logger.</param> /// <param name="mazeGenomeLogger">The maze genome logger.</param> public override void Initialize(string name, XmlElement xmlConfig, IDataLogger navigatorEvolutionLogger = null, IDataLogger navigatorPopulationLogger = null, IDataLogger navigatorGenomeLogger = null, IDataLogger mazeEvolutionLogger = null, IDataLogger mazePopulationLogger = null, IDataLogger mazeGenomeLogger = null) { // Initialize boiler plate parameters base.Initialize(name, xmlConfig, navigatorEvolutionLogger, navigatorPopulationLogger, navigatorGenomeLogger, mazeEvolutionLogger, mazePopulationLogger, mazeGenomeLogger); // Read in log file path/name _navigatorEvolutionDataLogger = navigatorEvolutionLogger ?? ExperimentUtils.ReadDataLogger(xmlConfig, LoggingType.Evolution, "NavigatorLoggingConfig"); _navigatorPopulationDataLogger = navigatorPopulationLogger ?? ExperimentUtils.ReadDataLogger(xmlConfig, LoggingType.Population, "NavigatorLoggingConfig"); _navigatorGenomeDataLogger = navigatorGenomeLogger ?? ExperimentUtils.ReadDataLogger(xmlConfig, LoggingType.Genome, "NavigatorLoggingConfig"); _mazeEvolutionDataLogger = mazeEvolutionLogger ?? ExperimentUtils.ReadDataLogger(xmlConfig, LoggingType.Evolution, "MazeLoggingConfig"); _mazePopulationDataLogger = mazePopulationLogger ?? ExperimentUtils.ReadDataLogger(xmlConfig, LoggingType.Population, "MazeLoggingConfig"); _mazeGenomeDataLogger = mazeGenomeLogger ?? ExperimentUtils.ReadDataLogger(xmlConfig, LoggingType.Genome, "MazeLoggingConfig"); // Create new evolution field elements map with all fields enabled _navigatorLogFieldEnableMap = EvolutionFieldElements.PopulateEvolutionFieldElementsEnableMap(); // Add default population logging configuration foreach (var populationLoggingPair in PopulationFieldElements.PopulatePopulationFieldElementsEnableMap()) { _navigatorLogFieldEnableMap.Add(populationLoggingPair.Key, populationLoggingPair.Value); } // Add default genome logging configuration foreach (var genomeLoggingPair in GenomeFieldElements.PopulateGenomeFieldElementsEnableMap()) { _navigatorLogFieldEnableMap.Add(genomeLoggingPair.Key, genomeLoggingPair.Value); } // Disable logging fields not relevant to agent evolution in MCC experiment _navigatorLogFieldEnableMap[EvolutionFieldElements.SpecieCount] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.AsexualOffspringCount] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.SexualOffspringCount] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.InterspeciesOffspringCount] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MinimalCriteriaThreshold] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MinimalCriteriaPointX] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MinimalCriteriaPointY] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MaxFitness] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MeanFitness] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MeanSpecieChampFitness] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MinSpecieSize] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MaxSpecieSize] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.ChampGenomeGenomeId] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.ChampGenomeFitness] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.ChampGenomeBirthGeneration] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.ChampGenomeConnectionGeneCount] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.ChampGenomeNeuronGeneCount] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.ChampGenomeTotalGeneCount] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.ChampGenomeEvaluationCount] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.ChampGenomeBehaviorX] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.ChampGenomeBehaviorY] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.ChampGenomeDistanceToTarget] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.ChampGenomeXml] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MinWalls] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MaxWalls] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MeanWalls] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MinWaypoints] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MaxWaypoints] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MeanWaypoints] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MinJunctures] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MaxJunctures] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MeanJunctures] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MinTrajectoryFacingOpenings] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MaxTrajectoryFacingOpenings] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MeanTrajectoryFacingOpenings] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MinHeight] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MaxHeight] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MeanHeight] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MinWidth] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MaxWidth] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MeanWidth] = false; // Create a maze logger configuration with the same configuration as the navigator one _mazeLogFieldEnableMap = new Dictionary <FieldElement, bool>(_navigatorLogFieldEnableMap) { [EvolutionFieldElements.RunPhase] = false, [PopulationFieldElements.RunPhase] = false, [EvolutionFieldElements.MinWalls] = true, [EvolutionFieldElements.MaxWalls] = true, [EvolutionFieldElements.MeanWalls] = true, [EvolutionFieldElements.MinWaypoints] = true, [EvolutionFieldElements.MaxWaypoints] = true, [EvolutionFieldElements.MeanWaypoints] = true, [EvolutionFieldElements.MinJunctures] = true, [EvolutionFieldElements.MaxJunctures] = true, [EvolutionFieldElements.MeanJunctures] = true, [EvolutionFieldElements.MinTrajectoryFacingOpenings] = true, [EvolutionFieldElements.MaxTrajectoryFacingOpenings] = true, [EvolutionFieldElements.MeanTrajectoryFacingOpenings] = true, [EvolutionFieldElements.MinHeight] = true, [EvolutionFieldElements.MaxHeight] = true, [EvolutionFieldElements.MeanHeight] = true, [EvolutionFieldElements.MinWidth] = true, [EvolutionFieldElements.MaxWidth] = true, [EvolutionFieldElements.MeanWidth] = true }; // Read in the number of batches between population logging _populationLoggingBatchInterval = XmlUtils.TryGetValueAsInt(xmlConfig, "PopulationLoggingBatchInterval"); }
public void SetLogger(LoggerDestinationEnum loggerDestination, IDataLogger logger) { _childLocation.ApplyChangeableId (_changeableId); _childLocation.SetLogger (loggerDestination, logger); }
public override void Initialize(string name, XmlElement xmlConfig, IDataLogger evolutionDataLogger, IDataLogger evaluationDataLogger) { base.Initialize(name, xmlConfig, evolutionDataLogger, evaluationDataLogger); // Read in the behavior characterization _behaviorCharacterizationFactory = ExperimentUtils.ReadBehaviorCharacterizationFactory(xmlConfig, "BehaviorConfig"); // Read in steady-state specific parameters _batchSize = XmlUtils.GetValueAsInt(xmlConfig, "OffspringBatchSize"); _populationEvaluationFrequency = XmlUtils.GetValueAsInt(xmlConfig, "PopulationEvaluationFrequency"); // Read in MCS selection method _mcsSelectionMethod = XmlUtils.TryGetValueAsString(xmlConfig, "McsSelectionMethod"); // Read in log file path/name _evolutionDataLogger = evolutionDataLogger ?? ExperimentUtils.ReadDataLogger(xmlConfig, LoggingType.Evolution); _evaluationDataLogger = evaluationDataLogger ?? ExperimentUtils.ReadDataLogger(xmlConfig, LoggingType.Evaluation); }
public override void Initialize(ExperimentDictionary experimentDictionary) { base.Initialize(experimentDictionary); // Ensure the start position and minimum distance constraint are not null Debug.Assert(experimentDictionary.Primary_MCS_MinimalCriteriaStartX != null, "experimentDictionary.Primary_MCS_MinimalCriteriaStartX != null"); Debug.Assert(experimentDictionary.Primary_MCS_MinimalCriteriaStartY != null, "experimentDictionary.Primary_MCS_MinimalCriteriaStartY != null"); Debug.Assert(experimentDictionary.Primary_MCS_MinimalCriteriaThreshold != null, "experimentDictionary.Primary_MCS_MinimalCriteriaThreshold != null"); // Read in the behavior characterization _behaviorCharacterizationFactory = ExperimentUtils.ReadBehaviorCharacterizationFactory( experimentDictionary, true); // Read in steady-state specific parameters _batchSize = experimentDictionary.Primary_OffspringBatchSize ?? default(int); _populationEvaluationFrequency = experimentDictionary.Primary_PopulationEvaluationFrequency ?? default(int); // Read in MCS selection method _mcsSelectionMethod = experimentDictionary.Primary_SelectionAlgorithmName; // Read in log file path/name _evolutionDataLogger = new NoveltyExperimentEvaluationEntityDataLogger(experimentDictionary.ExperimentName); _evaluationDataLogger = new NoveltyExperimentOrganismStateEntityDataLogger(experimentDictionary.ExperimentName); }
public virtual void SetLogger(LoggerDestinationEnum loggerDestination, IDataLogger logger) { if (loggerDestination == LoggerDestinationEnum.DataGenLogger && _dataGenerator != null) _dataGenerator.SetLogger ((DataGeneratorLogger)logger); }
public override void Initialize(string name, XmlElement xmlConfig, IDataLogger evolutionDataLogger, IDataLogger evaluationDataLogger) { base.Initialize(name, xmlConfig, evolutionDataLogger, evaluationDataLogger); // Read in the behavior characterization _behaviorCharacterizationFactory = ExperimentUtils.ReadBehaviorCharacterizationFactory(xmlConfig, "BehaviorConfig"); // Read in the novelty archive parameters // Read in the novelty archive parameters ExperimentUtils.ReadNoveltyParameters(xmlConfig, out _archiveAdditionThreshold, out _archiveThresholdDecreaseMultiplier, out _archiveThresholdIncreaseMultiplier, out _maxGenerationArchiveAddition, out _maxGenerationsWithoutArchiveAddition); // Read in nearest neighbors for behavior distance calculations _nearestNeighbors = XmlUtils.GetValueAsInt(xmlConfig, "NearestNeighbors"); }
/// <inheritdoc /> /// <summary> /// Initializes the MCC maze navigation experiment by reading in all of the configuration parameters and /// setting up the bootstrapping/initialization algorithm. /// </summary> /// <param name="name">The name of the experiment.</param> /// <param name="xmlConfig">The reference to the XML configuration file.</param> /// <param name="population1EvolutionLogger">The navigator evolution data logger.</param> /// <param name="population1PopulationLogger">The navigator population logger.</param> /// <param name="population1GenomeLogger">The navigator genome logger.</param> /// <param name="population2EvolutionLogger">The maze evolution data logger.</param> /// <param name="population2PopulationLogger">The maze population logger.</param> /// <param name="population2GenomeLogger">The maze genome logger.</param> public virtual void Initialize(string name, XmlElement xmlConfig, IDataLogger population1EvolutionLogger = null, IDataLogger population1PopulationLogger = null, IDataLogger population1GenomeLogger = null, IDataLogger population2EvolutionLogger = null, IDataLogger population2PopulationLogger = null, IDataLogger population2GenomeLogger = null) { // Set boiler plate properties Name = name; Description = XmlUtils.GetValueAsString(xmlConfig, "Description"); ActivationScheme = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation"); ParallelOptions = ExperimentUtils.ReadParallelOptions(xmlConfig); // Set the genome parameters NeatGenomeParameters = ExperimentUtils.ReadNeatGenomeParameters(xmlConfig); NeatGenomeParameters.FeedforwardOnly = ActivationScheme.AcyclicNetwork; MazeGenomeParameters = ExperimentUtils.ReadMazeGenomeParameters(xmlConfig); // Configure evolutionary algorithm parameters AgentDefaultPopulationSize = XmlUtils.GetValueAsInt(xmlConfig, "AgentPopulationSize"); MazeDefaultPopulationSize = XmlUtils.GetValueAsInt(xmlConfig, "MazePopulationSize"); AgentSeedGenomeCount = XmlUtils.GetValueAsInt(xmlConfig, "AgentSeedGenomeCount"); MazeSeedGenomeCount = XmlUtils.GetValueAsInt(xmlConfig, "MazeSeedGenomeCount"); AgentNumSpecies = XmlUtils.GetValueAsInt(xmlConfig, "AgentNumSpecies"); MazeNumSpecies = XmlUtils.GetValueAsInt(xmlConfig, "MazeNumSpecies"); BehaviorCharacterizationFactory = ExperimentUtils.ReadBehaviorCharacterizationFactory(xmlConfig, "BehaviorConfig"); NavigatorBatchSize = XmlUtils.GetValueAsInt(xmlConfig, "NavigatorOffspringBatchSize"); MazeBatchSize = XmlUtils.GetValueAsInt(xmlConfig, "MazeOffspringBatchSize"); // Set run-time bounding parameters MaxGenerations = XmlUtils.TryGetValueAsInt(xmlConfig, "MaxGenerations"); MaxEvaluations = XmlUtils.TryGetValueAsULong(xmlConfig, "MaxEvaluations"); // Set experiment-specific parameters MinSuccessDistance = XmlUtils.GetValueAsInt(xmlConfig, "MinSuccessDistance"); MazeHeight = XmlUtils.GetValueAsInt(xmlConfig, "MazeHeight"); MazeWidth = XmlUtils.GetValueAsInt(xmlConfig, "MazeWidth"); MazeQuadrantHeight = XmlUtils.GetValueAsInt(xmlConfig, "MazeQuadrantHeight"); MazeQuadrantWidth = XmlUtils.GetValueAsInt(xmlConfig, "MazeQuadrantWidth"); MazeScaleMultiplier = XmlUtils.GetValueAsInt(xmlConfig, "MazeScaleMultiplier"); // Get success/failure criteria constraints NumMazeSuccessCriteria = XmlUtils.GetValueAsInt(xmlConfig, "NumMazesSolvedCriteria"); NumAgentSuccessCriteria = XmlUtils.GetValueAsInt(xmlConfig, "NumAgentsSolvedCriteria"); NumAgentFailedCriteria = XmlUtils.GetValueAsInt(xmlConfig, "NumAgentsFailedCriteria"); // Read in the maximum number of initialization evaluations _maxInitializationEvaluations = XmlUtils.GetValueAsUInt(xmlConfig, "MaxInitializationEvaluations"); // Initialize the initialization algorithm _mazeNavigationInitializer = ExperimentUtils.DetermineMCCInitializer( xmlConfig.GetElementsByTagName("InitializationAlgorithmConfig", "")[0] as XmlElement); // Setup initialization algorithm _mazeNavigationInitializer.SetAlgorithmParameters( xmlConfig.GetElementsByTagName("InitializationAlgorithmConfig", "")[0] as XmlElement, ActivationScheme.AcyclicNetwork, NumAgentSuccessCriteria, 0); // Pass in maze experiment specific parameters // (note that a new maze structure is created here for the sole purpose of extracting the maze dimensions and calculating max distance to target) _mazeNavigationInitializer.SetEnvironmentParameters(MinSuccessDistance, new MazeDecoder(MazeScaleMultiplier).Decode( new MazeGenomeFactory(MazeGenomeParameters, MazeHeight, MazeWidth, MazeQuadrantHeight, MazeQuadrantWidth).CreateGenome(0))); // The size of the randomly generated agent genome pool from which to evolve agent bootstraps AgentInitializationGenomeCount = _mazeNavigationInitializer.PopulationSize; }
public override void Initialize(string name, XmlElement xmlConfig, IDataLogger evolutionDataLogger, IDataLogger evaluationDataLogger) { base.Initialize(name, xmlConfig, evolutionDataLogger, evaluationDataLogger); // Read in the behavior characterization _behaviorCharacterizationFactory = ExperimentUtils.ReadBehaviorCharacterizationFactory(xmlConfig, "BehaviorConfig"); // Read in number of offspring to produce in a single batch _batchSize = XmlUtils.GetValueAsInt(xmlConfig, "OffspringBatchSize"); // Read in the minimal criteria update interval _minimalCriteriaUpdateInterval = XmlUtils.GetValueAsInt(xmlConfig, "MinimalCriteriaUpdateInterval"); // Read in the bridging magnitude and number of applications _bridgingMagnitude = XmlUtils.TryGetValueAsInt(xmlConfig, "BridgingMagnitude") ?? default(int); _bridgingApplications = XmlUtils.TryGetValueAsInt(xmlConfig, "BridgingApplications") ?? default(int); // Read in the number of seed genomes to generate to bootstrap the primary algorithm SeedGenomeCount = XmlUtils.GetValueAsInt(xmlConfig, "SeedGenomeCount"); // Read in log file path/name _evolutionDataLogger = evolutionDataLogger ?? ExperimentUtils.ReadDataLogger(xmlConfig, LoggingType.Evolution); _evaluationDataLogger = evaluationDataLogger ?? ExperimentUtils.ReadDataLogger(xmlConfig, LoggingType.Evaluation); // Setup the specific logging options based on parameters that are enabled/disabled _experimentLogFieldEnableMap = new Dictionary<FieldElement, bool>(); // Enable or disable genome XML logging if (SerializeGenomeToXml) { _experimentLogFieldEnableMap.Add(EvolutionFieldElements.ChampGenomeXml, true); } // Enable or disable primary fitness logging (causing utilization of auxiliary fitness) if (_bridgingMagnitude > 0) { _experimentLogFieldEnableMap.Add(EvolutionFieldElements.ChampGenomeFitness, false); } // Log the MC threshold and location since it is dynamic _experimentLogFieldEnableMap.Add(EvolutionFieldElements.MinimalCriteriaThreshold, true); _experimentLogFieldEnableMap.Add(EvolutionFieldElements.MinimalCriteriaPointX, true); _experimentLogFieldEnableMap.Add(EvolutionFieldElements.MinimalCriteriaPointY, true); }
public Message31Reader(IByteReader byteReader, IDataLogger dataLogger) { _byteReader = byteReader; _dataLogger = dataLogger; }
public override void Initialize(ExperimentDictionary experimentDictionary) { base.Initialize(experimentDictionary); // Read in the behavior characterization _behaviorCharacterizationFactory = ExperimentUtils.ReadBehaviorCharacterizationFactory( experimentDictionary, true); // Read in number of offspring to produce in a single batch _batchSize = experimentDictionary.Primary_OffspringBatchSize ?? default(int); // Read in the bridging magnitude _bridgingMagnitude = experimentDictionary.Primary_MCS_BridgingMagnitude ?? default(int); _bridgingApplications = experimentDictionary.Primary_MCS_BridgingApplications ?? default(int); // TODO: Read seed genome count from the database // Read in log file path/name _evolutionDataLogger = new McsExperimentEvaluationEntityDataLogger(experimentDictionary.ExperimentName); _evaluationDataLogger = new McsExperimentOrganismStateEntityDataLogger(experimentDictionary.ExperimentName); // Initialize the initialization algorithm _mazeNavigationInitializer = new NoveltySearchMazeNavigationInitializer(MaxEvaluations, _evolutionDataLogger, _evaluationDataLogger, SerializeGenomeToXml); // Setup initialization algorithm _mazeNavigationInitializer.SetAlgorithmParameters(experimentDictionary, InputCount, OutputCount); // Pass in maze experiment specific parameters _mazeNavigationInitializer.SetEnvironmentParameters(MaxDistanceToTarget, MaxTimesteps, MazeVariant, MinSuccessDistance); }
public override void Initialize(string name, XmlElement xmlConfig, IDataLogger evolutionDataLogger, IDataLogger evaluationDataLogger) { base.Initialize(name, xmlConfig, evolutionDataLogger, evaluationDataLogger); // Read in the behavior characterization _behaviorCharacterizationFactory = ExperimentUtils.ReadBehaviorCharacterizationFactory(xmlConfig, "BehaviorConfig"); // Read in number of offspring to produce in a single batch _batchSize = XmlUtils.GetValueAsInt(xmlConfig, "OffspringBatchSize"); // Read in the bridging magnitude and number of applications _bridgingMagnitude = XmlUtils.TryGetValueAsInt(xmlConfig, "BridgingMagnitude") ?? default(int); _bridgingApplications = XmlUtils.TryGetValueAsInt(xmlConfig, "BridgingApplications") ?? default(int); // Read in the number of seed genomes to generate to bootstrap the primary algorithm SeedGenomeCount = XmlUtils.GetValueAsInt(xmlConfig, "SeedGenomeCount"); // Read in log file path/name _evolutionDataLogger = evolutionDataLogger ?? ExperimentUtils.ReadDataLogger(xmlConfig, LoggingType.Evolution); _evaluationDataLogger = evaluationDataLogger ?? ExperimentUtils.ReadDataLogger(xmlConfig, LoggingType.Evaluation); // Setup the specific logging options based on parameters that are enabled/disabled _experimentLogFieldEnableMap = EvolutionFieldElements.PopulateEvolutionFieldElementsEnableMap(); // Enable or disable genome XML logging if (SerializeGenomeToXml == false) { _experimentLogFieldEnableMap.Add(EvolutionFieldElements.ChampGenomeXml, false); } // Enable or disable primary fitness logging (causing utilization of auxiliary fitness) if (_bridgingMagnitude > 0) { _experimentLogFieldEnableMap.Add(EvolutionFieldElements.ChampGenomeFitness, false); } // Initialize the initialization algorithm _mazeNavigationInitializer = new NoveltySearchMazeNavigationInitializer(MaxEvaluations, _evolutionDataLogger, _evaluationDataLogger, SerializeGenomeToXml); // Setup initialization algorithm _mazeNavigationInitializer.SetAlgorithmParameters( xmlConfig.GetElementsByTagName("InitializationAlgorithmConfig", "")[0] as XmlElement, InputCount, OutputCount); // Pass in maze experiment specific parameters _mazeNavigationInitializer.SetEnvironmentParameters(MaxDistanceToTarget, MaxTimesteps, MazeVariant, MinSuccessDistance); }
public override void Initialize(string name, XmlElement xmlConfig, IDataLogger evolutionDataLogger, IDataLogger evaluationDataLogger) { base.Initialize(name, xmlConfig, evolutionDataLogger, evaluationDataLogger); // Read in the behavior characterization _behaviorCharacterizationFactory = ExperimentUtils.ReadBehaviorCharacterizationFactory(xmlConfig, "BehaviorConfig"); // Read in the novelty archive parameters ExperimentUtils.ReadNoveltyParameters(xmlConfig, out _archiveAdditionThreshold, out _archiveThresholdDecreaseMultiplier, out _archiveThresholdIncreaseMultiplier, out _maxGenerationArchiveAddition, out _maxGenerationsWithoutArchiveAddition); // Read in nearest neighbors for behavior distance calculations _nearestNeighbors = XmlUtils.GetValueAsInt(xmlConfig, "NearestNeighbors"); // Read in steady-state specific parameters _batchSize = XmlUtils.GetValueAsInt(xmlConfig, "OffspringBatchSize"); _populationEvaluationFrequency = XmlUtils.GetValueAsInt(xmlConfig, "PopulationEvaluationFrequency"); // Read in log file path/name _generationalLogFile = XmlUtils.TryGetValueAsString(xmlConfig, "GenerationalLogFile"); }
/// <summary> /// Initializes the coevolution maze navigation experiment by reading in all of the configuration parameters and /// setting up the bootstrapping/initialization algorithm. /// </summary> /// <param name="name">The name of the experiment.</param> /// <param name="xmlConfig">The reference to the XML configuration file.</param> /// <param name="navigatorEvolutionLogger">The navigator evolution data logger.</param> /// <param name="navigatorGenomeLogger">The navigator genome logger.</param> /// <param name="mazeEvolutionLogger">The maze evolution data logger.</param> /// <param name="mazeGenomeLogger">The maze genome logger.</param> public override void Initialize(string name, XmlElement xmlConfig, IDataLogger navigatorEvolutionLogger = null, IDataLogger navigatorGenomeLogger = null, IDataLogger mazeEvolutionLogger = null, IDataLogger mazeGenomeLogger = null) { base.Initialize(name, xmlConfig, navigatorEvolutionLogger, navigatorGenomeLogger, mazeEvolutionLogger, mazeGenomeLogger); // Set experiment-specific parameters _maxTimesteps = XmlUtils.GetValueAsInt(xmlConfig, "MaxTimesteps"); _minSuccessDistance = XmlUtils.GetValueAsInt(xmlConfig, "MinSuccessDistance"); _mazeHeight = XmlUtils.GetValueAsInt(xmlConfig, "MazeHeight"); _mazeWidth = XmlUtils.GetValueAsInt(xmlConfig, "MazeWidth"); _mazeScaleMultiplier = XmlUtils.GetValueAsInt(xmlConfig, "MazeScaleMultiplier"); // Get success/failure criteria constraints _numMazeSuccessCriteria = XmlUtils.GetValueAsInt(xmlConfig, "NumMazesSolvedCriteria"); _numAgentSuccessCriteria = XmlUtils.GetValueAsInt(xmlConfig, "NumAgentsSolvedCriteria"); // Read in log file path/name _navigatorEvolutionDataLogger = navigatorEvolutionLogger ?? ExperimentUtils.ReadDataLogger(xmlConfig, LoggingType.Evolution, "NavigatorLoggingConfig"); _navigatorPopulationGenomesDataLogger = navigatorGenomeLogger ?? ExperimentUtils.ReadDataLogger(xmlConfig, LoggingType.PopulationGenomes, "NavigatorLoggingConfig"); _mazeEvolutionDataLogger = mazeEvolutionLogger ?? ExperimentUtils.ReadDataLogger(xmlConfig, LoggingType.Evolution, "MazeLoggingConfig"); _mazePopulationGenomesDataLogger = mazeGenomeLogger ?? ExperimentUtils.ReadDataLogger(xmlConfig, LoggingType.PopulationGenomes, "MazeLoggingConfig"); // Read in the maximum number of initialization evaluations _maxInitializationEvaluations = XmlUtils.GetValueAsUInt(xmlConfig, "MaxInitializationEvaluations"); // Create new evolution field elements map with all fields enabled _navigatorLogFieldEnableMap = EvolutionFieldElements.PopulateEvolutionFieldElementsEnableMap(); // Also add default population logging configuration foreach ( KeyValuePair<FieldElement, bool> populationLoggingPair in PopulationGenomesFieldElements.PopulatePopulationGenomesFieldElementsEnableMap()) { _navigatorLogFieldEnableMap.Add(populationLoggingPair.Key, populationLoggingPair.Value); } // Disable logging fields not relevant to coevolution experiment _navigatorLogFieldEnableMap[EvolutionFieldElements.SpecieCount] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.AsexualOffspringCount] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.SexualOffspringCount] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.InterspeciesOffspringCount] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MinimalCriteriaThreshold] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MinimalCriteriaPointX] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MinimalCriteriaPointY] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MaxFitness] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MeanFitness] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MeanSpecieChampFitness] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MinSpecieSize] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.MaxSpecieSize] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.ChampGenomeGenomeId] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.ChampGenomeFitness] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.ChampGenomeBirthGeneration] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.ChampGenomeConnectionGeneCount] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.ChampGenomeNeuronGeneCount] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.ChampGenomeTotalGeneCount] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.ChampGenomeEvaluationCount] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.ChampGenomeBehaviorX] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.ChampGenomeBehaviorY] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.ChampGenomeDistanceToTarget] = false; _navigatorLogFieldEnableMap[EvolutionFieldElements.ChampGenomeXml] = false; // Create a maze logger configuration with the same configuration as the navigator one _mazeLogFieldEnableMap = new Dictionary<FieldElement, bool>(_navigatorLogFieldEnableMap); // Make on change to the maze logger configuration to switch off run phase logging _mazeLogFieldEnableMap[EvolutionFieldElements.RunPhase] = false; _mazeLogFieldEnableMap[PopulationGenomesFieldElements.RunPhase] = false; // Read in the number of batches between population logging _populationLoggingBatchInterval = XmlUtils.TryGetValueAsInt(xmlConfig, "PopulationLoggingBatchInterval"); // Initialize the initialization algorithm _mazeNavigationInitializer = ExperimentUtils.DetermineCoevolutionInitializer( xmlConfig.GetElementsByTagName("InitializationAlgorithmConfig", "")[0] as XmlElement); // Setup initialization algorithm _mazeNavigationInitializer.SetAlgorithmParameters( xmlConfig.GetElementsByTagName("InitializationAlgorithmConfig", "")[0] as XmlElement, AnnInputCount, AnnOutputCount, _numAgentSuccessCriteria, 0); // Pass in maze experiment specific parameters // (note that a new maze structure is created here for the sole purpose of extracting the maze dimensions and calculating max distance to target) _mazeNavigationInitializer.SetEnvironmentParameters(_maxTimesteps, _minSuccessDistance, new MazeDecoder(_mazeHeight, _mazeWidth, _mazeScaleMultiplier).Decode( new MazeGenomeFactory(MazeGenomeParameters, null, null).CreateGenome(0))); // Propagate the initialization seed genome size up to the base experiment level // so that we know how to generate the bootstrap population AgentInitializationGenomeCount = _mazeNavigationInitializer.PopulationSize; }
/// <summary> /// Logs the static maze genomes on which all initialization evaluations will be conducted. /// </summary> /// <param name="initializationMazeGenomes">The initialization maze genomes to log.</param> /// <param name="mazeGenomeDataLogger">The maze data logger.</param> public void LogStartingMazeGenomes(List<MazeGenome> initializationMazeGenomes, IDataLogger mazeGenomeDataLogger) { // Open the logger mazeGenomeDataLogger?.Open(); // Write the header mazeGenomeDataLogger?.LogHeader(new List<LoggableElement> { new LoggableElement(PopulationGenomesFieldElements.Generation, null), new LoggableElement(PopulationGenomesFieldElements.GenomeId, null), new LoggableElement(PopulationGenomesFieldElements.GenomeXml, null), new LoggableElement(PopulationGenomesFieldElements.SpecieId, null) }); // Write the genome XML for all initialization genomes foreach (MazeGenome mazeGenome in initializationMazeGenomes) { // Write the genome XML mazeGenomeDataLogger?.LogRow(new List<LoggableElement> { new LoggableElement(PopulationGenomesFieldElements.Generation, mazeGenome.BirthGeneration), new LoggableElement(PopulationGenomesFieldElements.GenomeId, mazeGenome.Id), new LoggableElement(PopulationGenomesFieldElements.GenomeXml, XmlIoUtils.GetGenomeXml(mazeGenome)), new LoggableElement(PopulationGenomesFieldElements.SpecieId, mazeGenome.SpecieIdx) }); } }
/// <summary> /// Sets the data loggers for the initialization process. /// </summary> /// <param name="navigatorEvolutionDataLogger">The logger for evolution statistics.</param> /// <param name="navigatorPopulationDataLogger">The logger for serializing navigator genomes.</param> /// <param name="navigatorEvolutionLogFieldEnableMap">Indicates the enabled/disabled status of the evolution logger fields.</param> /// <param name="populationLoggingInterval">The batch interval at which the current population is serialized to a file.</param> public void SetDataLoggers(IDataLogger navigatorEvolutionDataLogger, IDataLogger navigatorPopulationDataLogger, IDictionary<FieldElement, bool> navigatorEvolutionLogFieldEnableMap, int? populationLoggingInterval) { NavigatorEvolutionDataLogger = navigatorEvolutionDataLogger; NavigatorPopulationDataLogger = navigatorPopulationDataLogger; NavigatorEvolutionLogFieldEnableMap = navigatorEvolutionLogFieldEnableMap; PopulationLoggingBatchInterval = populationLoggingInterval; }
/// <summary> /// Initialize the experiment with configuration file parameters. /// </summary> /// <param name="name">The name of the experiment</param> /// <param name="xmlConfig">The parent XML configuration element</param> /// <param name="evolutionDataLogger">The optional evolution data logger.</param> /// <param name="evaluationDataLogger">The optional evaluation data logger.</param> public virtual void Initialize(string name, XmlElement xmlConfig, IDataLogger evolutionDataLogger, IDataLogger evaluationDataLogger) { // Set all properties Name = name; DefaultPopulationSize = XmlUtils.TryGetValueAsInt(xmlConfig, "PopulationSize") ?? default(int); Description = XmlUtils.GetValueAsString(xmlConfig, "Description"); // Set all internal class variables _activationScheme = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation"); ComplexityRegulationStrategy = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy"); Complexitythreshold = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold"); ParallelOptions = ExperimentUtils.ReadParallelOptions(xmlConfig); SerializeGenomeToXml = XmlUtils.TryGetValueAsBool(xmlConfig, "DecodeGenomesToXml") ?? false; MaxGenerations = XmlUtils.TryGetValueAsInt(xmlConfig, "MaxGenerations"); MaxEvaluations = XmlUtils.TryGetValueAsULong(xmlConfig, "MaxEvaluations"); MaxRestarts = XmlUtils.TryGetValueAsInt(xmlConfig, "MaxRestarts"); // Set evolution/genome parameters NeatEvolutionAlgorithmParameters = ExperimentUtils.ReadNeatEvolutionAlgorithmParameters(xmlConfig); NeatGenomeParameters = ExperimentUtils.ReadNeatGenomeParameters(xmlConfig); NeatGenomeParameters.FeedforwardOnly = _activationScheme.AcyclicNetwork; // Set experiment-specific parameters MaxTimesteps = XmlUtils.GetValueAsInt(xmlConfig, "MaxTimesteps"); MinSuccessDistance = XmlUtils.GetValueAsInt(xmlConfig, "MinSuccessDistance"); MaxDistanceToTarget = XmlUtils.GetValueAsInt(xmlConfig, "MaxDistanceToTarget"); MazeVariant = MazeVariantUtil.convertStringToMazeVariant(XmlUtils.TryGetValueAsString(xmlConfig, "MazeVariant")); }