Beispiel #1
0
        public MasterSystem(ProgramArguments arguments, int size)
        {
            int rank = 0;

            LoadOptimiserParams(arguments);
            sceOptions = SceOptions.RndInSubComplex;
            if (arguments.SceOptions == "full")
            {
                sceOptions |= SceOptions.ReflectionRandomization;
            }

            OutputPath = arguments.OutputPath;
            // Ensure existance of some locations that are assumed to exist when writing the results
            if (!OutputPath.Exists)
            {
                OutputPath.Create();
            }

            RosenbrockIterations            = arguments.RosenbrockIterations.Clamp(MinRosenbrockIterations, MaxRosenbrockIterations);
            WallClock                       = arguments.WallClockHours.Clamp(MinWallClock, MaxWallClock);
            ConvergenceCriterionCvThreshold = arguments.ConvergenceCriterionCvThreshold.Clamp(MinConvergenceThreshold, MaxConvergenceThreshold);
            TerminationCriterion            = (TerminationCriteria)Enum.Parse(typeof(TerminationCriteria), arguments.TerminationCriterion);
            OptimisationMethod              = (OptimisationMethods)Enum.Parse(typeof(OptimisationMethods), arguments.OptimisationMethod);
            SeedParametersFile              = arguments.ParameterDefinitions.FullName;
            LogFileName                     = Path.Combine(arguments.OutputPath.FullName, arguments.LogFile);
            OutputFileName                  = Path.Combine(arguments.OutputPath.FullName, arguments.ResultsFile);
            TemplateParameterSet            = GridModelHelper.LoadParameterSpace(arguments.ParameterDefinitions.FullName);
            MpiSysConfig[] seedsPopulation = GridModelHelper.LoadParameterSets(arguments.SeedParameterSets, TemplateParameterSet);
            evaluator = new MultiCatchmentCompositeObjectiveEvaluator(
                arguments.GlobalDefinition, arguments.ObjectiveDefinition, arguments.CreateCompositeEvaluator(), rank, size);
            InMemoryLogger     = new InMemoryLogger();
            optimisationEngine = CreateEngine(evaluator, TemplateParameterSet, seedsPopulation, InMemoryLogger, arguments.Name, arguments.InitString);
        }
        protected virtual void SetWorkPackage(WorkPackage work)
        {
            MyWork = work;

            // Create the models
            if (MyWork != null && MyWork.Cells.Length > 0)
            {
                Log.DebugFormat("Rank {0}: creating {1} model evaluators", WorldRank, MyWork.Cells.Length);
                Models = new ICatchmentCellModelRunner[MyWork.Cells.Length];
                for (int i = 0; i < MyWork.Cells.Length; i++)
                {
                    CellDefinition cellDefinition = MyWork.Cells[i];
                    Log.DebugFormat("Rank {0}: model instance {1}, catchment {2}, cell {3}", WorldRank, i, cellDefinition.CatchmentId, cellDefinition.Id);
                    var inputs = (TIME.Tools.Metaheuristics.Persistence.Gridded.ModelInputsDefinition)cellDefinition.ModelRunDefinition.Inputs;
                    if (inputs != null && !File.Exists(inputs.NetCdfDataFilename))
                    {
                        string msg = String.Format(
                            "Rank {0}: Input netcdf file '{1}' not found. Catchment: {2}, cell {3}",
                            WorldRank,
                            inputs.NetCdfDataFilename,
                            cellDefinition.CatchmentId,
                            cellDefinition.Id);
                        throw new ConfigurationException(msg);
                    }
#if USE_TOY_MODEL
                    Models[i] = new GriddedCatchmentToyModel(MyWork.Cells[i]);
#else
                    Log.DebugFormat("Rank {0}: creating cell evaluator", rank);
                    Models[i] = GridModelHelper.CreateCellEvaluator(cellDefinition);
                    Log.DebugFormat("Rank {0}: Evaluator created", rank);
#endif
                }
                Log.DebugFormat("Rank {0}: models created", WorldRank);
            }
        }
Beispiel #3
0
        /// <summary>
        ///   Writes the results.
        /// </summary>
        public void WriteResults()
        {
            Log.InfoFormat("Writing in-memory log to '{0}'", LogFileName);
            InMemoryLogger.CsvSerialise(LogFileName, "GriddedCalib");

            Log.InfoFormat("Root: saving final parameters to '{0}'", OutputFileName);
            MetaheuristicsHelper.SaveAsCsv <MpiSysConfig>(Results, OutputFileName);

            string parameterSetPath = Path.Combine(OutputPath.FullName, "BestParamSet.xml");

            Log.InfoFormat("Root: saving reseed parameters to '{0}'", parameterSetPath);
            GridModelHelper.WriteParameters <MpiSysConfig>(Results, SeedParametersFile, parameterSetPath);
        }