コード例 #1
0
ファイル: SinuousFaultGene.cs プロジェクト: vcer007/geodyssey
        private AbstractMutationStrategy YMutationStrategy(Grid2DDomain domain)
        {
            double range      = (domain.Max.Y - domain.Min.Y) / 2.0; // Half model width
            double resolution = 1.0;

            return(PowerLawMutationStrategy.Create(range, resolution));
        }
コード例 #2
0
ファイル: SinuousFaultGene.cs プロジェクト: vcer007/geodyssey
        private AbstractMutationStrategy MaxHeaveMutationStrategy(Grid2DDomain domain)
        {
            double range      = MaxMaxHeave(domain) / 2.0;
            double resolution = 1.0f;

            return(PowerLawMutationStrategy.Create(range, resolution));
        }
コード例 #3
0
ファイル: SinuousFaultGene.cs プロジェクト: vcer007/geodyssey
        private AbstractMutationStrategy DetachDepthMutationStrategy(Grid2DDomain domain)
        {
            double range      = MaxDetachDepth(domain) / 2.0;
            double resolution = 1.0;

            return(PowerLawMutationStrategy.Create(range, resolution));
        }
コード例 #4
0
ファイル: SinuousFaultGene.cs プロジェクト: vcer007/geodyssey
 public static SinuousFaultGene Create(Grid2DDomain domain, double x0, double y0, double phi0,
                                       double x1, double y1, double phi1,
                                       double maxHeave, double detachDepth, double dip)
 {
     Debug.Assert(dip > 0.0 && dip <= 90.0);
     return(new SinuousFaultGene(domain, x0, y0, phi0, x1, y1, phi1, maxHeave, detachDepth, dip));
 }
コード例 #5
0
        private AbstractMutationStrategy RhoMutationStrategy(Grid2DDomain domain)
        {
            double r = (domain.Max - domain.Min).Magnitude / 2.0; // Half model diagonal
            double k = 9.0;                                       // ~ 1 metre

            return(PowerLawMutationStrategy.Create(r, k));
        }
コード例 #6
0
 private LinearFaultGene(Grid2DDomain domain, double rho, double theta, double faultThrow) :
     base(domain, System.Enum.GetValues(typeof(DimIndex)).Length)
 {
     Dimensions[(int)DimIndex.Rho]   = new Dimension(rho, RhoMutationStrategy(domain), RhoRangeStrategy(domain));
     Dimensions[(int)DimIndex.Theta] = new Dimension(theta, ThetaMutationStrategy(domain), ThetaRangeStrategy(domain));
     Dimensions[(int)DimIndex.Throw] = new Dimension(faultThrow, ThrowMutationStrategy(domain), ThrowRangeStrategy(domain));
 }
コード例 #7
0
ファイル: Gene.cs プロジェクト: vcer007/geodyssey
 public Gene(Grid2DDomain domain, int size)
 {
     Debug.Assert(domain != null);
     this.domain       = domain;
     dimensions        = new Dimension[size];
     dimensionsIndexer = new DimensionIndexer(this);
 }
コード例 #8
0
ファイル: SinuousFaultGene.cs プロジェクト: vcer007/geodyssey
        private AbstractMutationStrategy DipMutationStrategy(Grid2DDomain domain)
        {
            // Should have ~1° resolution
            double range      = (maxFaultDip - minFaultDip) / 2.0;
            double resolution = 1.0;

            return(PowerLawMutationStrategy.Create(range, resolution));
        }
コード例 #9
0
        public static LinearFaultGene Create(Grid2DDomain domain, double x, double y, double strike, double faultThrow)
        {
            Debug.Assert(strike >= 0.0 && strike < 360.0);

            double theta = 360.0 - strike;
            double rho   = x * Math.Cos(theta) + y * Math.Sin(theta);

            return(new LinearFaultGene(domain, rho, theta, faultThrow));
        }
コード例 #10
0
ファイル: Grid2DPhenotype.cs プロジェクト: vcer007/geodyssey
        public Grid2DPhenotype(Grid2DDomain domain) :
            base(domain)
        {
            Point2D  origin   = domain.Min;
            Vector2D diagonal = domain.Max - domain.Min;
            Vector2D spacing  = new Vector2D(diagonal.DeltaX / domain.SizeI, diagonal.DeltaY / domain.SizeJ);

            this.grid = new RegularGrid2D(origin, spacing, domain.SizeI, domain.SizeJ, 0.0);
        }
コード例 #11
0
        public static LinearFaultGene CreateRandom(Grid2DDomain domain)
        {
            double x          = Rng.ContinuousUniform(domain.Min.X, domain.Max.X);
            double y          = Rng.ContinuousUniform(domain.Min.Y, domain.Max.Y);
            double strike     = Rng.ContinuousUniform(0.0, 360.0);
            double faultThrow = Rng.ContinuousUniform(0.0, 50.0);

            return(Create(domain, x, y, strike, faultThrow));
        }
