Esempio n. 1
0
        /// <summary>
        /// The GetAlgorithmDeviceConfig
        /// </summary>
        /// <returns>The <see cref="DeviceBenchmarkConfig"/></returns>
        public DeviceBenchmarkConfig GetAlgorithmDeviceConfig()
        {
            DeviceBenchmarkConfig ret = new DeviceBenchmarkConfig
            {
                DeviceName = Name,
                DeviceUUID = UUID
            };

            // init algo settings
            foreach (var algo in AlgorithmSettings)
            {
                // create/setup
                AlgorithmConfig conf = new AlgorithmConfig
                {
                    Name                      = algo.AlgorithmStringID,
                    CryptoMiner937ID          = algo.CryptoMiner937ID,
                    SecondaryCryptoMiner937ID = algo.SecondaryCryptoMiner937ID,
                    MinerBaseType             = algo.MinerBaseType,
                    MinerName                 = algo.MinerName, // TODO probably not needed
                    BenchmarkSpeed            = algo.BenchmarkSpeed,
                    SecondaryBenchmarkSpeed   = algo.SecondaryBenchmarkSpeed,
                    ExtraLaunchParameters     = algo.ExtraLaunchParameters,
                    Enabled                   = algo.Enabled,
                    LessThreads               = algo.LessThreads
                };
                // insert
                ret.AlgorithmSettings.Add(conf);
            }
            return(ret);
        }
Esempio n. 2
0
        public AlgorithmResult Run(AlgorithmConfig cfg)
        {
            InitDataFromConfig(cfg);

            var res = cfg.AlgorithmType switch {
                AlgorithmType.Length => RunLengthAlgorithm(cfg.MethodType),
                AlgorithmType.Cost => RunCostAlgorithm(cfg.MethodType),
                AlgorithmType.Time => RunTimeAlgorithm(cfg.MethodType),
                AlgorithmType.ComplexCost => RunComplexCostAlgorithm(cfg.MethodType),
                _ => null
            };

            if (res == null)
            {
                return(null);
            }

            res.AlgorithmConfig = cfg;
            foreach (var n in res.Nodes)
            {
                n.Name = _cities.First(c => c.Id == n.Id).Name;
            }

            return(res);
        }
Esempio n. 3
0
        public DeviceBenchmarkConfig GetAlgorithmDeviceConfig()
        {
            DeviceBenchmarkConfig ret = new DeviceBenchmarkConfig();

            ret.DeviceName = this.Name;
            ret.DeviceUUID = this.UUID;
            // init algo settings
            foreach (var algo in this.AlgorithmSettings)
            {
                // create/setup
                AlgorithmConfig conf = new AlgorithmConfig();
                conf.Name                    = algo.AlgorithmStringID;
                conf.NiceHashID              = algo.NiceHashID;
                conf.SecondaryNiceHashID     = algo.SecondaryNiceHashID;
                conf.MinerBaseType           = algo.MinerBaseType;
                conf.MinerName               = algo.MinerName; // TODO probably not needed
                conf.BenchmarkSpeed          = algo.BenchmarkSpeed;
                conf.SecondaryBenchmarkSpeed = algo.SecondaryBenchmarkSpeed;
                conf.ExtraLaunchParameters   = algo.ExtraLaunchParameters;
                conf.Enabled                 = algo.Enabled;
                conf.LessThreads             = algo.LessThreads;
                // insert
                ret.AlgorithmSettings.Add(conf);
            }
            return(ret);
        }
Esempio n. 4
0
        private void learnButton_Click(object sender, EventArgs e)
        {
            outputBox.AppendText("Learning process is started!\n");
            this.Refresh();

            Vector[] learnVectors = GetInputVectors("learn-data.txt");
            if (learnVectors != null)
            {
                int      classesCount = defineExpValue(learnVectors);
                double[] minX         = (double[])learnVectors[0].input.Clone();
                double[] maxX         = (double[])learnVectors[0].input.Clone();
                defMinMax(ref minX, ref maxX, learnVectors);
                NormalizeVectors(ref learnVectors, minX, maxX);
                int    cyclesCount           = (int)learningCycles.Value;
                double rateCount             = (double)learningSpeed.Value;
                double minError              = (double)minimalError.Value;
                MinimizationFunction minFunc = new MinimizationFunction();
                configuration = new AlgorithmConfig
                {
                    BatchSize     = 1,
                    ErrorFunction = minFunc,
                    LearningRate  = rateCount,
                    MaxCycles     = cyclesCount,
                    MinError      = minError
                };
                testWithParametr(configuration, learnVectors, classesCount);
            }
        }
