internal static StringBuilder Section_COORDS(AnalyticModel model)
        {
            StringBuilder sb   = new StringBuilder();
            string        twox = "  ";

            sb.AppendLine("#$ COORDS");

            int count = model.Sequences.Count();

            sb.Append(twox);
            sb.AppendLine(INT(count, 13));

            foreach (var sequence in model.Sequences)
            {
                var ae = sequence.Sequence.FirstOrDefault();

                sb.Append(twox);
                sb.Append(INT(ae.From.Number, 13));
                sb.Append(FLO(ae.From.X, 13, 2, 4));
                sb.Append(FLO(ae.From.Y, 13, 2, 4));
                sb.Append(FLO(ae.From.Z, 13, 2, 4));
                sb.AppendLine();
            }

            return(sb);
        }
Esempio n. 2
0
        // Przewiduje poprawną cenę oferowanej książki przez system analityczny.
        public ContentResult <AnalyticModelPrediction> AnalizeOffer(FormalizedOffer offer)
        {
            var mlContext = new MLContext(0);

            ITransformer model;

            using (var stream = new FileStream(hostingEnvironment.ContentRootPath + "/private_static/model.zip", FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                model = mlContext.Model.Load(stream);
            }

            var toAnalize = new AnalyticModel
            {
                AuthorPopularity = offer.AuthorPopularity,
                Condition        = offer.Condition,
                Category         = offer.Category,
                Language         = offer.Language,
                IsEbook          = offer.IsEbook,
                WritingTime      = offer.WritingTime,
                PrintingTime     = offer.PrintingTime
            };

            var predictionEngine = model.CreatePredictionEngine <AnalyticModel, AnalyticModelPrediction>(mlContext);
            var predictedPrice   = predictionEngine.Predict(toAnalize);

            return(new ContentResult <AnalyticModelPrediction>
            {
                Content = predictedPrice
            });
        }
        internal StringBuilder Section_ELEMENTS(AnalyticModel model)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("#$ ELEMENTS");

            foreach (AnalyticElement ae in model.AllAnalyticElements)
            {
                sb.Append(wElement(ae));
            }

            return(sb);
        }
        private StringBuilder Section_MISCEL_1(AnalyticModel data)
        {
            StringBuilder sb   = new StringBuilder();
            string        twox = "  ";

            int MaterialNumber = 406;

            //Write material number
            int  numelt   = data.AllAnalyticElements.Count();
            bool straight = true;

            int nlines = numelt / 6;

            if (numelt % 6 != 0)
            {
                nlines += 1; straight = false;
            }

            for (int i = 0; i < nlines; i++)
            {
                if (i == nlines - 1 && straight == false)
                {
                    int rest = numelt - (nlines - 1) * 6;
                    sb.Append(twox);
                    sb.Append(FLO(MaterialNumber, 13, 0, 3, rest));
                    sb.AppendLine();
                    break;
                }

                sb.Append(twox);
                sb.Append(FLO(MaterialNumber, 13, 0, 3, 6));
                sb.AppendLine();
            }

            //Nozzles - not implemented
            //Hangers - not implemented
            //Execution Options
            sb.Append(@"              1            0            0            2       0.0000            0
              0            0  10.0000      10.0000                0            0
              0            0            0            0       0.2500            3
              0");
            sb.AppendLine();

            return(sb);
        }
 public ModelData(AnalyticModel Model)
 {
     Data = Model;
 }
        internal static StringBuilder Section_CONTROL(AnalyticModel model)
        {
            StringBuilder sb   = new StringBuilder();
            string        twox = "  ";

            //Gather data
            int numberOfReducers = model.AllAnalyticElements.Count(x => x.Type == ElemType.Transition);
            int numberOfElbows   = model.AllAnalyticElements.Count(x => x.Type == ElemType.Elbow);
            int numberOfRigids   = model.AllAnalyticElements.Count(x => x.Type == ElemType.Rigid);
            int numberOfTees     = model.AllAnalyticElements.Count(x => x.Type == ElemType.Tee);

            sb.AppendLine("#$ CONTROL");

            //Start of a new line
            sb.Append(twox);

            //NUMELT - number of "piping" (every element with DX, DY, DZ) elements
            sb.Append(INT(model.AllAnalyticElements.Count, 13));

            //NUMNOZ - number of nozzles
            sb.Append(INT(0, 13));

            //NOHGRS - number of hangers
            sb.Append(INT(0, 13));

            //NONAM - number of Node Name data blocks (A node can be given a name besides number)
            sb.Append(INT(0, 13));

            //NORED - number of reducers
            sb.Append(INT(numberOfReducers, 13));

            //NUMFLG - number of flanges (I think they mean flange checks)
            sb.Append(INT(0, 13));

            //NEWLINE
            sb.AppendLine();
            sb.Append(twox);

            //BEND - number of bends
            sb.Append(INT(numberOfElbows, 13));

            //RIGID - number of rigids
            sb.Append(INT(numberOfRigids, 13));

            //EXPJT - number of expansion joints
            sb.Append(INT(0, 13));

            //RESTRANT - number of restraints aux blocks
            sb.Append(INT(0, 13));

            //DISPLMNT - number of displacements
            sb.Append(INT(0, 13));

            //FORCMNT - number of force/moments
            sb.Append(INT(0, 13));

            //NEWLINE
            sb.AppendLine();
            sb.Append(twox);

            //UNIFORM - number of uniform loads
            sb.Append(INT(0, 13));

            //WIND - number of wind loads
            sb.Append(INT(0, 13));

            //OFFSETS - number of element offsets
            sb.Append(INT(0, 13));

            //ALLOWBLS - number of allowables
            sb.Append(INT(0, 13));

            //SIF&TEES - number of tees
            sb.Append(INT(numberOfTees, 13));

            //IZUP flag - 0 global Y axis vertical and 1 global Z axis vertical
            sb.Append(INT(1, 13)); //Revit works with Z axis vertical, so it is easier to keep it that way

            //NEWLINE
            sb.AppendLine();
            sb.Append(twox);

            //NOZNOM - number of nozzles
            sb.AppendLine(INT(0, 13));

            return(sb);
        }