Ejemplo n.º 1
0
        private void RunSimulation_Click(object sender, EventArgs e)
        {
            //try
            //{
            this.susceptableInitialParams = new InitialParameters();
            this.infectedInitialParams    = new InitialParameters();
            this.removedInitialParams     = new InitialParameters();

            this.SIR = new SIRModel();

            this.setInitialParameters();

            this.SIR.InfectedIndividualsInitialParameters    = this.infectedInitialParams;
            this.SIR.SusceptableIndividualsInitialParameters = this.susceptableInitialParams;
            this.SIR.RemovedIndividualsInitialParameters     = this.removedInitialParams;

            //this.predatorpreyModel.StartModel();
            this.SIR.StartModel();
            this.susceptableResults = this.SIR.SusceptablePopulation;
            this.infectedResults    = this.SIR.InfectionPopulation;
            this.removedResults     = this.SIR.RemovedPopulation;

            this.populateGridViewWithSeriesData();
            this.populateChartSeriesData();

            MessageBox.Show("Simulation run is complete.", "Simulation complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show("Error", ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            // }
        }
        private void RunSimulation_Click(object sender, EventArgs e)
        {
            try
            {
                this.preyInitialParams     = new InitialParameters();
                this.predatorInitialParams = new InitialParameters();

                this.predatorpreyModel = new PredatorPrey();

                this.setInitialParameters();

                //this.predatorpreyModel.StartModel();
                this.SelectModelToRun();
                this.preyResults     = this.predatorpreyModel.PreyResults;
                this.predatorResults = this.predatorpreyModel.PredatorResults;

                this.populateGridViewWithSeriesData();
                this.populateChartSeriesData();

                MessageBox.Show("Simulation run is complete.", "Simulation complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error", ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void RunSimulation_Click(object sender, EventArgs e)
        {
            this.initialParams            = new InitialParameters();
            this.unconstrainedGrowthModel = new UnconstrainedGrowth();

            this.setInitialParameters();

            this.unconstrainedGrowthModel.StartModel();
            this.results = this.unconstrainedGrowthModel.ResultSet;

            this.populateGridViewWithSeriesData();
            this.populateChartSeriesData();

            MessageBox.Show("Simulation run is complete.", "Simulation complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        private void RunSimulation_Click(object sender, EventArgs e)
        {
            this.competitorOneInitialParams = new InitialParameters();
            this.competitorTwoInitialParams = new InitialParameters();

            this.competitionModel = new Competition();

            this.setInitialParameters();

            this.competitionModel.StartModel();
            this.competitorOneResults = this.competitionModel.CompetitorOneResults;
            this.competitorTwoResults = this.competitionModel.CompetitorTwoResults;

            this.populateGridViewWithSeriesData();
            this.populateChartSeriesData();

            MessageBox.Show("Simulation run is complete.", "Simulation complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Ejemplo n.º 5
0
        public PredictionModelOutput Execute(PredictionModelInput parameters)
        {
            string json = JsonConvert.SerializeObject(parameters);


            // return null;
            var httpWebRequest = (HttpWebRequest)WebRequest.Create(_url);

            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method      = "POST";
            string content;

            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                streamWriter.Write(json);
                streamWriter.Flush();
                streamWriter.Close();
            }

            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                content = streamReader.ReadToEnd();
            }

            ModelResults data = JsonConvert.DeserializeObject <ModelResults>(content);

            //Calculate estimations errors.
            data.Results.CalculateErrors();
            PredictionModelOutput output = new PredictionModelOutput {
                OutputData = data.Results.Cars, MSE_Test = data.Results.MSE_Test, MSE_Training = data.Results.MSE_Training, Score_Test = data.Results.Score_Test, Score_Training = data.Results.Score_Training, TargetCar = data.Results.TargetCar
            };

            return(output);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Run an analysis on the specified model
        /// </summary>
        /// <param name="model"></param>
        /// <param name="alertLog"></param>
        /// <returns></returns>
        public ModelResults AnalyseModel(Model.Model model, AnalysisCaseCollection cases, AlertLog alertLog = null)
        {
            alertLog?.RaiseAlert("BLD", "Building analysis model...");

            var results = new ModelResults();

            // Create model:
            var feModel = new BFE.Model();

            // Create nodes:
            var nodesMap = new Dictionary <Guid, BFE.Node>();

            foreach (var node in model.Nodes)
            {
                var bfeNode = ToBFE.Convert(node);
                feModel.Nodes.Add(bfeNode);
                nodesMap.Add(node.GUID, bfeNode);
            }

            // Create materials:

            /*var materialsMap = new Dictionary<Guid, BFE.Materials.BaseMaterial>();
             * foreach (var material in model.Materials)
             * {
             *  var bfeMat = ToBFE.Convert(material);
             *  materialsMap.Add(material.GUID, bfeMat);
             * }*/

            // Create sections:

            /*foreach (var family in model.Families)
             * {
             *  if (family is SectionFamily)
             *  {
             *      SectionFamily section = (SectionFamily)family;
             *      //TODO?
             *  }
             * }*/

            // Create elements:
            var elementMap = new Dictionary <Guid, BFE.FrameElement2Node>();

            foreach (var element in model.Elements)
            {
                if (element is LinearElement)
                {
                    var linEl = (LinearElement)element;
                    if (linEl.StartNode != null && linEl.EndNode != null && linEl.Family != null)
                    {
                        var el = new BFE.FrameElement2Node(
                            nodesMap[linEl.StartNode.GUID], nodesMap[linEl.EndNode.GUID]);
                        //TODO: Releases
                        //TODO: Orientation
                        //TODO: Offsets
                        if (linEl.Family.Profile?.Perimeter != null)
                        {
                            var profile = ToBFE.Convert(linEl.Family.Profile.Perimeter);
                            el.Geometry = profile;
                            el.UseOverridedProperties = false;
                            //TODO: Hollow sections
                        }
                        el.E = linEl.Family.GetPrimaryMaterial()?.GetE(Geometry.Direction.X) ?? 210e9;
                        feModel.Elements.Add(el);
                        elementMap.Add(element.GUID, el);
                    }
                    else
                    {
                        alertLog.RaiseAlert("INCOMPLETE DATA", linEl, "Incomplete data.  Will be excluded from analysis.");
                    }
                }
            }

            //Loading time!
            // TODO: Limit to specific load cases?
            foreach (var load in model.Loads)
            {
                if (load is LinearElementLoad)
                {
                    var lEL = (LinearElementLoad)load;
                    if (lEL.IsMoment)
                    {
                        alertLog.RaiseAlert("MOMENTS UNSUPPORTED", load, "Moment line loads are not supported.", AlertLevel.Error);
                    }
                    else
                    {
                        // TODO: Set load case
                        var bLoad = new BFE.UniformLoad1D(lEL.Value, ToBFE.Convert(lEL.Direction), ToBFE.Convert(lEL.Axes));

                        // TODO: Generalise
                        var elements = lEL.AppliedTo.Items;
                        foreach (var el in elements)
                        {
                            elementMap[el.GUID].Loads.Add(bLoad);
                        }
                    }
                }
                else if (load is NodeLoad)
                {
                    var nL = (NodeLoad)load;
                }
                else
                {
                    alertLog.RaiseAlert("LOAD TYPE UNSUPPORTED", load, "Load type is not supported.", AlertLevel.Error);
                }
            }

            alertLog?.RaiseAlert("BLD", "Analysis model built.");

            alertLog.RaiseAlert("SLV", "Solving...");

            feModel.Solve();

            alertLog.RaiseAlert("SLV", "Solved.");

            foreach (var kvp in nodesMap)
            {
                var disp = kvp.Value.GetNodalDisplacement();
                var nR   = new NodeResults();
                var cNR  = new CaseNodeResults();

                //nR.Add(cNR);
            }

            /*foreach (var element in model.Elements)
             * {
             *  bNS = nodesMap[element]
             * }*/
            return(results);
        }