Esempio n. 1
0
        public TileSharpSource(ILabelOverlapPreventer overlapPreventer, IFeatureCache featureCache, LayerConfig layerConfig)
        {
            IsAsync = true;

            _overlapPreventer = overlapPreventer;
            _featureCache = featureCache;
            _layerConfig = layerConfig;
        }
Esempio n. 2
0
        public void UpdateArcGISLayer(ArcGISConfig layer)
        {
            LayerConfig layerConfig = this.readLayerConfigFromFile();
            var         index       = layerConfig.arcgislayers.FindIndex(item => item.id == layer.id);

            if (index != -1)
            {
                layerConfig.arcgislayers[index] = layer;
            }
            this.saveLayerConfigToFile(layerConfig);
        }
Esempio n. 3
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="config">The data layer settings.</param>
 /// <param name="mods">Handles access to the supported mod integrations.</param>
 public MachineLayer(LayerConfig config, ModIntegrations mods)
     : base(I18n.Machines_Name(), config)
 {
     this.Legend = new[]
     {
         this.Empty      = new LegendEntry(I18n.Keys.Machines_Empty, Color.Red),
         this.Processing = new LegendEntry(I18n.Keys.Machines_Processing, Color.Orange),
         this.Finished   = new LegendEntry(I18n.Keys.Machines_Finished, Color.Green)
     };
     this.Mods = mods;
 }
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="translations">Provides translations in stored in the mod folder's i18n folder.</param>
 /// <param name="config">The data layer settings.</param>
 public AccessibilityLayer(ITranslationHelper translations, LayerConfig config)
     : base(translations.Get("accessibility.name"), config)
 {
     this.Legend = new[]
     {
         new LegendEntry(translations.Get("accessibility.clear"), this.ClearColor),
         new LegendEntry(translations.Get("accessibility.occupied"), this.OccupiedColor),
         new LegendEntry(translations.Get("accessibility.impassable"), this.ImpassableColor),
         new LegendEntry(translations.Get("accessibility.warp"), this.WarpColor)
     };
 }
Esempio n. 5
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="translations">Provides translations in stored in the mod folder's i18n folder.</param>
 /// <param name="config">The data layer settings.</param>
 /// <param name="mods">Handles access to the supported mod integrations.</param>
 public MachineLayer(ITranslationHelper translations, LayerConfig config, ModIntegrations mods)
     : base(translations.Get("machines.name"), config)
 {
     this.Legend = new[]
     {
         this.Empty      = new LegendEntry(translations, "machines.empty", Color.Red),
         this.Processing = new LegendEntry(translations, "machines.processing", Color.Orange),
         this.Finished   = new LegendEntry(translations, "machines.finished", Color.Green)
     };
     this.Mods = mods;
 }
Esempio n. 6
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="translations">Provides translations in stored in the mod folder's i18n folder.</param>
 /// <param name="config">The data layer settings.</param>
 /// <param name="input">The API for checking input state.</param>
 /// <param name="monitor">Writes messages to the SMAPI log.</param>
 public AccessibleLayer(ITranslationHelper translations, LayerConfig config, IInputHelper input, IMonitor monitor)
     : base(translations.Get("accessible.name"), config, input, monitor)
 {
     this.Legend = new[]
     {
         this.Clear      = new LegendEntry(translations, "accessible.clear", Color.Green),
         this.Occupied   = new LegendEntry(translations, "accessible.occupied", Color.Orange),
         this.Impassable = new LegendEntry(translations, "accessible.impassable", Color.Red),
         this.Warp       = new LegendEntry(translations, "accessible.warp", Color.Blue)
     };
 }
Esempio n. 7
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="translations">Provides translations in stored in the mod folder's i18n folder.</param>
 /// <param name="config">The data layer settings.</param>
 /// <param name="input">The API for checking input state.</param>
 /// <param name="monitor">Writes messages to the SMAPI log.</param>
 public TillableLayer(ITranslationHelper translations, LayerConfig config, IInputHelper input, IMonitor monitor)
     : base(translations.Get("tillable.name"), config, input, monitor)
 {
     this.Legend = new[]
     {
         this.Tilled      = new LegendEntry(translations, "tillable.tilled", Color.DarkMagenta),
         this.Tillable    = new LegendEntry(translations, "tillable.tillable", Color.Green),
         this.Occupied    = new LegendEntry(translations, "tillable.occupied", Color.Orange),
         this.NonTillable = new LegendEntry(translations, "tillable.not-tillable", Color.Red)
     };
 }