Esempio n. 5
0
        public bool CheckTransportSystems(AlgorithmConfig cfg)
        {
            InitDataFromConfig(cfg);
            var graph = new SimpleGraph(_cities.Select(c => c.Id), null);

            foreach (var road in _roads)
            {
                graph.AddEdge(road.ToCityId, road.FromCityId, road.Id);
            }

            return(graph.ValidationCheck(_centralCities.Select(c => c.Id)));
        }
Esempio n. 6
0
        private void testWithParametr(AlgorithmConfig configuration, Vector[] learnVectors, int classes)
        {
            neuronsCount = null;
            int layersCount = (int)hiddenLayers.Value + 1;

            switch (layersCount)
            {
            case 2:
            {
                neuronsCount    = new int[1];
                neuronsCount[0] = (int)firstLayerNeurons.Value;
            } break;

            case 3:
            {
                neuronsCount    = new int[2];
                neuronsCount[0] = (int)firstLayerNeurons.Value;
                neuronsCount[1] = (int)secondtLayerNeurons.Value;
            } break;

            case 4:
            {
                neuronsCount    = new int[3];
                neuronsCount[0] = (int)firstLayerNeurons.Value;
                neuronsCount[1] = (int)secondtLayerNeurons.Value;
                neuronsCount[2] = (int)thirdtLayerNeurons.Value;
            } break;
            }

            beta  = 0.7;
            myNet = new NeuralNetwork(layersCount, neuronsCount, learnVectors[0].input.Length, classes, beta);
            List <Vector> data = new List <Vector>(learnVectors.Length);

            data.AddRange(learnVectors);
            switch (algorithmBox.SelectedIndex)
            {
            case 0:
            {
                BackPropagation method = new BackPropagation(configuration);
                method.RaiseMessageEvent += AddMessage;
                method.Train(myNet, data);
                break;
            }

            case 1:
            {
                QuickProp method = new QuickProp(configuration);
                method.RaiseMessageEvent += AddMessage;
                method.Train(myNet, data);
                break;
            }
            }
        }
Esempio n. 7
0
        protected virtual Action <Run <T> > Start()
        {
            return(message =>
            {
                log.Info("Start Algorithm");

                _algorithmConfig = message.AlgorithmConfig;
                _creatorActorCreator.CreateChild(nameof(Population <T>));
                _population = Context.ActorOf(_creatorActorCreator.GetChild(nameof(Population <T>), Context), nameof(Population <T>));

                _population.Tell(new InitializePopulation(_algorithmConfig.NumberOfChromosomes));
            });
        }
Esempio n. 8
0
        public DeviceBenchmarkConfig GetAlgorithmDeviceConfig()
        {
            var ret = new DeviceBenchmarkConfig
            {
                DeviceName = Name,
                DeviceUUID = Uuid
            };

            // init algo settings
            foreach (var algo in AlgorithmSettings)
            {
                // create/setup
                var conf = new AlgorithmConfig
                {
                    Name                  = algo.AlgorithmStringID,
                    NiceHashID            = algo.NiceHashID,
                    MinerBaseType         = algo.MinerBaseType,
                    MinerName             = algo.MinerName,
                    BenchmarkSpeed        = algo.BenchmarkSpeed,
                    ExtraLaunchParameters = algo.ExtraLaunchParameters,
                    Enabled               = algo.Enabled,
                    LessThreads           = algo.LessThreads,
                    PowerUsage            = algo.PowerUsage
                };
                // insert
                ret.AlgorithmSettings.Add(conf);
                if (algo is DualAlgorithm dualAlgo)
                {
                    conf.SecondaryNiceHashID     = dualAlgo.SecondaryNiceHashID;
                    conf.SecondaryBenchmarkSpeed = dualAlgo.SecondaryBenchmarkSpeed;

                    DualAlgorithmConfig dualConf = new DualAlgorithmConfig
                    {
                        Name = algo.AlgorithmStringID,
                        SecondaryNiceHashID      = dualAlgo.SecondaryNiceHashID,
                        IntensitySpeeds          = dualAlgo.IntensitySpeeds,
                        SecondaryIntensitySpeeds = dualAlgo.SecondaryIntensitySpeeds,
                        TuningEnabled            = dualAlgo.TuningEnabled,
                        TuningStart        = dualAlgo.TuningStart,
                        TuningEnd          = dualAlgo.TuningEnd,
                        TuningInterval     = dualAlgo.TuningInterval,
                        IntensityPowers    = dualAlgo.IntensityPowers,
                        UseIntensityPowers = dualAlgo.UseIntensityPowers
                    };

                    ret.DualAlgorithmSettings.Add(dualConf);
                }
            }

            return(ret);
        }
