Example #1
0
        public double[] StartMapping(SpotParsInitBox spotParsInitBox)
        {
            OptBoundVariable[] x = new OptBoundVariable[spotParsInitBox.SpotsNumber * 4];

            for (int i = 0; i < x.Length; i++)
            {
                x[i] = new OptBoundVariable();
            }

            for (int q = 0; q < this.lcObs.Length; q++)
            {
                for (int s = 0; s < spotParsInitBox.SpotsNumber; s++)
                {
                    this.modeller[q].StarM.AddUniformCircularSpot(0.0, 0.0, 1.0, 4000, 30, 90);
                }
            }

            for (int s = 0; s < spotParsInitBox.SpotsNumber; s++)
            {
                x[0 + s * 4].InitialGuess = spotParsInitBox.spots[s].longitude * Math.PI / 180;
                x[0 + s * 4].UpperBound   = spotParsInitBox.spots[s].longitudeUpperLimit * Math.PI / 180;
                x[0 + s * 4].LowerBound   = spotParsInitBox.spots[s].longitudeLowerLimit * Math.PI / 180;
                x[0 + s * 4].Fixed        = spotParsInitBox.spots[s].longitudeFixed;

                x[1 + s * 4].InitialGuess = spotParsInitBox.spots[s].colatutude * Math.PI / 180;
                x[1 + s * 4].UpperBound   = spotParsInitBox.spots[s].colatitudeUpperLimit * Math.PI / 180;
                x[1 + s * 4].LowerBound   = spotParsInitBox.spots[s].colatitudeLowerLimit * Math.PI / 180;
                x[1 + s * 4].Fixed        = spotParsInitBox.spots[s].colatitudeFixed;

                x[2 + s * 4].InitialGuess = spotParsInitBox.spots[s].radius * Math.PI / 180;
                x[2 + s * 4].UpperBound   = spotParsInitBox.spots[s].radiusUpperLimit * Math.PI / 180;
                x[2 + s * 4].LowerBound   = spotParsInitBox.spots[s].radiusLowerLimit * Math.PI / 180;
                x[2 + s * 4].Fixed        = spotParsInitBox.spots[s].radiusFixed;

                x[3 + s * 4].InitialGuess = spotParsInitBox.spots[s].teff;
                x[3 + s * 4].UpperBound   = spotParsInitBox.spots[s].teffUpperLimit;
                x[3 + s * 4].LowerBound   = spotParsInitBox.spots[s].teffLowerLimit;
                x[3 + s * 4].Fixed        = spotParsInitBox.spots[s].teffFixed;
            }

            double[] res;

            Simplex simplex = new Simplex();

            DotNumerics.Optimization.TruncatedNewton tn = new TruncatedNewton();


            //res = simplex.ComputeMin(this.Khi2, x);

            res = tn.ComputeMin(this.Khi2, this.GradKhi2, x);

            this.GenerateModLightCurve();

            return(res);
        }
