public SMPSO(Problem problem, string trueParetoFront)
            : base(problem)
        {
            hy = new HyperVolume();
            MetricsUtil mu = new MetricsUtil();

            trueFront       = mu.ReadNonDominatedSolutionSet(trueParetoFront);
            trueHypervolume = hy.Hypervolume(trueFront.WriteObjectivesToMatrix(),
                                             trueFront.WriteObjectivesToMatrix(),
                                             problem.NumberOfObjectives);

            // Default configuration
            r1Max  = 1.0;
            r1Min  = 0.0;
            r2Max  = 1.0;
            r2Min  = 0.0;
            C1Max  = 2.5;
            C1Min  = 1.5;
            C2Max  = 2.5;
            C2Min  = 1.5;
            WMax   = 0.1;
            WMin   = 0.1;
            ChVel1 = -1;
            ChVel2 = -1;
        }
Пример #2
0
        private void GenerateReferenceParetoFronts()
        {
            var problems      = experiment.ExperimentProblems;
            var referencePath = Path.Combine(experiment.ExperimentBaseDirectory, "ReferenceParetoFront");

            if (!Directory.Exists(referencePath))
            {
                Directory.CreateDirectory(referencePath);
            }

            foreach (var problem in problems)
            {
                if (string.IsNullOrEmpty(problem.ParetoFront))
                {
                    NonDominatedSolutionList solutionSet = new NonDominatedSolutionList();
                    string      file    = Path.Combine(referencePath, problem.Alias + ".pf");
                    MetricsUtil metrics = new MetricsUtil();

                    foreach (var algorithmDictionary in problem.AlgorithmDictionary)
                    {
                        foreach (var algorithm in algorithmDictionary.Value)
                        {
                            metrics.ReadNonDominatedSolutionSet(algorithm.Result.GetObjectives(), solutionSet);
                        }
                    }

                    solutionSet.PrintObjectivesToFile(file);
                    problem.ParetoFront = file;
                }
            }
        }
        public SMPSO(Problem problem,
                     List <double> variables,
                     string trueParetoFront)
            : base(problem)
        {
            r1Max  = variables[0];
            r1Min  = variables[1];
            r2Max  = variables[2];
            r2Min  = variables[3];
            C1Max  = variables[4];
            C1Min  = variables[5];
            C2Max  = variables[6];
            C2Min  = variables[7];
            WMax   = variables[8];
            WMin   = variables[9];
            ChVel1 = variables[10];
            ChVel2 = variables[11];

            hy = new HyperVolume();
            MetricsUtil mu = new MetricsUtil();

            trueFront       = mu.ReadNonDominatedSolutionSet(trueParetoFront);
            trueHypervolume = hy.Hypervolume(trueFront.WriteObjectivesToMatrix(),
                                             trueFront.WriteObjectivesToMatrix(),
                                             problem.NumberOfObjectives);
        }
Пример #4
0
        public override void Init(string contextName, ContextFactory factory)
        {
            base.Init(contextName, factory);
            int nKids;

            try
            {
                string sKids = GetAttribute(ArityLabel);
                nKids = System.Convert.ToInt32(sKids);
            }
            catch (Exception e)
            {
                Log.Error("Unable to initialize composite metric " + contextName + ": could not init arity"
                          , e);
                return;
            }
            for (int i = 0; i < nKids; ++i)
            {
                MetricsContext ctxt = MetricsUtil.GetContext(string.Format(SubFmt, contextName, i
                                                                           ), contextName);
                if (null != ctxt)
                {
                    subctxt.AddItem(ctxt);
                }
            }
        }
Пример #5
0
        private void TestMetricsInstance()
        {
            IMetrics metrics = AppMetrics.CreateDefaultBuilder().Build();

            MetricsUtil.SetMetricsInstance(metrics);

            Assert.Equal(metrics, MetricsUtil.MetricsInstance);
        }
Пример #6
0
        /// <summary>Creates a new instance of JvmMetrics</summary>
        private JvmMetrics(string processName, string sessionId, string recordName)
        {
            MetricsContext context = MetricsUtil.GetContext("jvm");

            metrics = MetricsUtil.CreateRecord(context, recordName);
            metrics.SetTag("processName", processName);
            metrics.SetTag("sessionId", sessionId);
            context.RegisterUpdater(this);
        }
Пример #7
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="problem">The problem</param>
 /// <param name="paretoFrontFile">Pareto front file</param>
 public QualityIndicator(Problem problem, string paretoFrontFile)
 {
     this.problem               = problem;
     Utils                      = new MetricsUtil();
     trueParetoFront            = Utils.ReadNonDominatedSolutionSet(paretoFrontFile);
     TrueParetoFrontHypervolume = new HyperVolume().Hypervolume(
         trueParetoFront.WriteObjectivesToMatrix(),
         trueParetoFront.WriteObjectivesToMatrix(),
         problem.NumberOfObjectives);
 }