Esempio n. 8
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="config">The data layer settings.</param>
 /// <param name="input">The API for checking input state.</param>
 /// <param name="monitor">Writes messages to the SMAPI log.</param>
 public TillableLayer(LayerConfig config, IInputHelper input, IMonitor monitor)
     : base(I18n.Tillable_Name(), config, input, monitor)
 {
     this.Legend = new[]
     {
         this.Tilled      = new LegendEntry(I18n.Keys.Tillable_Tilled, Color.DarkMagenta),
         this.Tillable    = new LegendEntry(I18n.Keys.Tillable_Tillable, Color.Green),
         this.Occupied    = new LegendEntry(I18n.Keys.Tillable_Occupied, Color.Orange),
         this.NonTillable = new LegendEntry(I18n.Keys.Tillable_NotTillable, Color.Red)
     };
 }
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="translations">Provides translations in stored in the mod folder's i18n folder.</param>
 /// <param name="config">The data layer settings.</param>
 /// <param name="mods">Handles access to the supported mod integrations.</param>
 public MachineLayer(ITranslationHelper translations, LayerConfig config, ModIntegrations mods)
     : base(translations.Get("machines.name"), config)
 {
     this.Legend = new[]
     {
         new LegendEntry(translations.Get("machines.empty"), this.EmptyColor),
         new LegendEntry(translations.Get("machines.processing"), this.ProcessingColor),
         new LegendEntry(translations.Get("machines.finished"), this.FinishedColor)
     };
     this.Mods = mods;
 }
Esempio n. 10
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="translations">Provides translations in stored in the mod folder's i18n folder.</param>
        /// <param name="config">The data layer settings.</param>
        /// <param name="input">The API for checking input state.</param>
        /// <param name="monitor">Writes messages to the SMAPI log.</param>
        public BeeHouseLayer(ITranslationHelper translations, LayerConfig config, IInputHelper input, IMonitor monitor)
            : base(translations.Get("bee-houses.name"), config, input, monitor)
        {
            this.Legend = new[]
            {
                this.Covered = new LegendEntry(translations, "bee-houses.range", Color.Green)
            };

            this.RelativeRange = BeeHouseLayer
                                 .GetRelativeCoverage()
                                 .ToArray();
        }
Esempio n. 11
0
        /// <summary>
        /// Add vector layer to config.
        /// </summary>
        /// <param name="vectorConfig"></param>
        internal void AddVectorLayer(VectorConfig layer)
        {
            LayerConfig layerConfig = this.readLayerConfigFromFile();

            layer.id = this.GenerateLayerId(layerConfig).ToString();
            if (layerConfig.vectorlayers == null)
            {
                layerConfig.vectorlayers = new List <VectorConfig>();
            }
            layerConfig.vectorlayers.Add(layer);
            this.saveLayerConfigToFile(layerConfig);
        }
Esempio n. 12
0
        internal void UpdateExtendedWMSLayer(ExtendedWmsConfig layer)
        {
            LayerConfig layerConfig = this.readLayerConfigFromFile();

            var index = layerConfig.extendedwmslayers.FindIndex(item => item.id == layer.id);

            if (index != -1)
            {
                layerConfig.extendedwmslayers[index] = layer;
            }
            this.saveLayerConfigToFile(layerConfig);
        }
Esempio n. 13
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="config">The data layer settings.</param>
        public BeeHouseLayer(LayerConfig config)
            : base(I18n.BeeHouses_Name(), config)
        {
            this.Legend = new[]
            {
                this.Covered = new LegendEntry(I18n.Keys.BeeHouses_Range, Color.Green)
            };

            this.RelativeRange = BeeHouseLayer
                                 .GetRelativeCoverage()
                                 .ToArray();
        }
Esempio n. 14
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="translations">Provides translations in stored in the mod folder's i18n folder.</param>
        /// <param name="config">The data layer settings.</param>
        /// <param name="hasBeeHouseFlowerRangeFix">Whether the player has the Bee House Flower Range Fix mod.</param>
        public BeeHouseLayer(ITranslationHelper translations, LayerConfig config, bool hasBeeHouseFlowerRangeFix)
            : base(translations.Get("bee-houses.name"), config)
        {
            this.Legend = new[]
            {
                new LegendEntry(translations.Get("bee-houses.range"), this.CoveredColor)
            };

            this.RelativeRange = BeeHouseLayer
                                 .GetRelativeCoverage(maxLoops: hasBeeHouseFlowerRangeFix ? 166 : 150)
                                 .ToArray();
        }