コード例 #12
0
ファイル: SinuousFaultGene.cs プロジェクト: vcer007/geodyssey
 private SinuousFaultGene(Grid2DDomain domain, double x0, double y0, double phi0,
                          double x1, double y1, double phi1,
                          double maxHeave, double detachDepth, double dip) :
     base(domain, System.Enum.GetValues(typeof(DimIndex)).Length)
 {
     Dimensions[(int)DimIndex.X0]          = new Dimension(x0, XMutationStrategy(domain), XRangeStrategy(domain));
     Dimensions[(int)DimIndex.Y0]          = new Dimension(y0, YMutationStrategy(domain), YRangeStrategy(domain));
     Dimensions[(int)DimIndex.Phi0]        = new Dimension(phi0, PhiMutationStrategy(domain), PhiRangeStrategy(domain));
     Dimensions[(int)DimIndex.X1]          = new Dimension(x1, XMutationStrategy(domain), XRangeStrategy(domain));
     Dimensions[(int)DimIndex.Y1]          = new Dimension(y1, YMutationStrategy(domain), YRangeStrategy(domain));
     Dimensions[(int)DimIndex.Phi1]        = new Dimension(phi1, PhiMutationStrategy(domain), PhiRangeStrategy(domain));
     Dimensions[(int)DimIndex.DetachDepth] = new Dimension(detachDepth, DetachDepthMutationStrategy(domain), DetachDepthRangeStrategy(domain));
     Dimensions[(int)DimIndex.MaxHeave]    = new Dimension(maxHeave, MaxHeaveMutationStrategy(domain), MaxHeaveRangeStrategy(domain));
     Dimensions[(int)DimIndex.Dip]         = new Dimension(dip, DipMutationStrategy(domain), DipRangeStrategy(domain));
 }
コード例 #13
0
ファイル: SinuousFaultGene.cs プロジェクト: vcer007/geodyssey
        //public static SinuousFaultGene CreateRandom(Grid2DDomain domain)
        //{
        //    double border   = Border(domain);
        //    double x0   = Rng.ContinuousUniform(domain.Min.X - border, domain.Max.X + border);
        //    double y0   = Rng.ContinuousUniform(domain.Min.Y - border, domain.Max.Y + border);
        //    double phi0 = Rng.ContinuousUniform(-tipTangentAngle, +tipTangentAngle);
        //    double x1   = Rng.ContinuousUniform(domain.Min.X - border, domain.Max.X + border);
        //    double y1   = Rng.ContinuousUniform(domain.Min.Y - border, domain.Max.Y + border);
        //    double phi1 = Rng.ContinuousUniform(-tipTangentAngle, +tipTangentAngle);
        //    double detachDepth = Rng.ContinuousUniform(MinDetachDepth(domain), MaxDetachDepth(domain));
        //    double maxHeave    = Rng.ContinuousUniform(MinMaxHeave(domain), MaxMaxHeave(domain), false);
        //    double dip         = Rng.ContinuousUniform(minFaultDip, maxFaultDip);
        //    return Create(domain, x0, y0, phi0, x1, y1, phi1, maxHeave, detachDepth, dip);
        //}

        public static SinuousFaultGene CreateRandom(Grid2DDomain domain)
        {
            // Select a point to be on the centre of a straight line
            // joining the fault tips
            double  border = Border(domain);
            Point2D centre = new Point2D(Rng.ContinuousUniform(domain.Min.X - border, domain.Max.X + border),
                                         Rng.ContinuousUniform(domain.Min.Y - border, domain.Max.Y + border));

            // Select a fault orientation - select a dip azimuth from the
            // distribution, and convert it into a fault strike.
            double dipAzimuth = domain.RandomHistogramDipAzimuth();
            // Fault strike should be 90° anti-clockwise of surface dip
            double faultStrike = dipAzimuth - Math.PI / 2.0;

            // Select a fault length from the domain length scale distribution
            double faultLength = Rng.ContinuousUniformZeroToN((domain.Max - domain.Min).Magnitude);

            Vector2D halfCentreLine = new Vector2D(Math.Cos(faultStrike) * faultLength / 2.0,
                                                   Math.Sin(faultStrike) * faultLength / 2.0);

            Point2D p0 = centre - halfCentreLine;
            Point2D p1 = centre + halfCentreLine;

            double phi0 = Rng.ContinuousUniform(-tipTangentAngle, +tipTangentAngle);
            double phi1 = Rng.ContinuousUniform(-tipTangentAngle, +tipTangentAngle);

            double detachDepth = Rng.ContinuousUniform(MinDetachDepth(domain), MaxDetachDepth(domain));

            double maxFaultHeave   = faultLength / minFaultDisplacementLengthRatio;
            double lowerFaultHeave = MinMaxHeave(domain);
            double upperFaultHeave = Math.Max(Math.Min(maxFaultHeave, detachDepth / 2.0) / 10.0, lowerFaultHeave);
            double maxHeave        = Rng.ContinuousUniform(lowerFaultHeave, upperFaultHeave, false);
            double dip             = Rng.ContinuousUniform(minFaultDip, maxFaultDip);

            return(Create(domain, p0.X, p0.Y, phi0, p1.X, p1.Y, phi1, maxHeave, detachDepth, dip));
        }