Example #2
0
        public double[] StartMapping(SpotParsInitBox spotParsInitBox, string minimizator, double tau)
        {
            OptBoundVariable[] x = new OptBoundVariable[spotParsInitBox.SpotsNumber * 4];

            for (int i = 0; i < x.Length; i++)
            {
                x[i] = new OptBoundVariable();
            }

            for (int q = 0; q < this.lcObs.Length; q++)
            {
                this.modellers[q].StarM.RemoveAllSpots();
                for (int s = 0; s < spotParsInitBox.SpotsNumber; s++)
                {
                    this.modellers[q].StarM.AddUniformCircularSpot(
                        spotParsInitBox.spots[s].longitude * Math.PI / 180,
                        spotParsInitBox.spots[s].colatutude * Math.PI / 180,
                        spotParsInitBox.spots[s].radius * Math.PI / 180,
                        spotParsInitBox.spots[s].teff,
                        spotParsInitBox.spots[s].beltsCount,
                        spotParsInitBox.spots[s].nearEquatorialPatchesCount);
                }
            }

            this.fixedParsMask = new bool[x.Length];

            for (int s = 0; s < spotParsInitBox.SpotsNumber; s++)
            {
                x[0 + s * 4].InitialGuess     = spotParsInitBox.spots[s].longitude * Math.PI / 180;
                x[0 + s * 4].UpperBound       = spotParsInitBox.spots[s].longitudeUpperLimit * Math.PI / 180;
                x[0 + s * 4].LowerBound       = spotParsInitBox.spots[s].longitudeLowerLimit * Math.PI / 180;
                x[0 + s * 4].Fixed            = spotParsInitBox.spots[s].longitudeFixed;
                this.fixedParsMask[0 + s * 4] = spotParsInitBox.spots[s].longitudeFixed;

                x[1 + s * 4].InitialGuess     = spotParsInitBox.spots[s].colatutude * Math.PI / 180;
                x[1 + s * 4].UpperBound       = spotParsInitBox.spots[s].colatitudeUpperLimit * Math.PI / 180;
                x[1 + s * 4].LowerBound       = spotParsInitBox.spots[s].colatitudeLowerLimit * Math.PI / 180;
                x[1 + s * 4].Fixed            = spotParsInitBox.spots[s].colatitudeFixed;
                this.fixedParsMask[1 + s * 4] = spotParsInitBox.spots[s].colatitudeFixed;

                x[2 + s * 4].InitialGuess     = spotParsInitBox.spots[s].radius * Math.PI / 180;
                x[2 + s * 4].UpperBound       = spotParsInitBox.spots[s].radiusUpperLimit * Math.PI / 180;
                x[2 + s * 4].LowerBound       = spotParsInitBox.spots[s].radiusLowerLimit * Math.PI / 180;
                x[2 + s * 4].Fixed            = spotParsInitBox.spots[s].radiusFixed;
                this.fixedParsMask[2 + s * 4] = spotParsInitBox.spots[s].radiusFixed;

                x[3 + s * 4].InitialGuess     = spotParsInitBox.spots[s].teff;
                x[3 + s * 4].UpperBound       = spotParsInitBox.spots[s].teffUpperLimit;
                x[3 + s * 4].LowerBound       = spotParsInitBox.spots[s].teffLowerLimit;
                x[3 + s * 4].Fixed            = spotParsInitBox.spots[s].teffFixed;
                this.fixedParsMask[3 + s * 4] = spotParsInitBox.spots[s].teffFixed;
            }

            double[] res = new double[4];

            if (minimizator == "Simplex")
            {
                Simplex simplex = new Simplex();
                res = simplex.ComputeMin(this.Khi2, x);
            }
            if (minimizator == "TN")
            {
                //DotNumerics.Optimization.TruncatedNewton tn = new TruncatedNewton();
                DotNumerics.Optimization.L_BFGS_B bfgs = new L_BFGS_B();
                //tn.SearchSeverity = 1;

                //res = tn.ComputeMin(this.Khi2, this.GradKhi2, x);
                res = bfgs.ComputeMin(this.Khi2, this.GradKhi2, x);
            }
            if (minimizator == "LM")
            {
                LevenbergMaquard gn = new LevenbergMaquard();
                gn.MinimizedFunction = this.ResudalVector;
                double[] step       = new double[x.Length];
                double[] xinit      = new double[x.Length];
                bool[]   isFixed    = new bool[x.Length];
                double[] lowLimits  = new double[x.Length];
                double[] highLimits = new double[x.Length];


                for (int i = 0; i < xinit.Length; i++)
                {
                    xinit[i]      = x[i].InitialGuess;
                    isFixed[i]    = x[i].Fixed;
                    lowLimits[i]  = x[i].LowerBound;
                    highLimits[i] = x[i].UpperBound;
                    if (i != 0 && (i + 1) % 4 == 0)
                    {
                        step[i] = 10; // step for temperature;
                    }
                    else
                    {
                        step[i] = 0.02;
                    }
                }

                gn.StepForDer = step;
                gn.IterMax    = 100;
                gn.Tau        = tau;
                res           = gn.ComputeMin(xinit, isFixed, lowLimits, highLimits);
            }

            this.khi2 = this.Khi2(res);

            this.GenerateModLightCurve();

            return(res);
        }