Esempio n. 15
0
            public Life(List <Life> world, double X, double Y, List <LayerConfig> newgen = null, Life parent = null)
            {
                x  = X;
                y  = Y;
                pL = pR = pB = pT = 0.0;
                sL = sR = sB = sT = 0.0;
                network.AddLayer(new BasicLayer(null, true, 4)); //создание простой многослойной нейронной сети

                if (newgen == null)
                {
                    int maxlayers = 3 + rnd.Next(15);
                    for (int i = 0; i < maxlayers; i++)
                    {
                        bool bias  = rnd.NextDouble() >= 0.5;
                        var  layer = new LayerConfig((byte)rnd.Next(0, 16), bias, rnd.Next(100) + 10);
                        genotype.Add(layer);
                    }
                }
                else
                {
                    genotype = Mutate(newgen);
                }

                AddLayers(genotype);
                if (parent != null)
                {
                    for (int i = 0; i < parent.Memory.Count; i++)
                    {
                        if (rnd.NextDouble() > 0.5)
                        {
                            Memory.Add(parent.Memory[i]);
                            MemorySense.Add(parent.MemorySense[i]);
                        }
                    }
                }
                //network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationSigmoid(), false, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationSoftMax(), false, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationSoftMax (), true, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationSoftMax(), false, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationSoftMax(), true, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationStep (), false, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationStep(), true, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationStep(), false, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, rnd.Next(100) + 10));
                network.AddLayer(new BasicLayer(new ActivationSigmoid(), false, 4));

                network.Structure.FinalizeStructure();
                network.Reset();
                World = world;
            }
Esempio n. 16
0
    protected override void SetUp(LayerConfig config)
    {
        // Config files for random layers MUST define these properties
        blockToPlace = world.blockProvider.GetBlock(properties["blockName"]);

        if (properties.ContainsKey("blockColors"))
        {
            string[] colors = properties["blockColors"].Split(',');
            ((ColoredBlock)blockToPlace).color = new Color(byte.Parse(colors[0]) / 255f, byte.Parse(colors[1]) / 255f, byte.Parse(colors[2]) / 255f);
        }

        chance = float.Parse(properties["chance"]);
    }
Esempio n. 17
0
        /// <summary>
        /// Add wmts layer
        /// </summary>
        /// <param name="layer"></param>
        public void AddWMTSLayer(WMTSConfig layer)
        {
            LayerConfig layerConfig = this.readLayerConfigFromFile();

            layer.id = this.GenerateLayerId(layerConfig).ToString();
            if (layerConfig.wmtslayers == null)
            {
                layerConfig.wmtslayers = new List <WMTSConfig>();
            }
            layerConfig.wmtslayers.Add(layer);

            this.saveLayerConfigToFile(layerConfig);
        }
        private void updateLayer(ILayer l, int step, float min, float max, long version)
        {
            var lc = new LayerConfig(l, step, min, max, version);

            if (l == null || _layer.Equals(lc))
            {
                return;
            }

            _layer       = lc;
            mapGfxObject = MapGfxObject.LoadFromLayer(l, step, min, max);
            mapGfxObject.CalculateNormals();
        }
Esempio n. 19
0
        /// <summary>
        /// Remove vector layer from config.
        /// </summary>
        /// <param name="id"></param>
        internal void RemoveVectorLayer(string id)
        {
            LayerConfig layerConfig = this.readLayerConfigFromFile();

            this.removeLayerFromConfig(id);
            var index = layerConfig.vectorlayers.FindIndex(item => item.id == id);

            if (index != -1)
            {
                layerConfig.vectorlayers.RemoveAt(index);
            }
            this.saveLayerConfigToFile(layerConfig);
        }
Esempio n. 20
0
        /// <summary>
        /// Add arcgis layer
        /// </summary>
        /// <param name="layer"></param>
        internal void AddArcGISLayer(ArcGISConfig layer)
        {
            LayerConfig layerConfig = this.readLayerConfigFromFile();

            layer.id = this.GenerateLayerId(layerConfig).ToString();
            if (layerConfig.arcgislayers == null)
            {
                layerConfig.arcgislayers = new List <ArcGISConfig>();
            }
            layerConfig.arcgislayers.Add(layer);

            this.saveLayerConfigToFile(layerConfig);
        }
