Beispiel #1
0
        public static bool IsSameImputs(double[] newinputs, double[,] historicalinput)
        {
            var  oldinputs = OnlineGPupdating.MatrixtoRow(historicalinput);
            bool sameinput = true;

            for (int i = 0; i < newinputs.Length; i++)
            {
                var testnewdata = newinputs[i] + 10e-15;// incase is zero
                var testolddata = oldinputs[i] + 10e-15;
                if (Math.Abs((testnewdata - testolddata) / testolddata) < 0.05)
                {
                    continue;
                }
                else
                {
                    sameinput = false;
                    break;
                }
            }
            return(sameinput);
        }
Beispiel #2
0
        public static void EvaluateSubFirstThreeTime(SubAssembly sub, List <Component> refnodes, List <Component> movingnodes,
                                                     double olpdis, out double totaltime, out double totalSD, out double securetime, out double securesd)
        {
            var inputunitscaler = Program.MeshMagnifier / 1000;//magnifier translate unit to cm
            var movingsolids    = new List <TessellatedSolid>();
            var referencesolids = new List <TessellatedSolid>();
            var movingvertex    = new List <Vertex>();

            var counter = 10e6;

            ///////
            ///moving
            ///////
            foreach (var n in movingnodes)
            {
                movingsolids.Add(Program.Solids[n.name][0]); //cheange bbbbb class
            }
            foreach (var v in sub.Install.Moving.CVXHull.Vertices)
            {
                movingvertex.Add(v);
            }
            var movingOBB = OBB.BuildUsingPoints(movingvertex);

            //  var movingOBB = OBB.BuildUsingPoints(movingvertex);
            var lengths = new double[]
            {
                StarMath.norm1(movingOBB.CornerVertices[0].Position.subtract(movingOBB.CornerVertices[1].Position)),
                StarMath.norm1(movingOBB.CornerVertices[2].Position.subtract(movingOBB.CornerVertices[1].Position)),
                StarMath.norm1(movingOBB.CornerVertices[0].Position.subtract(movingOBB.CornerVertices[4].Position)),
            };
            var    lmax          = lengths.Max() / inputunitscaler;                                                    //mm
            var    lmin          = lengths.Min() / inputunitscaler;                                                    //mm
            double lmid          = lengths.Average() / inputunitscaler * 3 - lmax - lmin;
            var    movingweight  = Math.Log(sub.Install.Moving.Mass / inputunitscaler / Math.Pow(inputunitscaler, 3)); //in g ???????????
            var    OBBvolue      = Math.Log(movingOBB.Volume / 1000 / Math.Pow(inputunitscaler, 3));                   //cm^3
            var    OBBmaxsurface = Math.Log(lmax * lmid / 1000);
            var    OBBminsurface = Math.Log(lmin * lmid / 1000);
            /////
            /// distance TBD
            var movingdistance = 50;//cm
            var movingdis      = Math.Log(movingdistance);
            var movinginput    = new double[5] {
                movingweight, OBBvolue, OBBmaxsurface, OBBminsurface, movingdis
            };

            sub.MoveRoateModelInputs = OnlineGPupdating.RowtoMatrix(movinginput);
            //    Log ( weight, OOBvol OBB, maxf OBB, minf moving, distance  )all in mmgs unit system
            double movingtime = 0.0;
            double movingSD   = 0.0;

            CalculateAssemblyTimeAndSD.GetTimeAndSD(sub, movinginput, "moving", out movingtime, out movingSD);

            // Program.allmtime.Add(movingtime);
            ///////
            ///install
            ///////
            var allolpfs = BlockingDetermination.OverlappingSurfaces.FindAll(
                s =>
                (movingnodes.Any(n => n.name.Equals(s.Solid1.Name))) &&
                (refnodes.Any(n => n.name.Equals(s.Solid2.Name)))
                ||
                (movingnodes.Any(n => n.name.Equals(s.Solid2.Name))) &&
                (refnodes.Any(n => n.name.Equals(s.Solid1.Name)))
                );
            double olpfeatures = 0.0;

            for (int i = 0; i < allolpfs.Count; i++)
            {
                olpfeatures += allolpfs[i].Overlappings.Count; ////no alignment features for now;
            }
            if (olpfeatures == 0)
            {
                olpfeatures = 0.3;
            }
            var logOverlappingDist = Math.Log(olpdis / inputunitscaler);

            if (double.IsInfinity(logOverlappingDist))
            {
                logOverlappingDist = 1e-6;
            }
            var installinput = new double[6] {
                movingweight, OBBvolue, OBBmaxsurface, OBBminsurface, logOverlappingDist, Math.Log(olpfeatures)
            };

            sub.InstallModelInputs = OnlineGPupdating.RowtoMatrix(installinput);
            double installtime = 0;
            double instalSD    = 0;

            CalculateAssemblyTimeAndSD.GetTimeAndSD(sub, installinput, "install", out installtime, out instalSD);
            //Program.allitime.Add(installtime);
            ///////
            ///secure
            ///////
            securetime = 0.0;
            securesd   = 0.0;
            if (sub.Secure.Fasteners != null)
            {
                foreach (var f in sub.Secure.Fasteners)
                {
                    double eachseucretime = 0;
                    double eachsecureSD   = 0;
                    var    secureinput    = new double[6];
                    if (f.SecureModelInputs == null)
                    {
                        var OBBmax          = (f.Diameter / inputunitscaler) * (f.OverallLength / inputunitscaler);
                        var OBBmin          = (f.Diameter / inputunitscaler) * (f.Diameter / inputunitscaler);
                        var numberofthreads = f.NumberOfThreads;
                        if (numberofthreads == 0)
                        {
                            numberofthreads = 10;
                        }
                        var insertdistance = f.EngagedLength / inputunitscaler * 0.5;
                        if (insertdistance == 0)
                        {
                            insertdistance = numberofthreads * 0.25;
                        }
                        var nut  = 1;
                        var tool = 2;
                        if (f.Nuts != null)
                        {
                            nut = 2;
                        }
                        secureinput = new double[6] {
                            Math.Log(OBBmax / 1000), Math.Log(OBBmin / 1000), Math.Log(numberofthreads), Math.Log(insertdistance), nut, tool
                        };
                        f.SecureModelInputs = OnlineGPupdating.RowtoMatrix(secureinput);
                    }
                    else
                    {
                        secureinput = OnlineGPupdating.MatrixtoRow(f.SecureModelInputs);
                    }
                    CalculateAssemblyTimeAndSD.GetTimeAndSD(sub, secureinput, "s", out eachseucretime, out eachsecureSD);
                    securetime += eachseucretime;
                    securesd   += eachsecureSD;
                    f.Time      = eachseucretime;
                    f.TimeSD    = eachsecureSD;
                    //   if (eachseucretime > 30)
                    //   {
                    //       var sssss = 1;
                    //   }
                    ////   if (securetime != 0)
                    //      // Bridge.gpsecuretime.Add(eachseucretime);
                }
            }
            if (installtime < 0)
            {
                installtime = 0.5;
            }
            if (movingtime < 0)
            {
                movingtime = 0.5;
            }
            sub.MoveRoate.Time   = movingtime;
            sub.MoveRoate.TimeSD = movingSD;
            totalSD            = instalSD + movingSD;
            sub.Install.Time   = installtime;
            sub.Install.TimeSD = totalSD;
            sub.Secure.Time    = securetime;
            sub.Secure.TimeSD  = securesd;
            totaltime          = installtime + movingtime;

            if (movingtime > 2.9 && movingtime < 3.01)
            {
                var sss = 1;
            }
            if (installtime > 2.9 && installtime < 3.01)
            {
                var sss = 1;
            }


            // Bridge.gpinstalltime.Add(installtime);
            //  Bridge.gpmovingtime.Add(movingtime);
        }