Esempio n. 9
0
        internal int GetCompetitionResult(IChromosome chromosome1, IChromosome chromosome2, int count = 1)
        {
            var config1 = new AlgorithmConfig(chromosome1);
            var config2 = new AlgorithmConfig(chromosome2);

            var configString1 = config1.ToString();
            var configString2 = config2.ToString();

            var result = PowerChecker.GetPowerResult(configString1, configString2, count, Program.CheckedFactoryNum, Program.CheckedFactoryNum);

            //throw new NotImplementedException();
            Log.Information("Result: {@result}/{@count}. Between: '{@chromosome1}' & '{@chromosome2}'", result, count, configString1, configString2);

            return(result);
        }
 public void SetAlgorithmDeviceConfig(DeviceBenchmarkConfig config)
 {
     if (config != null && config.DeviceUUID == UUID && config.AlgorithmSettings != null)
     {
         foreach (var algoSetting in config.AlgorithmSettings)
         {
             AlgorithmType   key  = algoSetting.Key;
             AlgorithmConfig conf = algoSetting.Value;
             if (this.AlgorithmSettings.ContainsKey(key))
             {
                 this.AlgorithmSettings[key].BenchmarkSpeed        = conf.BenchmarkSpeed;
                 this.AlgorithmSettings[key].ExtraLaunchParameters = conf.ExtraLaunchParameters;
                 this.AlgorithmSettings[key].Skip        = conf.Skip;
                 this.AlgorithmSettings[key].LessThreads = conf.LessThreads;
             }
         }
     }
 }
        public TaskSpecificationDialog()
        {
            InitializeComponent();
            Owner = App.Window;
            Icon  = AppResources.GetAppIcon;

            _availableTransportSystems = App.DataBase.GetCollection <TransportSystem>().FindAll().ToList();
            _availableCityTags         = App.DataBase.GetCollection <CityTags>().FindOne(ct => ct.IsPrimary);
            _availableRoadTypes        = App.DataBase.GetCollection <RoadTypes>().FindOne(rt => rt.IsPrimary);

            _config = App.DataBase.GetCollection <AlgorithmConfig>().FindOne(a => a.IsPrimary);

            InitTransportSystemsProperty();
            InitAlgorithmTypeProperty();
            InitMethodTypeProperty();
            InitCityTagsProperty();
            InitUnusedRoadTypesProperty();

            Closed += (sender, args) => CancelClick();
        }
        public DeviceBenchmarkConfig GetAlgorithmDeviceConfig()
        {
            DeviceBenchmarkConfig ret = new DeviceBenchmarkConfig();

            ret.DeviceName = this.Name;
            ret.DeviceUUID = this.UUID;
            // init algo settings
            foreach (var algo in this.AlgorithmSettings.Values)
            {
                AlgorithmType key = algo.NiceHashID;
                // create/setup
                AlgorithmConfig conf = new AlgorithmConfig();
                conf.NiceHashID            = key;
                conf.MinerName             = algo.MinerName; // TODO probably not needed
                conf.BenchmarkSpeed        = algo.BenchmarkSpeed;
                conf.ExtraLaunchParameters = algo.ExtraLaunchParameters;
                conf.Skip        = algo.Skip;
                conf.LessThreads = algo.LessThreads;
                // insert
                ret.AlgorithmSettings[key] = conf;
            }
            return(ret);
        }