Esempio n. 21
0
        /// <summary>
        /// Remove WMS-layer
        /// </summary>
        /// <param name="id"></param>
        public void RemoveWMSLayer(string id)
        {
            LayerConfig layerConfig = this.readLayerConfigFromFile();

            this.removeLayerFromConfig(id);
            var index = layerConfig.wmslayers.FindIndex(item => item.id == id);

            if (index != -1)
            {
                layerConfig.wmslayers.RemoveAt(index);
            }
            this.saveLayerConfigToFile(layerConfig);
        }
Esempio n. 22
0
        internal void RemoveExtendedWMSLayer(string layerId)
        {
            LayerConfig layerConfig = this.readLayerConfigFromFile();

            this.removeLayerFromConfig(layerId);
            var index = layerConfig.extendedwmslayers.FindIndex(item => item.id == layerId);

            if (index != -1)
            {
                layerConfig.extendedwmslayers.RemoveAt(index);
            }
            this.saveLayerConfigToFile(layerConfig);
        }
Esempio n. 23
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="layerConfig"></param>
 private void saveLayerConfigToFile(LayerConfig layerConfig)
 {
     try
     {
         string file       = String.Format("{0}App_Data\\{1}", HostingEnvironment.ApplicationPhysicalPath, this.layerFile);
         string jsonOutput = JsonConvert.SerializeObject(layerConfig, Formatting.Indented);
         System.IO.File.WriteAllText(file, jsonOutput);
     }
     catch (Exception e)
     {
         _log.ErrorFormat("Exception in saveLayerConfigToFile: {0}", e.Message);
         throw e;
     }
 }
Esempio n. 24
0
    protected override void SetUp(LayerConfig config)
    {
        // Config files for random layers MUST define these properties
        chance = float.Parse(properties["chance"]);

        var structureType = Type.GetType(config.structure + ", " + typeof(GeneratedStructure).Assembly, false);

        if (structureType == null)
        {
            Debug.LogError("Could not create structure " + config.structure);
        }

        structure = (GeneratedStructure)Activator.CreateInstance(structureType);
    }
Esempio n. 25
0
    private TerrainLayer[] ProcessConfigs(World world, string layerFolder)
    {
        var configLoader = new ConfigLoader <LayerConfig>(new[] { layerFolder });

        List <LayerConfig>  layersConfigs = new List <LayerConfig>(configLoader.AllConfigs());
        List <TerrainLayer> layers        = new List <TerrainLayer>(layersConfigs.Count);
        HashSet <int>       indexes       = new HashSet <int>();

        for (int i = 0; i < layersConfigs.Count;)
        {
            LayerConfig config = layersConfigs[i];

            // Ignore broken configs
            var type = Type.GetType(config.layerType + ", " + typeof(Block).Assembly, false);
            if (type == null)
            {
                Debug.LogError("Could not create layer " + config.layerType + " : " + config.name);
                layersConfigs.RemoveAt(i);
                continue;
            }

            // Set layers up
            TerrainLayer layer = (TerrainLayer)Activator.CreateInstance(type);
            layer.BaseSetUp(config, world, this);

            // Do not allow any two layers share the same index
            if (indexes.Contains(layer.index))
            {
                Debug.LogError("Could not create layer " + config.layerType + " : " + config.name + ". Index " + layer.index + " already defined");
                layersConfigs.RemoveAt(i);
                continue;
            }

            // Add layer to layers list
            layers.Add(layer);
            indexes.Add(layer.index);

            ++i;
        }

        // Call OnInit for each layer now that they all have been set up. Thanks to this, layers can
        // e.g. address other layers knowing that they will be able to access all data they need.
        for (int i = 0; i < layersConfigs.Count; i++)
        {
            LayerConfig config = layersConfigs[i];
            layers[i].Init(config);
        }

        return(layers.ToArray());
    }