コード例 #14
0
        private AbstractRangeStrategy RhoRangeStrategy(Grid2DDomain domain)
        {
            double diagonal = (domain.Max - domain.Min).Magnitude;

            return(ClipRangeStrategy.Create(-diagonal, diagonal));
        }
コード例 #15
0
ファイル: SinuousFaultGene.cs プロジェクト: vcer007/geodyssey
 private static double MinMaxHeave(Grid2DDomain domain)
 {
     return(25.0);    // metres
 }
コード例 #16
0
 private AbstractMutationStrategy ThetaMutationStrategy(Grid2DDomain domain)
 {
     // Half-circle range, with 1° resolution
     return(PowerLawMutationStrategy.Create(180.0, 7.49f));
 }
コード例 #17
0
ファイル: SinuousFaultGene.cs プロジェクト: vcer007/geodyssey
 private AbstractRangeStrategy DipRangeStrategy(Grid2DDomain domain)
 {
     return(ReflectRangeStrategy.Create(minFaultDip, maxFaultDip));
 }
コード例 #18
0
 private AbstractRangeStrategy ThetaRangeStrategy(Grid2DDomain domain)
 {
     return(ModalRangeStrategy.Create(0.0, 360.0));
 }
コード例 #19
0
ファイル: SinuousFaultGene.cs プロジェクト: vcer007/geodyssey
 private AbstractRangeStrategy MaxHeaveRangeStrategy(Grid2DDomain domain)
 {
     return(ClipRangeStrategy.Create(MinMaxHeave(domain), MaxMaxHeave(domain)));
 }
コード例 #20
0
 private AbstractMutationStrategy ThrowMutationStrategy(Grid2DDomain domain)
 {
     return(PowerLawMutationStrategy.Create(50.0, 9.0));
 }
コード例 #21
0
ファイル: SinuousFaultGene.cs プロジェクト: vcer007/geodyssey
 private AbstractRangeStrategy DetachDepthRangeStrategy(Grid2DDomain domain)
 {
     return(ClipRangeStrategy.Create(MinDetachDepth(domain), MaxDetachDepth(domain)));
 }
コード例 #22
0
ファイル: SinuousFaultGene.cs プロジェクト: vcer007/geodyssey
 private AbstractMutationStrategy PhiMutationStrategy(Grid2DDomain domain)
 {
     return(PowerLawMutationStrategy.Create(tipTangentAngle, 1.0));    // 1° resolution
 }
コード例 #23
0
ファイル: SinuousFaultGene.cs プロジェクト: vcer007/geodyssey
 private AbstractRangeStrategy PhiRangeStrategy(Grid2DDomain domain)
 {
     return(ModalRangeStrategy.Create(-tipTangentAngle, tipTangentAngle));
 }
コード例 #24
0
ファイル: SinuousFaultGene.cs プロジェクト: vcer007/geodyssey
        private AbstractRangeStrategy YRangeStrategy(Grid2DDomain domain)
        {
            double border = Border(domain);

            return(ClipRangeStrategy.Create(domain.Min.Y - border, domain.Max.Y + border));
        }
コード例 #25
0
 private AbstractRangeStrategy ThrowRangeStrategy(Grid2DDomain domain)
 {
     return(ClipRangeStrategy.Create(0.0, 200.0));
 }
コード例 #26
0
ファイル: SinuousFaultGene.cs プロジェクト: vcer007/geodyssey
        private static double Border(Grid2DDomain domain)
        {
            double diagonal = (domain.Max - domain.Min).Magnitude;

            return(diagonal * borderProportion);
        }
コード例 #27
0
ファイル: SinuousFaultGene.cs プロジェクト: vcer007/geodyssey
 private static double MinDetachDepth(Grid2DDomain domain)
 {
     return(1000.0);    // metres - Must be greater than 0.0
 }