Esempio n. 13
0
 private void InitDataFromConfig(AlgorithmConfig cfg)
 {
     _transportSystems = App.DataBase
                         .GetCollection <TransportSystem>()
                         .FindAll()
                         .Where(ts => cfg.TransportSystems.Contains(ts))
                         .Select(ts => ts.Id)
                         .ToList();
     _cities = App.DataBase
               .GetCollection <City>()
               .FindAll()
               .Where(c => c.TransportSystemIds.Any(cc => cfg.TransportSystems.Select(ts => ts.Id).Contains(cc)))
               .ToList();
     _roads = App.DataBase
              .GetCollection <Road>()
              .FindAll()
              .Where(r => !cfg.RoadTypes.Select(rt => rt.Name).Contains(r.RoadType.Name))
              .Where(r => cfg.TransportSystems.Select(ts => ts.Id).Contains(r.TransportSystemId))
              .ToList();
     _centralCities = _cities
                      .Where(c => c.Tags.Select(ct => ct.Name)
                             .Any(ctName => cfg.CityTags.Select(ctt => ctt.Name).Contains(ctName)))
                      .ToList();
 }
        public DeviceBenchmarkConfig GetAlgorithmDeviceConfig()
        {
            var ret = new DeviceBenchmarkConfig
            {
                DeviceName = Name,
                DeviceUUID = Uuid
            };

            // init algo settings
            foreach (var algo in AlgorithmSettings)
            {
                if (algo is PluginAlgorithm pluginAlgo)
                {
                    var pluginConf = new PluginAlgorithmConfig
                    {
                        Name                  = pluginAlgo.PluginName,
                        PluginUUID            = pluginAlgo.BaseAlgo.MinerID,
                        AlgorithmIDs          = pluginAlgo.BaseAlgo.IDs.ToList(),
                        Enabled               = pluginAlgo.Enabled,
                        ExtraLaunchParameters = pluginAlgo.ExtraLaunchParameters,
                        PluginVersion         = "N/A",
                        PowerUsage            = pluginAlgo.PowerUsage,
                        // TODO dual not supported ATM
                        Speeds = new List <double> {
                            pluginAlgo.BenchmarkSpeed
                        }
                    };
                    ret.PluginAlgorithmSettings.Add(pluginConf);
                    continue;
                }
                // create/setup
                var conf = new AlgorithmConfig
                {
                    Name                  = algo.AlgorithmStringID,
                    NiceHashID            = algo.NiceHashID,
                    MinerBaseType         = algo.MinerBaseType,
                    MinerName             = algo.MinerName,
                    BenchmarkSpeed        = algo.BenchmarkSpeed,
                    ExtraLaunchParameters = algo.ExtraLaunchParameters,
                    Enabled               = algo.Enabled,
                    LessThreads           = algo.LessThreads,
                    PowerUsage            = algo.PowerUsage
                };
                // insert
                ret.AlgorithmSettings.Add(conf);
                if (algo is DualAlgorithm dualAlgo)
                {
                    conf.SecondaryNiceHashID     = dualAlgo.SecondaryNiceHashID;
                    conf.SecondaryBenchmarkSpeed = dualAlgo.SecondaryBenchmarkSpeed;

                    DualAlgorithmConfig dualConf = new DualAlgorithmConfig
                    {
                        Name = algo.AlgorithmStringID,
                        SecondaryNiceHashID      = dualAlgo.SecondaryNiceHashID,
                        IntensitySpeeds          = dualAlgo.IntensitySpeeds,
                        SecondaryIntensitySpeeds = dualAlgo.SecondaryIntensitySpeeds,
                        TuningEnabled            = dualAlgo.TuningEnabled,
                        TuningStart        = dualAlgo.TuningStart,
                        TuningEnd          = dualAlgo.TuningEnd,
                        TuningInterval     = dualAlgo.TuningInterval,
                        IntensityPowers    = dualAlgo.IntensityPowers,
                        UseIntensityPowers = dualAlgo.UseIntensityPowers
                    };

                    ret.DualAlgorithmSettings.Add(dualConf);
                }
            }

            return(ret);
        }
Esempio n. 15
0
 public Run(AlgorithmConfig <T> algorithmConfig)
 {
     AlgorithmConfig = algorithmConfig;
 }