Esempio n. 26
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="config">The data layer settings.</param>
        /// <param name="mods">Handles access to the supported mod integrations.</param>
        public JunimoHutLayer(LayerConfig config, ModIntegrations mods)
            : base(I18n.JunimoHuts_Name(), config)
        {
            // init
            this.Mods   = mods;
            this.Legend = new[]
            {
                this.Covered    = new LegendEntry(I18n.Keys.JunimoHuts_CanHarvest, Color.Green),
                this.NotCovered = new LegendEntry(I18n.Keys.JunimoHuts_CannotHarvest, Color.Red)
            };

            // set max radius
            this.MaxRadius = mods.BetterJunimos.IsLoaded
                ? mods.BetterJunimos.MaxRadius
                : JunimoHut.cropHarvestRadius;
        }
Esempio n. 27
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="translations">Provides translations in stored in the mod folder's i18n folder.</param>
        /// <param name="config">The data layer settings.</param>
        /// <param name="mods">Handles access to the supported mod integrations.</param>
        /// <param name="input">The API for checking input state.</param>
        /// <param name="monitor">Writes messages to the SMAPI log.</param>
        public JunimoHutLayer(ITranslationHelper translations, LayerConfig config, ModIntegrations mods, IInputHelper input, IMonitor monitor)
            : base(translations.Get("junimo-huts.name"), config, input, monitor)
        {
            // init
            this.Mods   = mods;
            this.Legend = new[]
            {
                this.Covered    = new LegendEntry(translations, "junimo-huts.can-harvest", Color.Green),
                this.NotCovered = new LegendEntry(translations, "junimo-huts.cannot-harvest", Color.Red)
            };

            // set max radius
            this.MaxRadius = mods.BetterJunimos.IsLoaded
                ? mods.BetterJunimos.MaxRadius
                : JunimoHut.cropHarvestRadius;
        }
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="translations">Provides translations in stored in the mod folder's i18n folder.</param>
        /// <param name="config">The data layer settings.</param>
        /// <param name="mods">Handles access to the supported mod integrations.</param>
        public JunimoHutLayer(ITranslationHelper translations, LayerConfig config, ModIntegrations mods)
            : base(translations.Get("junimo-huts.name"), config)
        {
            // init
            this.Mods   = mods;
            this.Legend = new[]
            {
                new LegendEntry(translations.Get("junimo-huts.can-harvest"), this.CoveredColor),
                new LegendEntry(translations.Get("junimo-huts.cannot-harvest"), this.NotCoveredColor)
            };

            // set max radius
            this.MaxRadius = mods.BetterJunimos.IsLoaded
                ? mods.BetterJunimos.MaxRadius
                : JunimoHut.cropHarvestRadius;
        }
Esempio n. 29
0
    public void BaseSetUp(LayerConfig config, World world, TerrainGen terrainGen)
    {
        this.terrainGen = terrainGen;
        layerName       = config.name;
        isStructure     = config.structure != null;
        this.world      = world;
        noiseGen        = terrainGen.noise;
        index           = config.index;

        foreach (var key in config.properties.Keys)
        {
            properties.Add(key.ToString(), config.properties[key].ToString());
        }

        SetUp(config);
    }
Esempio n. 30
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="config">The data layer settings.</param>
        /// <param name="mods">Handles access to the supported mod integrations.</param>
        public CropFertilizerLayer(LayerConfig config, ModIntegrations mods)
            : base(I18n.CropFertilizer_Name(), config)
        {
            this.Legend =
                new[]
            {
                this.Fertilizer    = new LegendEntry(I18n.Keys.CropFertilizer_Fertilizer, Color.Green),
                this.RetainingSoil = new LegendEntry(I18n.Keys.CropFertilizer_RetainingSoil, Color.Blue),
                this.SpeedGro      = new LegendEntry(I18n.Keys.CropFertilizer_SpeedGro, Color.Magenta),
                this.Multiple      = mods.MultiFertilizer.IsLoaded
                        ? new LegendEntry(I18n.Keys.CropFertilizer_Multiple, Color.Red)
                        : null
            }
            .WhereNotNull()
            .ToArray();

            this.Mods = mods;
        }