コード例 #28
0
ファイル: SinuousFaultGene.cs プロジェクト: vcer007/geodyssey
 private static double MaxDetachDepth(Grid2DDomain domain)
 {
     // TODO: Should have 3D bounds on domain
     return(Border(domain) / 2.0);
 }
コード例 #29
0
ファイル: SinuousFaultGene.cs プロジェクト: vcer007/geodyssey
 private static double MaxMaxHeave(Grid2DDomain domain)
 {
     return(MaxDetachDepth(domain) / 20.0);    // Reduced by factor of ten
 }
コード例 #30
0
ファイル: GeodysseyApp.cs プロジェクト: vcer007/geodyssey
        static int Main(string[] args)
        {
            // Get a URI from the command line argument
            Uri uri;

            try
            {
                uri = new Uri(args[0]);
            }
            catch (UriFormatException)
            {
                string absPath = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + args[0];
                try
                {
                    uri = new Uri(absPath);
                }
                catch (UriFormatException)
                {
                    return(1);
                }
            }

            ReportLogger.Instance.Create("report.xml");
            ReportLogger.Instance.Writer.WriteStartDocument();
            ReportLogger.Instance.Writer.WriteStartElement("GeodysseyRun");

            Stopwatch overallWatch = new Stopwatch();

            overallWatch.Start();
            //Console.WriteLine("Start!");
            int initialMinimumGenomeLength = 50;
            int initialMaximumGenomeLength = 100;
            int initialPopulationSize      = 1000;
            int finalPopulationSize        = 100;
            int numberOfGenerations        = 100;

            double populationPowerBase = Math.Pow((double)finalPopulationSize / (double)initialPopulationSize, 1.0 / numberOfGenerations);

            int totalNumberOfIndividuals = 0;

            // Determine how many individuals will be produced in this run
            for (int i = 0; i < numberOfGenerations; ++i)
            {
                int inc = (int)Math.Round(initialPopulationSize * Math.Pow(populationPowerBase, i + 1));
                //Console.WriteLine(inc);
                totalNumberOfIndividuals += inc;
            }
            Console.WriteLine("Total Number of Individuals = {0}", totalNumberOfIndividuals);
            Console.WriteLine("Mean Invididuals per Generation = {0}", totalNumberOfIndividuals / numberOfGenerations);

            // Load a target grid
            //RegularGrid2D targetGrid;
            //using (StreamReader reader = File.OpenText("target.grd"))
            //{
            //    targetGrid = RegularGrid2D.Create(reader);
            //}

            GeodysseyModel model = new GeodysseyModel();

            LoaderController.Instance.Open(uri, model);
            IRegularGrid2D targetGrid = model[0]; // The first grid

            Debug.Assert(targetGrid != null);
            Grid2DDomain domain = new Grid2DDomain(targetGrid);

            Stopwatch  stopWatch  = new Stopwatch();
            Population population = new Population(domain, initialPopulationSize, initialMinimumGenomeLength, initialMaximumGenomeLength);

            for (int i = 0; i < numberOfGenerations; ++i)
            {
                stopWatch.Reset();
                stopWatch.Start();
                population.ComputeFitnesses();
                stopWatch.Stop();
                TimeSpan ts = stopWatch.Elapsed;
                ReportLogger.Instance.Writer.WriteStartElement("Generation");
                ReportLogger.Instance.Writer.WriteStartAttribute("number");
                ReportLogger.Instance.Writer.WriteValue(i + 1);
                ReportLogger.Instance.Writer.WriteEndAttribute();
                ReportLogger.Instance.Writer.WriteStartAttribute("elapsedTime");
                ReportLogger.Instance.Writer.WriteValue(ts);
                ReportLogger.Instance.Writer.WriteEndAttribute();
                RecordBest(targetGrid, population, i, domain);
                population.LogSummaryStatistics();
                ReportLogger.Instance.Writer.WriteEndElement();
                Console.WriteLine("Generation {0} of {1} with size {2} in {3}) ", i + 1, numberOfGenerations, population.Count, ts);
                int nextGenerationSize = (int)Math.Round(initialPopulationSize * Math.Pow(populationPowerBase, i + 1));
                population.Evolve(nextGenerationSize);
            }
            population.ComputeFitnesses();
            RecordBest(targetGrid, population, numberOfGenerations, domain);
            Console.WriteLine("Generation {0} of {1} with size {2}) ", numberOfGenerations, numberOfGenerations, population.Count);
            overallWatch.Stop();
            Console.WriteLine("Running time : {0}", overallWatch.Elapsed);
            ReportLogger.Instance.Writer.WriteEndElement();
            ReportLogger.Instance.Writer.WriteEndDocument();
            ReportLogger.Instance.Close();
            Console.ReadKey();
            return(0);
        }