Пример #8
0
            public AppEncryptionParameterizedTestData()
            {
                configFixture = new ConfigFixture();

                // We do not log metrics for the Parameterized tests but we still need to set a disabled/no-op metrics
                // instance for the tests to run successfully. This is done below.
                IMetricsRoot metrics = new MetricsBuilder()
                                       .Configuration.Configure(options => options.Enabled = false)
                                       .Build();

                MetricsUtil.SetMetricsInstance(metrics);
            }
Пример #9
0
        internal ShuffleClientMetrics(TaskAttemptID reduceId, JobConf jobConf)
        {
            this.numCopiers = jobConf.GetInt(MRJobConfig.ShuffleParallelCopies, 5);
            MetricsContext metricsContext = MetricsUtil.GetContext("mapred");

            this.shuffleMetrics = MetricsUtil.CreateRecord(metricsContext, "shuffleInput");
            this.shuffleMetrics.SetTag("user", jobConf.GetUser());
            this.shuffleMetrics.SetTag("jobName", jobConf.GetJobName());
            this.shuffleMetrics.SetTag("jobId", reduceId.GetJobID().ToString());
            this.shuffleMetrics.SetTag("taskId", reduceId.ToString());
            this.shuffleMetrics.SetTag("sessionId", jobConf.GetSessionId());
            metricsContext.RegisterUpdater(this);
        }
Пример #10
0
        public LocalJobRunnerMetrics(JobConf conf)
        {
            string sessionId = conf.GetSessionId();

            // Initiate JVM Metrics
            JvmMetrics.Init("JobTracker", sessionId);
            // Create a record for map-reduce metrics
            MetricsContext context = MetricsUtil.GetContext("mapred");

            // record name is jobtracker for compatibility
            metricsRecord = MetricsUtil.CreateRecord(context, "jobtracker");
            metricsRecord.SetTag("sessionId", sessionId);
            context.RegisterUpdater(this);
        }
Пример #11
0
        private static object[] GenerateMocks(KeyState cacheIK, KeyState metaIK, KeyState cacheSK, KeyState metaSK)
        {
            AppEncryptionPartition appEncryptionPartition = new AppEncryptionPartition(
                cacheIK + "CacheIK_" + metaIK + "MetaIK_" + DateTimeUtils.GetCurrentTimeAsUtcIsoDateTimeOffset() + "_" + Random.Next(),
                cacheSK + "CacheSK_" + metaSK + "MetaSK_" + DateTimeUtils.GetCurrentTimeAsUtcIsoDateTimeOffset() + "_" + Random.Next(),
                DefaultProductId);

            // TODO Update to create KeyManagementService based on config/param once we plug in AWS KMS
            KeyManagementService kms = new StaticKeyManagementServiceImpl(KeyManagementStaticMasterKey);

            CryptoKeyHolder cryptoKeyHolder = CryptoKeyHolder.GenerateIKSK();

            // TODO Pass Metastore type to enable spy generation once we plug in external metastore types
            Mock <MemoryPersistenceImpl <JObject> > metastorePersistence = MetastoreMock.CreateMetastoreMock(appEncryptionPartition, kms, metaIK, metaSK, cryptoKeyHolder);

            CacheMock cacheMock = CacheMock.CreateCacheMock(cacheIK, cacheSK, cryptoKeyHolder);

            // Mimics (mostly) the old TimeBasedCryptoPolicyImpl settings
            CryptoPolicy cryptoPolicy = BasicExpiringCryptoPolicy.NewBuilder()
                                        .WithKeyExpirationDays(KeyExpiryDays)
                                        .WithRevokeCheckMinutes(int.MaxValue)
                                        .WithCanCacheIntermediateKeys(false)
                                        .WithCanCacheSystemKeys(false)
                                        .Build();

            SecureCryptoKeyDictionary <DateTimeOffset> intermediateKeyCache = cacheMock.IntermediateKeyCache;
            SecureCryptoKeyDictionary <DateTimeOffset> systemKeyCache       = cacheMock.SystemKeyCache;

            EnvelopeEncryptionJsonImpl envelopeEncryptionJson = new EnvelopeEncryptionJsonImpl(
                appEncryptionPartition,
                metastorePersistence.Object,
                systemKeyCache,
                new FakeSecureCryptoKeyDictionaryFactory <DateTimeOffset>(intermediateKeyCache),
                new BouncyAes256GcmCrypto(),
                cryptoPolicy,
                kms);

            IEnvelopeEncryption <byte[]> envelopeEncryptionByteImpl = new EnvelopeEncryptionBytesImpl(envelopeEncryptionJson);

            // Need to manually set a no-op metrics instance
            IMetrics metrics = new MetricsBuilder()
                               .Configuration.Configure(options => options.Enabled = false)
                               .Build();

            MetricsUtil.SetMetricsInstance(metrics);

            return(new object[] { envelopeEncryptionByteImpl, metastorePersistence, cacheIK, metaIK, cacheSK, metaSK, appEncryptionPartition });
        }