Esempio n. 31
0
        public override void CreateNetwork(List <LayerConfig> hiddenLayersConfig, LayerConfig outputLayerConfig, DataSet <T> TrainingSet, Config featurizer)
        {
            HiddenLayerList = CreateLayers(hiddenLayersConfig);
            for (var i = 0; i < HiddenLayerList.Count; i++)
            {
                SimpleLayer layer = HiddenLayerList[i];
                layer.InitializeWeights(TrainingSet.SparseFeatureSize, i == 0 ? TrainingSet.DenseFeatureSize : HiddenLayerList[i - 1].LayerSize);
                layer.SetRunningMode(RunningMode.Training);

                Logger.WriteLine($"Create hidden layer {i}: size = {layer.LayerSize}, sparse feature size = {layer.SparseFeatureSize}, dense feature size = {layer.DenseFeatureSize}");
            }

            outputLayerConfig.LayerSize = TrainingSet.TagSize;
            OutputLayer = CreateOutputLayer(outputLayerConfig, TrainingSet.SparseFeatureSize, HiddenLayerList[HiddenLayerList.Count - 1].LayerSize);
            OutputLayer.SetRunningMode(RunningMode.Training);

            Logger.WriteLine($"Create a Forward recurrent neural network with {HiddenLayerList.Count} hidden layers");
        }
Esempio n. 32
0
 List<LayerConfig> Mutate(List<LayerConfig> gen)
 {
     List<LayerConfig> newgen = new List<LayerConfig>();
     foreach (var g in gen)
     {
         newgen.Add(g);
     }
     if (newgen.Count >3)
     {
         if (rnd.NextDouble()>0.9)
         {
             newgen.RemoveAt(rnd.Next(newgen.Count));
         }
     }
     if (rnd.NextDouble() > 0.90)
     {
         bool bias = rnd.NextDouble() >= 0.5;
         var layer = new LayerConfig((byte)rnd.Next(0, 16), bias, rnd.Next(100) + 5);
         newgen.Insert(rnd.Next(newgen.Count), layer);
     }
     foreach (var g in newgen)
     {
         g.neurons += rnd.Next(g.neurons / 10);
         g.neurons -= rnd.Next(g.neurons / 10);
         if (rnd.NextDouble() > 0.90)
         {
             bool bias = rnd.NextDouble() >= 0.5;
             g.hasBias = bias;
         }
     }
     return newgen;
 }
Esempio n. 33
0
        private void init(IWorkspace con, string prefix, BusinessArea ba, Hashtable layers)
        {
            IQueryDef query = ((IFeatureWorkspace)con).CreateQueryDef();
            query.Tables = prefix+SDE_LAYERS_TABLE+","+prefix+SDE_OSDB_TABLE;
            query.WhereClause = prefix + SDE_LAYERS_TABLE + "." + OPERATIONAL_DATASET_NAME_COL + " = " +
                prefix + SDE_OSDB_TABLE + "." + OPERATIONAL_DATASET_NAME_COL +
                " AND "+prefix + SDE_LAYERS_TABLE + "." + OPERATIONAL_DATASET_NAME_COL + " = '" +
                (ba == BusinessArea.ForAdmBound?DAOUtils.FADM_OSDB_KEY:
                    (ba == BusinessArea.Tantalis?DAOUtils.TANT_OSDB_KEY:"NULL"))+"'";

            ICursor cur = null;
            try
            {
                cur = query.Evaluate();

                for(IRow row = cur.NextRow();row!=null;row = cur.NextRow())
                {
                    int fIndex = row.Fields.FindField(prefix + SDE_LAYERS_TABLE+"."+SDE_LAYER_NAME_COL);
                    object t = null;
                    string osdb = null;
                    if(fIndex > -1)
                    {
                        t = row.get_Value(fIndex);
                        if(!(t is DBNull))
                            osdb = (string)t;
                    }

                    fIndex = row.Fields.FindField(prefix + SDE_LAYERS_TABLE + "." + WORKING_THEME_NAME_COL);
                    t = null;
                    string working = null;
                    if(fIndex > -1)
                    {
                        t = row.get_Value(fIndex);
                        if(!(t is DBNull))
                            working = (string)t;
                    }

                    fIndex = row.Fields.FindField(prefix + SDE_LAYERS_TABLE + "." + PRISTINE_THEME_NAME_COL);
                    t = null;
                    string pristine = null;
                    if(fIndex > -1)
                    {
                        t = row.get_Value(fIndex);
                        if(!(t is DBNull))
                            pristine = (string)t;
                    }

                    fIndex = row.Fields.FindField(prefix + SDE_LAYERS_TABLE + "." + EDIT_THEME_NAME_COL);
                    t = null;
                    string edit = null;
                    if(fIndex > -1)
                    {
                        t = row.get_Value(fIndex);
                        if(!(t is DBNull))
                            edit = (string)t;
                    }

                    fIndex = row.Fields.FindField(prefix + SDE_LAYERS_TABLE + "." + CONFLICT_THEME_NAME_COL);
                    t = null;
                    string conflict = null;
                    if(fIndex > -1)
                    {
                        t = row.get_Value(fIndex);
                        if(!(t is DBNull))
                            conflict = (string)t;
                    }

                    fIndex = row.Fields.FindField(prefix + SDE_LAYERS_TABLE + "." + PRIMARY_KEY_FIELD_COL);
                    t = null;
                    string[] primaries = null;
                    if(fIndex > -1)
                    {
                        t = row.get_Value(fIndex);
                        string tmp = null;
                        if(!(t is DBNull))
                            tmp = (string)t;
                        primaries = (tmp == null?null:tmp.Split(new char[] {'|'}));
                    }

                    fIndex = row.Fields.FindField(prefix + SDE_LAYERS_TABLE + "." + READ_ONLY_FIELD_COL);
                    t = null;
                    string[] read_only = null;
                    if(fIndex > -1)
                    {
                        t = row.get_Value(fIndex);
                        string tmp = null;
                        if(!(t is DBNull))
                            tmp = (string)t;
                        read_only = (tmp == null?null:tmp.Split(new char[] {'|'}));
                    }

                    fIndex = row.Fields.FindField(prefix + SDE_LAYERS_TABLE + "." + JOIN_TABLE_COL);
                    t = null;
                    string join_table = null;
                    if(fIndex > -1)
                    {
                        t = row.get_Value(fIndex);
                        if(!(t is DBNull))
                            join_table = (string)t;
                    }

                    fIndex = row.Fields.FindField(prefix + SDE_LAYERS_TABLE + "." + JOIN_OUTPUT_ATTRS_COL);
                    t = null;
                    string[] join_output_attrs = null;
                    if(fIndex > -1)
                    {
                        t = row.get_Value(fIndex);
                        string tmp = null;
                        if(!(t is DBNull))
                            tmp = (string)t;
                        join_output_attrs = (tmp == null?null:tmp.Split(new char[] {'|'}));
                    }

                    fIndex = row.Fields.FindField(prefix + SDE_LAYERS_TABLE + "." + LABEL_COL);
                    t = null;
                    string label = null;
                    if(fIndex > -1)
                    {
                        t = row.get_Value(fIndex);
                        if(!(t is DBNull))
                            label = (string)t;
                    }

                    fIndex = row.Fields.FindField(prefix + SDE_LAYERS_TABLE + "." + UPDATE_TIME_FIELD_COL);
                    t = null;
                    string updateTimeField = null;
                    if(fIndex > -1)
                    {
                        t = row.get_Value(fIndex);
                        if(!(t is DBNull))
                            updateTimeField = (string)t;
                    }

                    fIndex = row.Fields.FindField(prefix + SDE_LAYERS_TABLE + "." + UPDATE_USER_FIELD_COL);
                    t = null;
                    string updateUserField = null;
                    if(fIndex > -1)
                    {
                        t = row.get_Value(fIndex);
                        if(!(t is DBNull))
                            updateUserField = (string)t;
                    }

                    fIndex = row.Fields.FindField(prefix + SDE_LAYERS_TABLE + "." + CREATE_TIME_FIELD_COL);
                    t = null;
                    string createTimeField = null;
                    if(fIndex > -1)
                    {
                        t = row.get_Value(fIndex);
                        if(!(t is DBNull))
                            createTimeField = (string)t;
                    }

                    fIndex = row.Fields.FindField(prefix + SDE_LAYERS_TABLE + "." + CREATE_USER_FIELD_COL);
                    t = null;
                    string createUserField = null;
                    if(fIndex > -1)
                    {
                        t = row.get_Value(fIndex);
                        if(!(t is DBNull))
                            createUserField = (string)t;
                    }

                    fIndex = row.Fields.FindField(prefix + SDE_LAYERS_TABLE + "." + GEOMETRY_TYPE_COL);
                    t = null;
                    string geometry = null;
                    if(fIndex > -1)
                    {
                        t = row.get_Value(fIndex);
                        if(!(t is DBNull))
                            geometry = (string)t;
                    }

                    fIndex = row.Fields.FindField(prefix + SDE_LAYERS_TABLE + "." + REQUIRES_SID_IND_COL);
                    t = null;
                    string requiresSID = null;
                    if(fIndex > -1)
                    {
                        t = row.get_Value(fIndex);
                        if(!(t is DBNull))
                            requiresSID = (string)t;
                    }

                    fIndex = row.Fields.FindField(prefix + SDE_LAYERS_TABLE + "." + SID_FIELD_NAME_COL);
                    t = null;
                    string sidField = null;
                    if(fIndex > -1)
                    {
                        t = row.get_Value(fIndex);
                        if(!(t is DBNull))
                            sidField = (string)t;
                    }

                    fIndex = row.Fields.FindField(prefix + SDE_LAYERS_TABLE + "." + FCODE_FIELD_NAME_COL);
                    t = null;
                    string fcodeField = null;
                    if(fIndex > -1)
                    {
                        t = row.get_Value(fIndex);
                        if(!(t is DBNull))
                            fcodeField = (string)t;
                    }

                    fIndex = row.Fields.FindField(prefix + SDE_LAYERS_TABLE + "." + SYMBOL_TYPE_FIELD_COL);
                    t = null;
                    string symbolTypeField = null;
                    if (fIndex > -1)
                    {
                        t = row.get_Value(fIndex);
                        if (!(t is DBNull))
                            symbolTypeField = (string)t;
                    }

                    fIndex = row.Fields.FindField(prefix + SDE_OSDB_TABLE + "." + CLUSTER_TOL_COL);
                    t = null;
                    float clusterTol = 0.0F;
                    if (fIndex > -1)
                    {
                        t = row.get_Value(fIndex);
                        if (!(t is DBNull))
                            if (!t.Equals(0.0))
                            {
                                clusterTol = (float)t;
                            }
                    }

                    fIndex = row.Fields.FindField(prefix + SDE_LAYERS_TABLE + "." + IS_TOPO_COL);
                    t = null;
                    bool isTopo = false;
                    if (fIndex > -1)
                    {
                        t = row.get_Value(fIndex);
                        if (!(t is DBNull))
                        {
                            isTopo = ((string)t).Equals("Y") || ((string)t).Equals("y");
                        }
                    }

                    LayerConfig lc = new LayerConfig(ba, osdb, working, pristine, edit,
                            conflict, toList(primaries), toList(read_only), join_table, toList(join_output_attrs), label,
                            updateTimeField, createTimeField, updateUserField, createUserField,
                            geometry, requiresSID, sidField, fcodeField, symbolTypeField,isTopo,clusterTol);

                    layers.Add(osdb,lc);
                }
            }
            catch(InvalidCastException e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message + "\n" + e.StackTrace);
            }
            finally
            {
                if(cur!=null)
                {
                    Utils.Release(cur);
                }
            }
        }