Пример #12
0
            public SessionFactory Build()
            {
                // If no metrics provided, we just create a disabled/no-op one
                if (metrics == null)
                {
                    metrics = new MetricsBuilder()
                              .Configuration.Configure(options => options.Enabled = false)
                              .Build();
                }

                MetricsUtil.SetMetricsInstance(metrics);

                return(new SessionFactory(
                           productId,
                           serviceId,
                           metastore,
                           new SecureCryptoKeyDictionaryFactory <DateTimeOffset>(cryptoPolicy),
                           cryptoPolicy,
                           keyManagementService));
            }
Пример #13
0
        public IDictionary <string, IDictionary <string, IDictionary <string, List <double> > > > GetIndicators()
        {
            GenerateReferenceParetoFronts();

            var         indicators = new Dictionary <string, IDictionary <string, IDictionary <string, List <double> > > >();
            MetricsUtil utils      = new MetricsUtil();

            for (int i = 0, li = experiment.QualityIndicators.Count; i < li; i++)
            {
                string indicatorString = experiment.QualityIndicators[i].ToUpper();
                double value           = 0;

                var problems = new Dictionary <string, IDictionary <string, List <double> > >();
                indicators.Add(indicatorString, problems);

                foreach (var problem in experiment.ExperimentProblems)
                {
                    var algorithm = new Dictionary <string, List <double> >();
                    problems.Add(problem.Alias, algorithm);

                    var trueFront = utils.ReadFront(problem.ParetoFront);

                    foreach (var algorithmDictionary in problem.AlgorithmDictionary)
                    {
                        var indicator = new List <double>();

                        algorithm.Add(algorithmDictionary.Key, indicator);

                        foreach (var alg in algorithmDictionary.Value)
                        {
                            var solutionFront = alg.Result.GetObjectives();

                            switch (indicatorString)
                            {
                            case "HV":
                                HyperVolume hv = new HyperVolume();
                                value = hv.Hypervolume(solutionFront, trueFront, trueFront[0].Length);
                                break;

                            case "SPREAD":
                                Spread spread = new Spread();
                                value = spread.CalculateSpread(solutionFront, trueFront, trueFront[0].Length);
                                break;

                            case "IGD":
                                InvertedGenerationalDistance igd = new InvertedGenerationalDistance();
                                value = igd.CalculateInvertedGenerationalDistance(solutionFront, trueFront, trueFront[0].Length);
                                break;

                            case "EPSILON":
                                Epsilon epsilon = new Epsilon();
                                value = epsilon.CalcualteEpsilon(solutionFront, trueFront, trueFront[0].Length);
                                break;
                            }

                            indicator.Add(value);
                        }
                    }
                }
            }
            return(indicators);
        }
Пример #14
0
        private void TestMetricsInstanceWithNull()
        {
            MetricsUtil.SetMetricsInstance(null);

            Assert.Throws <ArgumentNullException>(() => MetricsUtil.MetricsInstance);
        }
Пример #15
0
 public Spread()
 {
     utils = new MetricsUtil();
 }
Пример #16
0
 public MetricsFixture()
 {
     // Sets default builder to initialize properly for classes under test that use metrics.
     MetricsUtil.SetMetricsInstance(AppMetrics.CreateDefaultBuilder().Build());
 }
 protected override string ConvertValueToString()
 {
     return(MetricsUtil.FormatSize(bytesSent_, 3));
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="problem">Problem to solve</param>
 public SMSEMOA(Problem problem)
     : base(problem)
 {
     utils = new MetricsUtil();
     hv    = new HyperVolume();
 }
 /// <summary>
 /// Constructor.
 /// Creates a new instance of the generational distance metric.
 /// </summary>
 public GenerationalDistance()
 {
     utils = new MetricsUtil();
 }
Пример #20
0
 protected override string ConvertValueToString()
 {
     return(MetricsUtil.FormatSize(cachedSize_, 3));
 }
Пример #21
0
 /// <summary>
 /// Constructor
 /// Creates a new instance of MultiDelta
 /// </summary>
 public HyperVolume()
 {
     utils = new MetricsUtil();
 }