Esempio n. 34
0
            public Life(List<Life> world,double X,double Y, List<LayerConfig> newgen=null, Life parent=null  )
            {
                x = X;
                y = Y;
                pL = pR = pB = pT = 0.0;
                sL = sR = sB = sT = 0.0;
                network.AddLayer(new BasicLayer(null, true, 4)); //создание простой многослойной нейронной сети

                if (newgen ==null )
                {
                    int maxlayers = 3 + rnd.Next(15);
                    for (int i = 0; i < maxlayers; i++)
                    {
                        bool bias = rnd.NextDouble() >= 0.5;
                        var layer = new LayerConfig((byte)rnd.Next(0, 16), bias, rnd.Next(100) + 10);
                        genotype.Add(layer);
                    }
                }
                else
                {
                    genotype = Mutate(newgen);
                }

                AddLayers(genotype);
                if (parent!=null )
                {
                    for (int i = 0; i < parent.Memory.Count ; i++)
                    {
                        if (rnd.NextDouble()>0.5)
                        {
                            Memory.Add(parent.Memory[i]);
                            MemorySense.Add(parent.MemorySense[i]);
                        }
                    }
                }
                //network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationSigmoid(), false, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationSoftMax(), false, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationSoftMax (), true, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationSoftMax(), false, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationSoftMax(), true, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationStep (), false, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationStep(), true, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationStep(), false, rnd.Next(100) + 10));
                //network.AddLayer(new BasicLayer(new ActivationSigmoid(), true, rnd.Next(100) + 10));
                network.AddLayer(new BasicLayer(new ActivationSigmoid(), false, 4));

                network.Structure.FinalizeStructure();
                network.Reset();
                World = world;
            }