Esempio n. 1
0
 public void crearModeloCarnet()
 {
     pintarCarnet();
     dibujarPath();
     // Crea el modelo final
     SimioProjectFactory.SaveProject(apiCarnet, rutaFinal, out warnings);
 }
Esempio n. 2
0
        public void crearModelo()
        {
            crearRegiones();

            //modelo.Facility.IntelligentObjects["Source1"].Properties["InterarrivalTime"].Value = "Random.Exponential(5)";

            SimioProjectFactory.SaveProject(proyectoApi, rutafinal, out warnings);
        }
Esempio n. 3
0
        public void CrearCarnets()
        {
            String carnet1 = "201612097";
            String carnet2 = "201612276";

            CrearModelo(carnet1, 10, 10);
            CrearModelo(carnet2, 10, 40);
            SimioProjectFactory.SaveProject(proyectoApi, rutafinal, out warnings);
        }
Esempio n. 4
0
 private static void CrearNombreYApellido()
 {
     try
     {
         proyectoApi        = SimioProjectFactory.LoadProject(BASE, out warnings);
         intelligentObjects = proyectoApi.Models[1].Facility.IntelligentObjects;
         CrearNombre();
         CrearApellido();
         SimioProjectFactory.SaveProject(proyectoApi, FINAL_NOMBRE, out warnings);
     } catch
     {
     }
 }
Esempio n. 5
0
 public void GenerarMapa()
 {
     GenerarRegiones();
     Generar_Puntos_Cardinales();
     Generar_Aeropuertos();
     Generar_SalidaAeropuerto();
     Generar_Movimientos();
     Unir_Entrada_Aeropuertos();
     Generar_Turistas_Nacionales();
     Generar_Salida_Hacia_Aeropuertos();
     Generar_Quedarse_En_Misma_Region();
     GenerarContornosGuatemala();
     SimioProjectFactory.SaveProject(proyectoApi, rutafinal, out warnings);
 }
        /// <summary>
        /// Run an experiment. The experiment is Reset prior to run.
        /// A loaded project is passed in that must contain the named Model and Experiment.
        /// If the saveProjectPath is present and exists, then the project will be
        /// saved to that location. If there are Save warnings, then true is still
        /// returned, but the warnings are in explanation.
        /// </summary>
        /// <param name="projectPathAndFile"></param>
        /// <param name="experimentName"></param>
        /// <param name="saveModelAfterRun"></param>
        /// <param name="explanation"></param>
        /// <returns></returns>
        public static bool RunModelExperiment(ISimioProject project, string saveProjectPath,
                                              string modelName, string experimentName,
                                              out string explanation)
        {
            explanation = "";
            string marker = "Begin";

            try
            {
                marker = $"Loading Model named={modelName}";
                IModel model = LoadModel(project, modelName, out explanation);
                if (model == null)
                {
                    return(false);
                }


                marker = $"Loading Experiment named={experimentName}";
                if (!RunModelExperiment(model, experimentName, out explanation))
                {
                    throw new ApplicationException($"Cannot Run Experiment={experimentName}. Err={explanation}");
                }

                // Successful run. Save the project?
                if (File.Exists(saveProjectPath))
                {
                    marker = $"Save Project After Experiment Run to={saveProjectPath}";
                    LogIt($"Info: {marker}");

                    SimioProjectFactory.SaveProject(project, saveProjectPath, out string[] warnings);
                    explanation = "";
                    if (warnings.Any())
                    {
                        LogIt($"Warning: 'SaveProject' had {warnings.Length} Warnings:");
                        int nn = 0;
                        foreach (string warning in warnings)
                        {
                            explanation += $"  Warning[{++nn}]:{warning}";
                            LogIt($"  Warning: {warning}");
                        }
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                throw new ApplicationException($"Marker={marker} Err={ex.Message}");
            }
        }
Esempio n. 7
0
 public void crearModelo()
 {
     //this.principal();
     this.crearEntradaSalida();
     this.Mesas();
     this.Barras();
     this.Atencion();
     this.nodos();
     this.tiemposAtencion();
     this.rutas();
     //CREACION MODELO
     SimioProjectFactory.SaveProject(proyectoApi, rutafinal, out warnings);
     MessageBox.Show("El proyecto Simio ha sido generado");
     Console.WriteLine("Modelo Creado");
 }
Esempio n. 8
0
        /// <summary>
        /// Save the given project to the 'savePath'.
        /// </summary>
        /// <param name="project"></param>
        /// <param name="savePath"></param>
        public static bool SaveProject(HeadlessContext context, string savePath, out string explanation)
        {
            explanation = "";
            string marker = "Begin.";

            string[] warnings;

            // If project not loaded, return error
            if (context == null || context.CurrentProject == null)
            {
                explanation = $"Context or Project is null.";
                return(false);
            }

            string folderPath = Path.GetDirectoryName(savePath);

            if (Directory.Exists(folderPath) == false)
            {
                explanation = $"FolderPath={folderPath} not found.";
                return(false);
            }

            try
            {
                // Open project file.
                marker = $"Saving Project={context.CurrentProject.Name} to {savePath}.";
                LogIt($"Info: {marker}");
                if (!SimioProjectFactory.SaveProject(context.CurrentProject, savePath, out warnings))
                {
                    LogIt($"SaveProject failed.");
                }

                marker = $"Saved Project={savePath} with {warnings.Count()} warnings.";
                int ii = 1;
                foreach (string warning in warnings)
                {
                    LogIt($"Warning: {ii++}{warning}");
                }

                return(true);
            }
            catch (Exception ex)
            {
                explanation = $"Cannot Save Simio Project={context.CurrentProject.Name} to {savePath} Err={ex.Message}";
                return(false);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Save the given project to the 'savePath'.
        /// </summary>
        /// <param name="project"></param>
        /// <param name="savePath"></param>
        public bool SaveProject(string savePath, out string explanation)
        {
            explanation = "";
            string marker = "Begin.";

            string[] warnings;

            // If project not loaded, return error
            if (CurrentProject == null)
            {
                explanation = $"No project is loaded (Project is null).";
                return(false);
            }

            string folderPath = Path.GetDirectoryName(savePath);

            if (Directory.Exists(folderPath) == false)
            {
                explanation = $"FolderPath={folderPath} not found.";
                return(false);
            }

            try
            {
                // Save project file.
                marker = $"Saving Project={CurrentProject.Name} to {savePath}.";
                if (!SimioProjectFactory.SaveProject(CurrentProject, savePath, out warnings))
                {
                    explanation = $"SaveProject failed.";
                }

                marker = $"Saved Project={savePath} with {warnings.Count()} warnings.";
                ProjectSaveErrorList = new List <string>();
                int ii = 1;
                foreach (string warning in warnings)
                {
                    ProjectSaveErrorList.Add($"Warning: {ii++}{warning}");
                }

                return(true);
            }
            catch (Exception ex)
            {
                explanation = $"Cannot Save Simio Project={CurrentProject.Name} to {savePath} Err={ex.Message}";
                return(false);
            }
        }
Esempio n. 10
0
 public void CreateCards()
 {
     try
     {
         System.IO.File.WriteAllBytes(BASE_MODEL_PATH, FileStore.Resource.BaseModel);
         ISimioProject       project            = SimioProjectFactory.LoadProject(BASE_MODEL_PATH, out string[] warnings);
         IModel              model              = project.Models[1];
         IIntelligentObjects intelligentObjects = model.Facility.IntelligentObjects;
         CreateCarnet201503918(intelligentObjects);
         CreateCard201504420(intelligentObjects);
         SimioProjectFactory.SaveProject(project, CARD_MODEL_PATH, out warnings);
         System.IO.File.WriteAllLines(WARNINGS_FILE_PATH, warnings);
     }
     catch (Exception e)
     {
         System.IO.File.WriteAllText(WARNINGS_FILE_PATH, e.Message);
     }
 }
Esempio n. 11
0
 public void CreateModel(string finalModelPath)
 {
     try
     {
         System.IO.File.WriteAllBytes(BASE_MODEL_PATH, FileStore.Resource.BaseModel);
         ISimioProject       project            = SimioProjectFactory.LoadProject(BASE_MODEL_PATH, out string[] warnings);
         IModel              model              = project.Models[1];
         IIntelligentObjects intelligentObjects = model.Facility.IntelligentObjects;
         CreateMap(intelligentObjects);
         CreateShips(intelligentObjects);
         CreatePointCardinal(intelligentObjects);
         CreateAirports(intelligentObjects);
         SimioProjectFactory.SaveProject(project, finalModelPath, out warnings);
         System.IO.File.WriteAllLines(WARNINGS_FILE_PATH, warnings);
     } catch (Exception e)
     {
         System.IO.File.WriteAllText(WARNINGS_FILE_PATH, e.Message);
     }
 }
Esempio n. 12
0
 private static void CrearCarnet()
 {
     try
     {
         proyectoApi        = SimioProjectFactory.LoadProject(BASE, out warnings);
         intelligentObjects = proyectoApi.Models[1].Facility.IntelligentObjects;
         CrearDos(10, 50);
         CrearCero(50, 50);
         CrearUno(90, 50);
         CrearCinco(120, 50);
         CrearCero(160, 50);
         CrearCuatro(200, 50);
         CrearCuatro(240, 50);
         CrearDos(280, 50);
         CrearCero(320, 50);
         SimioProjectFactory.SaveProject(proyectoApi, FINAL_CARNET, out warnings);
     }
     catch
     {
     }
 }
        /// <summary>
        /// Set the extensionpath, load a project, then load the model, and run a plan for that model.
        /// </summary>
        /// <param name="extensionsPath">For DLL search. E.g. AppDomain.CurrentDomain.BaseDirectory</param>
        /// <param name="projectPathAndFile"></param>
        /// <param name="arguments">Comma delimited string of arguments</param>
        /// <param name="runRiskAnalysis"></param>
        /// <param name="explanation"></param>
        /// <returns></returns>
        public static bool RunProjectPlan(string extensionsPath, string projectFullPath, List <RequestArgument> argList, out string explanation)
        {
            explanation = "";
            string marker = "Begin";

            string[] warnings;

            try
            {
                // Set an extensions path to where we can locate User Extensions, etc.
                if (string.IsNullOrEmpty(extensionsPath))
                {
                    extensionsPath = System.AppDomain.CurrentDomain.BaseDirectory;
                    LogIt($"Info: No ExtensionsPath supplied. Defaulting to={extensionsPath}");
                }

                marker = $"Setting Extensions Path to={extensionsPath}";
                LogIt($"Info: {marker}");

                string saveAs = GetArgumentAsString(argList, "saveAs", "", out explanation);
                if (saveAs != null && !Directory.Exists(saveAs))
                {
                    explanation = $"SaveAs path={saveAs} does not exist.";
                    return(false);
                }

                string modelName       = GetArgumentAsString(argList, "model", "model", out explanation);
                bool?  runRiskAnalysis = GetArgumentAsBoolean(argList, "riskAnalysis", false, out explanation);
                if (runRiskAnalysis == null)
                {
                    explanation = $"{explanation}";
                    return(false);
                }
                bool?publishPlan = GetArgumentAsBoolean(argList, "publishPlan", false, out explanation);

                // Load the Project
                ISimioProject project = null;
                try
                {
                    //Cursor.Current = Cursors.WaitCursor;
                    SimioProjectFactory.SetExtensionsPath(extensionsPath);

                    project = LoadProject(extensionsPath, projectFullPath, out explanation);
                    if (project == null)
                    {
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    explanation = $"Cannot load from {projectFullPath}. Err={ex.Message}";
                    return(false);
                }
                finally
                {
                    //Cursor.Current = Cursors.Default;
                }

                // Load the Model
                IModel model = LoadModel(project, modelName, out explanation);
                if (model == null)
                {
                    return(false);
                }



                // Test to see if we can 'cheat'
                IPlan plan = (IPlan)model;
                plan.RunPlan(new RunPlanOptions()
                {
                    AllowDesignErrors = true
                });

                // Check for Plan
                if (model.Plan == null)
                {
                    explanation = $"Model={model.Name} has no Plan (you may not have a license for one)";
                    return(false);
                }

                // Start Plan
                marker = "Starting Plan (model.Plan.RunPlan)";
                LogIt($"Info: {marker}");
                model.Plan.RunPlan(new RunPlanOptions()
                {
                    AllowDesignErrors = true
                });

                IPlan plan2 = (IPlan)model;
                plan2.RunPlan(new RunPlanOptions()
                {
                    AllowDesignErrors = true
                });

                if (runRiskAnalysis.Value)
                {
                    marker = "Plan Finished...Starting Analyze Risk (model.Plan.RunRiskAnalysis)";
                    LogIt($"Info: {marker}");
                    model.Plan.RunRiskAnalysis();
                }

                if (saveAs != null)
                {
                    marker = $"Saving Project to={saveAs}";
                    LogIt($"Info: {marker}");
                    SimioProjectFactory.SaveProject(project, saveAs, out warnings);
                }

                if (publishPlan.Value)
                {
                    marker = "PublishPlan";
                    LogIt($"Info: {marker}");

                    // Todo: Add publish plan code here
                }
                marker = "End";

                return(true);
            }
            catch (Exception ex)
            {
                explanation = $"Project={projectFullPath} Marker={marker} Err={ex.Message}";
                Alert(explanation);
                return(false);
            }
        } // RunModel
Esempio n. 14
0
 public void crearModelo()
 {
     crear_modelo();
     SimioProjectFactory.SaveProject(proyectoApi, rutafinal, out warnings);
 }
Esempio n. 15
0
        static void Main(string[] args)
        {
            // Open project
            string[] warnings;
            try
            {
                Console.WriteLine("Start");
                // We'll assume our DLLs have been placed at the same location as this EXE
                string extensionsPath = System.AppDomain.CurrentDomain.BaseDirectory;
                SimioProjectFactory.SetExtensionsPath(extensionsPath);

                Console.WriteLine("Read Command Line Settings");
                if (args.Length == 0)
                {
                    throw new Exception("Project Path And File Must Be Specified In First Command Argument");
                }

                // set parameters
                string projectPathAndFile  = args[0];
                bool   runRiskAnalysis     = false;
                bool   saveModelAfterRun   = false;
                bool   publishPlanAfterRun = false;
                string modelName           = "Model";
                string publishName         = "";

                // set project file
                if (args.Length >= 2)
                {
                    runRiskAnalysis = Convert.ToBoolean(args[1]);
                }
                if (args.Length >= 3)
                {
                    saveModelAfterRun = Convert.ToBoolean(args[2]);
                }
                if (args.Length >= 4)
                {
                    publishPlanAfterRun = Convert.ToBoolean(args[3]);
                }
                if (args.Length >= 5)
                {
                    modelName = args[4];
                }
                if (args.Length >= 6)
                {
                    publishName = args[5];
                }

                // If File Not Exist, Throw Exeption
                if (File.Exists(projectPathAndFile) == false)
                {
                    throw new Exception("Project Not Found : " + projectPathAndFile);
                }

                Console.WriteLine("Project Name = " + projectPathAndFile);

                // Open project file.
                Console.WriteLine($"Loading Model=[{modelName}]");
                _simioProject = SimioProjectFactory.LoadProject(projectPathAndFile, out warnings);

                // Run schedule and save for existing events.
                var model = _simioProject.Models[modelName];
                if (model == null)
                {
                    Console.WriteLine("Model Not Found In Project");
                }
                else
                {
                    if (model.Plan == null)
                    {
                        throw new ApplicationException($"Model's Plan is null. Do you have the correct Simio licensing?");
                    }

                    // Start Plan
                    Console.WriteLine("Starting Plan");
                    RunPlanOptions options = new RunPlanOptions();
                    options.AllowDesignErrors = false;

                    model.Plan.RunPlan(options);
                    if (runRiskAnalysis)
                    {
                        Console.WriteLine("Plan Finished...Starting Analyze Risk");
                        model.Plan.RunRiskAnalysis();
                    }

                    if (saveModelAfterRun)
                    {
                        Console.WriteLine("Save Project After Schedule Run");
                        SimioProjectFactory.SaveProject(_simioProject, projectPathAndFile, out warnings);
                    }

                    // Publish the plan to portal after Run.
                    // This (of course) requires the URL of your Portal, plus an access token (PAT) for security.
                    if (publishPlanAfterRun)
                    {
                        Console.WriteLine("Info: PublishPlan");
                        string url = "https://test.internal.SimioPortal.com/";
                        string pat = "eyJ1IjoiZGFuX2hvdWNrQGhvdG1haWwuY29tIiwidCI6Ik9zeEp1bmtqdnBPaHcxR2RlUk9INjBSTUcyVm51SFpXSFBQbmpYMVNHREo3cjFkT0pMWVZhQXpFeHdzM0RvVWlIWU41Tjd4YUFhZndVNmNFekVuN1FBPT0ifQ ==";
                        var    pub = DoPublish(url, projectPathAndFile, pat, modelName, publishName, "Scheduling Discrete Part Production");
                        pub.Wait();
                    }


                    Console.WriteLine("End");
                    Console.ReadLine();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("RunError=" + ex.Message);
            }
        }
Esempio n. 16
0
        public void analizar()
        {
            if (listaAeropuertos.Count > 0 && listaVuelos.Count > 0)
            {
                // ISimioProject _simioproject;
                string _projectPathAndFile = getPathActual();
                //MessageBox.Show(_projectPathAndFile);
                string[] warnings;
                currentProject = SimioProjectFactory.LoadProject("Model.spfx", out warnings);

                //ISimioProject project = SimioProjectFactory.LoadProject("Test.spfx", out warnings);
                IModel model = currentProject.Models["Model"];

                IExperiment experiment = model.Experiments.Create("Experiment");

                // Setup the experiment (optional)
                // Specify run times.
                //string experiment_ScenarioEnded = "2";
                double    runtime = 2;
                IRunSetup setup   = experiment.RunSetup;
                setup.StartingTime         = new DateTime(2010, 10, 01);
                setup.WarmupPeriod         = TimeSpan.FromHours(0);
                setup.EndingTime           = experiment.RunSetup.StartingTime + TimeSpan.FromDays(runtime);
                experiment.ConfidenceLevel = ExperimentConfidenceLevelType.Point90;
                experiment.LowerPercentile = 5;
                experiment.UpperPercentile = 95;
                //model.Facility.IntelligentObjects["aeropuerto"].Properties["InitialCapacity"].Value = "69";
                int          contador = 0;
                Random       rnd      = new Random();
                IFixedObject source   = model.Facility.IntelligentObjects["fuente"] as IFixedObject;
                source.Properties["InterarrivalTime"].Value = "Random.Poisson(60/300)";
                foreach (var air in listaAeropuertos)
                {
                    TiempoServicioGeneral = rnd.Next(1, 3);

                    IFixedObject aeropuerto = model.Facility.IntelligentObjects.CreateObject("Server", new FacilityLocation(air.x, air.y, air.z)) as IFixedObject;
                    aeropuerto.ObjectName = air.nombre;
                    switch (TiempoServicioGeneral)
                    {
                    case 1:
                        aeropuerto.Properties["ProcessingTime"].Value = "Random.Triangular(35,45,60)";
                        break;

                    case 2:
                        aeropuerto.Properties["ProcessingTime"].Value = "Random.Triangular(30,40,50)";
                        break;

                    case 3:
                        aeropuerto.Properties["ProcessingTime"].Value = "Random.Uniform(30,50)";
                        break;
                    }
                    aeropuerto.Properties["FailureType"].Value          = air.tipoFalla;
                    aeropuerto.Properties["OffShiftRule"].Value         = "FinishWorkAlreadyStarted";
                    aeropuerto.Properties["CountBetweenFailures"].Value = air.cantEntreFallas.ToString();
                    aeropuerto.Properties["TimeToRepair"].Value         = air.tiempoReparacion.ToString();

                    IFixedObject mezclador = model.Facility.IntelligentObjects.CreateObject("Combiner", new FacilityLocation(air.x, air.y + 30, air.z)) as IFixedObject;
                    String       n         = air.nombre + "C";
                    mezclador.ObjectName = n;

                    IFixedObject sourceAviones = model.Facility.IntelligentObjects.CreateObject("Source", new FacilityLocation(air.x, air.y + 30, air.z)) as IFixedObject;
                    n = air.nombre + "S";
                    sourceAviones.ObjectName = n;
                    sourceAviones.Properties["InitialCapacity"].Value = "100";

                    IIntelligentObject pista = model.Facility.IntelligentObjects.CreateObject("Server", new FacilityLocation(air.x, air.y + 30, air.z));
                    n = air.nombre + "P";
                    pista.ObjectName = n;

                    pista.Properties["InitialCapacity"].Value = air.capacidadPista.ToString();
                    ILinkObject path1 = model.Facility.IntelligentObjects.CreateLink("TimePath", source.Nodes[0], aeropuerto.Nodes[0], null) as ILinkObject;
                    path1.Properties["TravelTime"].Value = air.tiempoAbordajeDespegue.ToString();
                    ILinkObject path  = model.Facility.IntelligentObjects.CreateLink("Path", sourceAviones.Nodes[0], mezclador.Nodes[0], null) as ILinkObject;
                    ILinkObject path3 = model.Facility.IntelligentObjects.CreateLink("Path", aeropuerto.Nodes[0], mezclador.Nodes[1], null) as ILinkObject;



                    //nuevo.Properties[""].Value = air.tiempoPersonas;
                    //nuevo.Properties[""].Value = air.tiempoAbordajeDespegue;
                    //nuevo.Properties[""].Value = air.id;



                    //if (contador == 0)
                    //{

                    //    model.Facility.IntelligentObjects["DefaultEntity"].Properties["Name"].Value = air.nombre;

                    //}
                    //else
                    //{
                    //    model.Facility.IntelligentObjects["Server"+(contador+1)].Properties["Name"].Value = air.nombre;
                    //}

                    //model.Facility.IntelligentObjects[2].Properties["name"].Value = air.nombre;
                    contador = contador + 1;
                }

                //model.Facility.IntelligentObjects.CreateObject("Server", new FacilityLocation(0, 0, 0));


                /*
                 * // Add event handler for events from experiment
                 * experiment.ScenarioEnded += new EventHandler<ScenarioEndedEventArgs>(experiment_ScenarioEnded);
                 * experiment.RunCompleted += new EventHandler<RunCompletedEventArgs>(experiment_RunCompleted);
                 * experiment.RunProgressChanged += new EventHandler<RunProgressChangedEventArgs>(experiment_RunProgressChanged);
                 * experiment.ReplicationEnded += new EventHandler<ReplicationEndedEventArgs>(experiment_ReplicationEnded);
                 */
                // Run Experiment, will call event handler methods when finished etc.
                SimioProjectFactory.SaveProject(currentProject, "Nuevo.spfx", out warnings);
            }
            else
            {
                MessageBox.Show("Debe cargar ambos archivos.");
            }
        }
Esempio n. 17
0
        static void Main(string[] args)
        {
            // Open project
            string[] warnings;
            try
            {
                Console.WriteLine("Start");
                string extensionsPath = System.AppDomain.CurrentDomain.BaseDirectory;
                SimioProjectFactory.SetExtensionsPath(extensionsPath);

                Console.WriteLine("Read Command Line Settings");
                if (args.Length == 0)
                {
                    throw new Exception("Project Path And File Must Be Specified In First Command Argument");
                }

                // set parameters
                string projectPathAndFile = args[0];
                bool   saveModelAfterRun  = false;
                string modelName          = "Model";
                string experimentName     = "";

                if (!File.Exists(projectPathAndFile))
                {
                    throw new ApplicationException($"Cannot find SimioProject file at={projectPathAndFile}");
                }

                if (args.Length >= 2)
                {
                    saveModelAfterRun = Convert.ToBoolean(args[1]);
                }
                if (args.Length >= 3)
                {
                    modelName = args[2];
                }
                if (args.Length >= 4)
                {
                    experimentName = args[3];
                }

                // If File Not Exist, Throw Exeption
                if (File.Exists(projectPathAndFile) == false)
                {
                    throw new Exception("Project Not Found : " + projectPathAndFile);
                }

                Console.WriteLine("Project Name = " + projectPathAndFile);

                // Open project file.
                Console.WriteLine($"Loading Model=[{modelName}]");
                _simioProject = SimioProjectFactory.LoadProject(projectPathAndFile, out warnings);

                // Run schedule and save for existing events.
                var model = _simioProject.Models[modelName];
                if (model == null)
                {
                    Console.WriteLine("Model Not Found In Project");
                }
                else
                {
                    if (model.Experiments == null)
                    {
                        throw new ApplicationException($"Model's Experiments collection is null.");
                    }

                    // Start Experiment
                    Console.WriteLine("Starting Experiment");
                    string projectPath = "";

                    if (!HeadlessHelpers.RunExperiment(extensionsPath, projectPath, modelName, experimentName, saveModelAfterRun,
                                                       out string explanation))
                    {
                        throw new ApplicationException(explanation);
                    }
                    else
                    {
                        Console.WriteLine($"Info: Model={modelName} Experiment={experimentName} performed the actions successfully. Check the logs for more information.");
                    }


                    if (saveModelAfterRun)
                    {
                        Console.WriteLine("Save Project After Experiment Run");
                        SimioProjectFactory.SaveProject(_simioProject, projectPathAndFile, out warnings);
                    }

                    Console.WriteLine("End");
                    Console.ReadLine();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("RunError=" + ex.Message);
            }
        }
Esempio n. 18
0
        static void Main(string[] args)
        {
            // Open project
            string[] warnings;
            try
            {
                string extensionsPath = System.AppDomain.CurrentDomain.BaseDirectory;
                Logit($"Info: Starting. Default ExtensionsPath={extensionsPath}.");
                SimioProjectFactory.SetExtensionsPath(extensionsPath);
                Logit($"Info: ExtensionsPath Set successfully.");

                Logit("Read Command Line Settings");
                if (args.Length == 0)
                {
                    throw new Exception("Project Path And File Must Be Specified In First Command Argument");
                }

                // set parameters
                string projectPathAndFile = args[0];
                bool   saveModelAfterRun  = false;
                string modelName          = "Model";
                string experimentName     = "";

                if (!File.Exists(projectPathAndFile))
                {
                    throw new ApplicationException($"Cannot find SimioProject file at={projectPathAndFile}");
                }

                if (args.Length >= 2)
                {
                    saveModelAfterRun = Convert.ToBoolean(args[1]);
                }
                if (args.Length >= 3)
                {
                    modelName = args[2];
                }
                if (args.Length >= 4)
                {
                    experimentName = args[3];
                }

                // If File Not Exist, Throw Exeption
                if (File.Exists(projectPathAndFile) == false)
                {
                    throw new Exception("Project Not Found : " + projectPathAndFile);
                }

                string projectFolder = Path.GetDirectoryName(projectPathAndFile);

                Logit($"Project Name={projectPathAndFile} Model={modelName} Experiment={experimentName} SaveAfterRun={saveModelAfterRun}");

                // Test if experiment can be done.
                string simpleTestProjectFullpath = Path.Combine(projectFolder, "LicenseExperimentTest.spfx");
                if (File.Exists(simpleTestProjectFullpath))
                {
                    Logit($"Info: Testing license with Project=[{simpleTestProjectFullpath}]");

                    try
                    {
                        Logit($"Info: Loading License Project=[{simpleTestProjectFullpath}]");
                        ISimioProject simioProject = SimioProjectFactory.LoadProject(simpleTestProjectFullpath, out warnings);

                        if (!SimEngineHelpers.RunModelExperiment(simioProject, "", "Model", "Experiment1",
                                                                 out string explanation))
                        {
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new ApplicationException($"LicenseTest: Cannot Run Simple Experiment. Err={ex.Message}");
                    }
                }

                // Open project file.
                Logit($"Loading Project=[{projectPathAndFile}]");
                _simioProject = SimioProjectFactory.LoadProject(projectPathAndFile, out warnings);

                // Run schedule and save for existing events.
                var model = _simioProject.Models[modelName];
                if (model == null)
                {
                    throw new ApplicationException($"Model={modelName} Not Found In Project={projectPathAndFile}");
                }
                else
                {
                    if (model.Experiments == null)
                    {
                        throw new ApplicationException($"Model's Experiments collection is null.");
                    }

                    // Start Experiment
                    Logit("Starting Experiment");

                    string savePathAndFile = "";
                    if (saveModelAfterRun)
                    {
                        savePathAndFile = projectPathAndFile;
                    }

                    if (!SimEngineHelpers.RunModelExperiment(extensionsPath, projectPathAndFile, savePathAndFile, modelName, experimentName,
                                                             out string explanation))
                    {
                        throw new ApplicationException(explanation);
                    }
                    else
                    {
                        Logit($"Info: Model={modelName} Experiment={experimentName} performed the actions successfully. Check the logs for more information.");
                    }


                    if (saveModelAfterRun)
                    {
                        Logit("Save Project After Experiment Run");
                        SimioProjectFactory.SaveProject(_simioProject, projectPathAndFile, out warnings);
                    }

                    Logit("End");
                    Console.ReadLine();
                }
            }
            catch (Exception ex)
            {
                Logit($"RunError={ex.Message}");
            }
        }
Esempio n. 19
0
        /// <summary>
        /// Run a model plan
        /// </summary>
        /// <param name="projectPathAndFile"></param>
        /// <param name="modelName"></param>
        /// <param name="runRiskAnalysis"></param>
        /// <param name="saveModelAfterRun"></param>
        /// <param name="publishPlanAfterRun"></param>
        /// <param name="explanation"></param>
        /// <returns></returns>
        public static bool RunModel(string projectFullPath, string modelName, bool runRiskAnalysis, bool saveModelAfterRun, bool publishPlanAfterRun, out string explanation)
        {
            explanation = "";
            string marker = "Begin";

            string[] warnings;

            try
            {
                // Set an extensions path to where we can locate User Extensions, etc.
                string extensionsPath = System.AppDomain.CurrentDomain.BaseDirectory;
                marker = $"Setting Extensions Path to={extensionsPath}";
                LogIt($"Info: {marker}");

                ISimioProject project = null;
                try
                {
                    Cursor.Current = Cursors.WaitCursor;
                    SimioProjectFactory.SetExtensionsPath(extensionsPath);

                    project = LoadProject(projectFullPath, out explanation);
                    if (project == null)
                    {
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    explanation = $"Cannot load from {projectFullPath}. Err={ex}";
                    return(false);
                }
                finally
                {
                    Cursor.Current = Cursors.Default;
                }

                IModel model = LoadModel(project, modelName, out explanation);
                if (model == null)
                {
                    return(false);
                }

                // Check for Plan
                if (model.Plan == null)
                {
                    explanation = $"Model={model.Name} has no Plan.";
                    return(false);
                }

                // Start Plan
                marker = "Starting Plan (model.Plan.RunPlan)";
                LogIt($"Info: {marker}");
                model.Plan.RunPlan();

                if (runRiskAnalysis)
                {
                    marker = "Plan Finished...Starting Analyze Risk (model.Plan.RunRiskAnalysis)";
                    LogIt($"Info: {marker}");
                    model.Plan.RunRiskAnalysis();
                }
                if (saveModelAfterRun)
                {
                    marker = "Save Project After Schedule Run (SimioProjectFactory.SaveProject)";
                    LogIt($"Info: {marker}");
                    SimioProjectFactory.SaveProject(project, projectFullPath, out warnings);
                }
                if (publishPlanAfterRun)
                {
                    marker = "PublishPlan";
                    LogIt($"Info: {marker}");

                    // ADD PUBLISH PLAN CODE HERE
                }
                marker = "End";


                return(true);
            }
            catch (Exception ex)
            {
                explanation = $"Project={projectFullPath} Model={modelName} Marker={marker} Err={ex.Message}";
                Alert(explanation);
                return(false);
            }
        } // RunModel
Esempio n. 20
0
        /// <summary>
        /// Set the extensionpath, load a project, then the load the model, and run a plan for that model.
        /// </summary>
        /// <param name="extensionsPath">For DLL search. E.g. AppDomain.CurrentDomain.BaseDirectory</param>
        /// <param name="projectPathAndFile"></param>
        /// <param name="modelName"></param>
        /// <param name="runRiskAnalysis"></param>
        /// <param name="saveModelAfterRun"></param>
        /// <param name="publishPlanAfterRun"></param>
        /// <param name="explanation"></param>
        /// <returns></returns>
        public static bool RunModelPlan(string extensionsPath, string projectFullPath, string modelName, bool runRiskAnalysis, bool saveModelAfterRun, bool publishPlanAfterRun, out string explanation)
        {
            explanation = "";
            string marker = "Begin";

            string[] warnings;

            try
            {
                // Set an extensions path to where we can locate User Extensions, etc.
                if (string.IsNullOrEmpty(extensionsPath))
                {
                    extensionsPath = System.AppDomain.CurrentDomain.BaseDirectory;
                    LogIt($"Info: No ExtensionsPath supplied. Defaulting to={extensionsPath}");
                }

                marker = $"Setting Extensions Path to={extensionsPath}";
                LogIt($"Info: {marker}");

                // Load the Project
                ISimioProject project = null;
                try
                {
                    Cursor.Current = Cursors.WaitCursor;
                    SimioProjectFactory.SetExtensionsPath(extensionsPath);

                    project = LoadProject(extensionsPath, projectFullPath, out explanation);
                    if (project == null)
                    {
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    explanation = $"Cannot load from {projectFullPath}. Err={ex.Message}";
                    return(false);
                }
                finally
                {
                    Cursor.Current = Cursors.Default;
                }

                // Load the Model
                IModel model = LoadModel(project, modelName, out explanation);
                if (model == null)
                {
                    return(false);
                }

                // Test to see if we can 'cheat'
                IPlan plan = (IPlan)model;
                plan.RunPlan();

                // Check for Plan
                if (model.Plan == null)
                {
                    explanation = $"Model={model.Name} has no Plan (you may not have a license for one)";
                    return(false);
                }

                // Start Plan
                marker = "Starting Plan (model.Plan.RunPlan)";
                LogIt($"Info: {marker}");
                model.Plan.RunPlan();

                IPlan plan2 = (IPlan)model;
                plan2.RunPlan();

                if (runRiskAnalysis)
                {
                    marker = "Plan Finished...Starting Analyze Risk (model.Plan.RunRiskAnalysis)";
                    LogIt($"Info: {marker}");
                    model.Plan.RunRiskAnalysis();
                }
                if (saveModelAfterRun)
                {
                    marker = "Save Project After Schedule Run (SimioProjectFactory.SaveProject)";
                    LogIt($"Info: {marker}");
                    SimioProjectFactory.SaveProject(project, projectFullPath, out warnings);
                }
                if (publishPlanAfterRun)
                {
                    marker = "PublishPlan";
                    LogIt($"Info: {marker}");

                    // Todo: Add publish plan code here
                }
                marker = "End";

                return(true);
            }
            catch (Exception ex)
            {
                explanation = $"Project={projectFullPath} Model={modelName} Marker={marker} Err={ex.Message}";
                Alert(explanation);
                return(false);
            }
        } // RunModel
Esempio n. 21
0
 private void guardarModeloSalida()
 {
     SimioProjectFactory.SaveProject(_simioproyecto, _rutaSalida, out warnings);
 }
Esempio n. 22
0
        private void CalcularButton_Click(object sender, EventArgs e)
        {
            SimioProjectFactory.SetExtensionsPath(System.AppDomain.CurrentDomain.BaseDirectory);
            string[] warnings;
            try
            {
                string path = "Modelo1_G1.spfx";
                if (File.Exists(path) == false)
                {
                    throw new ApplicationException($"Proyecto no encontrado:{path}");
                }

                ISimioProject _simioProject = SimioAPI.SimioProjectFactory.LoadProject(path, out warnings);
                IModel        model         = _simioProject.Models[1];

                //var jsonObj = JsonConvert.DeserializeObject<List<aeropuerto>>(sb.ToString());
                //foreach (var obj in jsonObj)
                //{
                //    model.Facility.IntelligentObjects.CreateObject("Combiner", new FacilityLocation(obj.posicion_x, obj.posicion_z, obj.posicion_y));

                //}

                model.Facility.IntelligentObjects.CreateObject("Source", new FacilityLocation(0, 0, 0));
                var objetoA = model.Facility.IntelligentObjects["Source1"];
                objetoA.ObjectName = "Personas";
                objetoA.Properties["EntityType"].Value       = "ModelEntity1";
                objetoA.Properties["InterarrivalTime"].Value = "Random.Poisson(5)";

                INodeObject nodo       = ((IFixedObject)model.Facility.IntelligentObjects["Personas"]).Nodes[0];
                var         nombreNodo = nodo.Properties["OutboundLinkRule"];
                nombreNodo.Value = "By Link Weight";
                //[64] = {EnteredAddOnProcess: }
                var exitedProcess = nodo.Properties["EnteredAddOnProcess"];
                exitedProcess.Value = "Process1";

                model.Facility.IntelligentObjects.CreateObject("Source", new FacilityLocation(-20, 0, 0));
                var objetoB = model.Facility.IntelligentObjects["Source1"];
                objetoB.ObjectName = "Aviones";
                objetoB.Properties["EntityType"].Value       = "ModelEntity2";
                objetoB.Properties["InterarrivalTime"].Value = "Random.Poisson(0.1)";

                foreach (DataRow fila in dt.Rows)
                {
                    //model.Facility.IntelligentObjects.CreateObject("Combiner", new FacilityLocation(Convert.ToDouble(fila[2]), Convert.ToDouble(fila[3]), Convert.ToDouble(fila[4])));
                    model.Facility.IntelligentObjects.CreateObject("Combiner", new FacilityLocation(Convert.ToDouble(fila[2]), Convert.ToDouble(fila[4]), Convert.ToDouble(fila[3])));

                    var objeto = model.Facility.IntelligentObjects["Combiner1"];
                    objeto.ObjectName = "aeropuerto_" + Convert.ToString(fila[0]);

                    model.Facility.IntelligentObjects.CreateObject("Sink", new FacilityLocation((Convert.ToDouble(fila[2]) - 5), Convert.ToDouble(fila[4]), Convert.ToDouble(fila[3])));

                    var entradaAeropuerto = model.Facility.IntelligentObjects["Sink1"];
                    entradaAeropuerto.ObjectName = "AuxAeropuerto_" + Convert.ToString(fila[0]);

                    String      vari           = "aeropuerto_" + Convert.ToString(fila[0]);
                    INodeObject nodo2          = ((IFixedObject)model.Facility.IntelligentObjects[vari]).Nodes[1];
                    var         exitedProcess2 = nodo2.Properties["EnteredAddOnProcess"];
                    exitedProcess2.Value = "Write_Bitacora";

                    //FailureType = 61
                    objeto.Properties[61].Value = Convert.ToString(fila[5]);
                    //CountBetweenFailures = 63
                    objeto.Properties[63].Value = Convert.ToString(fila[6]);
                    //TimeToRepair = 65
                    objeto.Properties[65].Value = Convert.ToString((Convert.ToDouble(fila[7]) / 60));
                    //InitialCapacity = 16
                    objeto.Properties[16].Value = Convert.ToString(fila[8]);
                    //ProcessingTime = 39
                    objeto.Properties[39].Value = Convert.ToString(fila[10]);
                    //BatchQuantity = 27
                    objeto.Properties[27].Value = "100";
                    //MemberTransferInTime
                    objeto.Properties["MemberTransferInTime"].Value = Convert.ToString(fila[9]);;


                    String      combi         = "aeropuerto_" + Convert.ToString(fila[0]);
                    INodeObject a             = ((IFixedObject)model.Facility.IntelligentObjects["Personas"]).Nodes[0];
                    INodeObject b             = ((IFixedObject)model.Facility.IntelligentObjects[combi]).Nodes[1];
                    var         arista        = model.Facility.IntelligentObjects.CreateLink("Path", a, b, null);
                    var         tipoSeleccion = arista.Properties["SelectionWeight"];
                    //Math.If( ModelEntity.destino == 1, 1, 0 )
                    tipoSeleccion.Value = "Math.If( ModelEntity.a_origen == " + Convert.ToString(fila[0]) + ", 1, 0 )";

                    String      combi2 = "aeropuerto_" + Convert.ToString(fila[0]);
                    INodeObject a2     = ((IFixedObject)model.Facility.IntelligentObjects["Aviones"]).Nodes[0];
                    INodeObject b2     = ((IFixedObject)model.Facility.IntelligentObjects[combi]).Nodes[0];
                    model.Facility.IntelligentObjects.CreateLink("Path", a2, b2, null);
                }

                //var objeto2 = model.Facility.IntelligentObjects["aeropuerto_1"];
                //objeto2.ObjectName = "nuevo";


                /**************Esto es para los Path**************/
                //Destino posicion 0
                //Origen posicion 1

                foreach (DataRow fila in dt2.Rows)
                {
                    String aux1 = "aeropuerto_" + fila[0];
                    String aux2 = "aeropuerto_" + fila[1];
                    String aux3 = "AuxAeropuerto_" + fila[0];

                    //Aeropuerto Origen -> Salida
                    INodeObject a = ((IFixedObject)model.Facility.IntelligentObjects[aux2]).Nodes[2];
                    INodeObject b = ((IFixedObject)model.Facility.IntelligentObjects[aux3]).Nodes[0];
                    model.Facility.IntelligentObjects.CreateLink("Path", a, b, null);
                }

                //*************** Esto es para los experimentos **********/
                //IExperiment experimento = model.Experiments.Create("Experimento");

                ////configurando el experimento
                //IRunSetup setup = experimento.RunSetup;
                //setup.StartingTime = new DateTime(2018, 10, 1);
                //setup.WarmupPeriod = TimeSpan.FromHours(0);
                //setup.EndingTime = experimento.RunSetup.StartingTime + TimeSpan.FromDays(1);
                //experimento.ConfidenceLevel = ExperimentConfidenceLevelType.Point95;
                //experimento.LowerPercentile = 25;
                //experimento.UpperPercentile = 75;
                ////configuracion variable de control

                ////configurando los responses
                ////a estos hay que asignarles un valor en el escenario
                //IExperimentResponse response1 = experimento.Responses.Create("CantidadAviones");
                //response1.Expression = "avion.cantidad"; //valor de ejemplo
                //IExperimentResponse response2 = experimento.Responses.Create("CantidadPersonasTranportadas");
                //response2.Expression = "personas.cantidad"; //valor de ejemplo

                ////creando un escenario
                //IScenario escenario1 = experimento.Scenarios.Create("escenario1");
                //IScenario escenario2 = experimento.Scenarios.Create("escenario2");
                //IScenario escenario3 = experimento.Scenarios.Create("escenario3");

                //escenario creados
                //TODO cambiar la variable de control por escenario
                //como se hace? el metodo de controls de cada escenario solo tiene un get
                //que solo devueleve el valor del control pero no para asignarselo

                SimioProjectFactory.SaveProject(_simioProject, path, out warnings);
                MessageBox.Show("Carga realizada");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Esempio n. 23
0
        public void CreateModel(string finalModelPath)
        {
            try
            {
                System.IO.File.WriteAllBytes(BASE_MODEL_PATH, FileStore.Resource.BaseModel);
                ISimioProject       project            = SimioProjectFactory.LoadProject(BASE_MODEL_PATH, out string[] warnings);
                IModel              model              = project.Models[1];
                IIntelligentObjects intelligentObjects = model.Facility.IntelligentObjects;

                Source llegadaClientes = new Source(intelligentObjects, 0, 0);
                llegadaClientes.UpdateInterarrivalTime("Random.Uniform(1, 2.5)");
                llegadaClientes.UpdateName("LlegadaClientes");
                llegadaClientes.UpdateEntityType("Cliente");

                Server caja = new Server(intelligentObjects, 10, 0);
                caja.UpdateProcessingTime("Random.Uniform(2/3, 11/6)");
                caja.UpdateName("Caja");
                Path pathLlegadaCaja = new Path(intelligentObjects, llegadaClientes.GetOutput(), caja.GetInput());
                pathLlegadaCaja.UpdateDrawToScale("False");
                pathLlegadaCaja.UpdateLogicalLength("20");

                Source llegadaBotellas = new Source(intelligentObjects, 10, 15);
                llegadaBotellas.UpdateName("AlmacenBotella");
                llegadaBotellas.UpdateEntityType("Botella");
                llegadaBotellas.UpdateArrivalMode("On Event");

                INodeObject entradaCaja = (INodeObject)intelligentObjects["EntradaCaja"];
                new Path(intelligentObjects, entradaCaja, llegadaBotellas.GetOutput());

                Combiner entrega = new Combiner(intelligentObjects, 20, 0);
                entrega.UpdateName("Entrega");
                entrega.GetOutput().Properties["OutboundLinkRule"].Value = "By Link Weight";
                Path cajaEntrega = new Path(intelligentObjects, caja.GetOutput(), entrega.GetParentInput());
                cajaEntrega.UpdateDrawToScale("False");
                cajaEntrega.UpdateLogicalLength("4");

                Sink     sink       = new Sink(intelligentObjects, 60, -5);
                TimePath pathSalida = new TimePath(intelligentObjects, entrega.GetOutput(), sink.GetInput());
                pathSalida.UpdateSelectionWeight("0.48");
                pathSalida.UpdateTravelTime("0.3");
                TransferNode transferNode = new TransferNode(intelligentObjects, 25, -10);
                transferNode.UpdateName("IrSalida");
                new Path(intelligentObjects, transferNode.GetInput(), sink.GetInput());

                CreateServer(
                    intelligentObjects, 50, 40, "0.12",
                    "Random.Triangular(4, 8, 12)", "5",
                    null, "3", "Barra", entrega.GetOutput(), sink.GetInput()
                    );
                int i = 1;
                int x = 50;
                int y = 35;
                for (; i < 15; i++)
                {
                    CreateServer(
                        intelligentObjects, x, y, "0.025",
                        "Random.Triangular(12, 20, 25)",
                        i <= 8 ? "4" : "3", i <= 8 ? "10/60" : "12/60",
                        null, "Mesa_" + i, entrega.GetOutput(), sink.GetInput()
                        );
                    y -= 5;
                }
                SimioProjectFactory.SaveProject(project, finalModelPath, out warnings);
                System.IO.File.WriteAllLines(WARNINGS_FILE_PATH, warnings);
            } catch (Exception e)
            {
                System.IO.File.WriteAllText(WARNINGS_FILE_PATH, e.Message);
            }
        }
Esempio n. 24
0
        public void crearModelo()
        {
            pintarBasicNode();
            pintarServer();
            actualizarObjetos();
            dibujarRuta();
            modificarRegiones();



            //Source de la Fuerza Armada
            crearSource("Source", "FuerzaArmada", -8.75, -81);
            cambioNombre("Source1", "FuerzaArmada");
            crearModelEntyty("ModelEntity", "avion", -4.356, -78.731);
            cambioNombre("ModelEntity1", "avion");
            modificarPropiedades("FuerzaArmada", "InterarrivalTime", "15");
            modificarPropiedades("FuerzaArmada", "MaximumArrivals", "15");
            modificarPropiedades("FuerzaArmada", "EntityType", "avion");


            crearSource("Source", "IN_AERO_La_Aurora", 0, 10);
            cambioNombre("Source1", "IN_AERO_La_Aurora");
            crearModelEntyty("ModelEntity", "turista", 0, 15);
            cambioNombre("ModelEntity1", "turista");
            modificarPropiedades("IN_AERO_La_Aurora", "InterarrivalTime", "Random.Exponential(35)");
            modificarPropiedades("IN_AERO_La_Aurora", "EntitiesPerArrival", "70");
            modificarPropiedades("IN_AERO_La_Aurora", "EntityType", "turista");


            crearSource("Source", "InMetropolitana", 0, 5);
            cambioNombre("Source1", "InMetropolitana");
            modificarPropiedades("InMetropolitana", "InterarrivalTime", "Random.Poisson(2)");
            modificarPropiedades("InMetropolitana", "EntityType", "turista");


            crearBasicNode("BasicNode", "BM", 0, 8);
            cambioNombre("BasicNode1", "BM");

            crearSink("Sink", "OutMetropolitana", -3, 8);
            cambioNombre("Sink1", "OutMetropolitana");



            crearSource("Source", "IN_AERO_Mundo_Maya", 10, -60);
            cambioNombre("Source1", "IN_AERO_Mundo_Maya");
            modificarPropiedades("IN_AERO_Mundo_Maya", "InterarrivalTime", "Random.Exponential(35)");
            modificarPropiedades("IN_AERO_Mundo_Maya", "EntitiesPerArrival", "40");
            modificarPropiedades("IN_AERO_Mundo_Maya", "EntityType", "turista");

            crearSource("Source", "InPeten", 10, -55);
            cambioNombre("Source1", "InPeten");
            modificarPropiedades("InPeten", "InterarrivalTime", "Random.Poisson(4)");
            modificarPropiedades("InPeten", "EntityType", "turista");


            crearSource("Source", "IN_AERO_Quetzal", -40, 20);
            cambioNombre("Source1", "IN_AERO_Quetzal");
            modificarPropiedades("IN_AERO_Quetzal", "InterarrivalTime", "Random.Exponential(35)");
            modificarPropiedades("IN_AERO_Quetzal", "EntitiesPerArrival", "30");
            modificarPropiedades("IN_AERO_Quetzal", "EntityType", "turista");

            crearSource("Source", "InSurOccidente", -40, 15);
            cambioNombre("Source1", "InSurOccidente");
            modificarPropiedades("InSurOccidente", "InterarrivalTime", "Random.Poisson(4)");
            modificarPropiedades("InSurOccidente", "EntityType", "turista");

            crearSource("Source", "InSurOriente", 15, 25);
            cambioNombre("Source1", "InSurOriente");
            modificarPropiedades("InSurOriente", "InterarrivalTime", "Random.Poisson(10)");
            modificarPropiedades("InSurOriente", "EntityType", "turista");

            crearSource("Source", "InNorOriente", 30, -5);
            cambioNombre("Source1", "InNorOriente");
            modificarPropiedades("InNorOriente", "InterarrivalTime", "Random.Poisson(6)");
            modificarPropiedades("InNorOriente", "EntityType", "turista");

            crearSource("Source", "InNorte", 5, -15);
            cambioNombre("Source1", "InNorte");
            modificarPropiedades("InNorte", "InterarrivalTime", "Random.Poisson(8)");
            modificarPropiedades("InNorte", "EntityType", "turista");

            crearSource("Source", "InCentral", -15, 25);
            cambioNombre("Source1", "InCentral");
            modificarPropiedades("InCentral", "InterarrivalTime", "Random.Poisson(3)");
            modificarPropiedades("InCentral", "EntityType", "turista");

            crearSource("Source", "InNorOccidente", -50, -20);
            cambioNombre("Source1", "InNorOccidente");
            modificarPropiedades("InNorOccidente", "InterarrivalTime", "Random.Poisson(12)");
            modificarPropiedades("InNorOccidente", "EntityType", "turista");


            crearLink("Conveyor", getNodoServer("FuerzaArmada", 0), getNodo("Pto6", 1));
            crearLink("Path", getNodoServer("IN_AERO_La_Aurora", 0), getNodo("BM", 1));
            cambioNombre("Path1", "InAurora");
            crearLink("Path", getNodo("BM", 1), getNodoServer("Metropolitana", 0));
            modificarPropiedades("Path1", "SelectionWeight", "0.5");

            noPath++;


            rutasRegiones();
            // Crea el modelo final
            llenarCarnet.crearModeloCarnet();
            SimioProjectFactory.SaveProject(practica4, rutaFinal, out warnings);
        }
        /// <summary>
        /// Run an experiment. The experiment is Reset prior to run.
        /// If the saveProjectPath is present and exists, then the project will be
        /// saved to that location. If there are Save warnings, then true is still
        /// returned, but the warnings are in explanation.
        /// </summary>
        /// <param name="projectPathAndFile"></param>
        /// <param name="experimentName"></param>
        /// <param name="saveModelAfterRun"></param>
        /// <param name="explanation"></param>
        /// <returns></returns>
        public static bool RunModelExperiment(ISimioProject project, string saveProjectPath,
                                              string modelName, string experimentName,
                                              out string explanation)
        {
            explanation = "";
            string marker = "Begin";

            try
            {
                marker = $"Loading Model named={modelName}";
                IModel model = LoadModel(project, modelName, out explanation);
                if (model == null)
                {
                    return(false);
                }


                marker = $"Loading Experiment named={experimentName}";
                IExperiment experiment = LoadExperiment(model, experimentName, out explanation);
                if (experiment == null)
                {
                    return(false);
                }

                // Create some methods to handle experiment events. Events are:
                // RunStarted, RunProgessChanged, RunCompleted
                // ScenarioStarted, ScenarioEnded
                // ReplicationStarted, ReplicationEnded
                //


                // Here the 'e' is RunStartedEventArgs
                experiment.RunStarted += (s, e) =>
                {
                    LogIt($"Info: Event=> Experiment={experiment.Name} Run Started. ");
                };

                // Here the 'e' is ReplicationEndedEventArgs
                experiment.ReplicationEnded += (s, e) =>
                {
                    LogIt($"Info: Event=> Ended Replication={e.ReplicationNumber} of Scenario={e.Scenario.Name}.");
                };

                // Here the 'e' is ScenarioStartedEventArgs
                experiment.ScenarioStarted += (s, e) =>
                {
                    LogIt($"Info: Event=> Scenario={e.Scenario.Name} Started.");
                };
                experiment.ScenarioEnded += (s, e) =>
                {
                    LogIt($"Info: Event=> Scenario={e.Scenario.Name} Ended.");
                };


                // Here the 'e' is RunCompletedEventArgs
                experiment.RunCompleted += (s, e) =>
                {
                    LogIt($"Info: Event=> Experiment={experiment.Name} Run Complete. ");
                    foreach (ITable table in model.Tables)
                    {
                        table.ExportForInteractive();
                    }
                };

                // Now do the run.
                experiment.Reset();
                experiment.Run();
                //experiment.RunAsync(); // Another option

                // Let's look at some results
                var response = experiment.Responses;

                if (File.Exists(saveProjectPath))
                {
                    marker = $"Save Project After Experiment Run to={saveProjectPath}";
                    LogIt($"Info: {marker}");

                    string[] warnings;
                    SimioProjectFactory.SaveProject(project, saveProjectPath, out warnings);
                    explanation = "";
                    int nn = 0;
                    foreach (string warning in warnings)
                    {
                        explanation += $"Save Warnings({warnings.Length}): Warning{++nn}:{warning}";
                        LogIt($"Warning: {warning}");
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                throw new ApplicationException($"Marker={marker} Err={ex.Message}");
            }
        }
Esempio n. 26
0
 public void saveFile()
 {
     SimioProjectFactory.SaveProject(SimioProject, this.outputFile, out warnings);
 }
Esempio n. 27
0
 public void guardarNuevoProyecto()
 {
     SimioProjectFactory.SaveProject(modSimioNuevo, nombrePryctNuevo, out warnings);
 }
Esempio n. 28
0
        /// <summary>
        /// Run an experiment
        /// </summary>
        /// <param name="projectPathAndFile"></param>
        /// <param name="experimentName"></param>
        /// <param name="saveModelAfterRun"></param>
        /// <param name="explanation"></param>
        /// <returns></returns>
        public static bool RunExperiment(string projectFullPath, string modelName, string experimentName, bool saveModelAfterRun, out string explanation)
        {
            explanation = "";
            string marker = "Begin";

            try
            {
                // Set an extensions path to where we can locate User Extensions, etc.
                string extensionsPath = System.AppDomain.CurrentDomain.BaseDirectory;
                marker = $"Setting Extensions Path to={extensionsPath}";
                LogIt($"Info: {marker}");
                SimioProjectFactory.SetExtensionsPath(extensionsPath);

                marker = $"Loading Project from={projectFullPath}";
                ISimioProject project = LoadProject(projectFullPath, out explanation);
                if (project == null)
                {
                    return(false);
                }

                marker = $"Loading Model named={modelName}";
                IModel model = LoadModel(project, modelName, out explanation);
                if (model == null)
                {
                    return(false);
                }

                marker = $"Loading Experiment named={experimentName}";
                IExperiment experiment = LoadExperiment(model, experimentName, out explanation);
                if (experiment == null)
                {
                    return(false);
                }

                // Create some methods to handle experiment events
                experiment.ReplicationEnded += (s, e) =>
                {
                    LogIt($"Info: Event=> Ended Replication={e.ReplicationNumber} of Scenario={e.Scenario.Name}.");
                };

                experiment.ScenarioEnded += (s, e) =>
                {
                    LogIt($"Info: Event=> Scenario={e.Scenario.Name} Ended.");
                };

                experiment.RunCompleted += (s, e) =>
                {
                    LogIt($"Info: Event=> Experiment={experiment.Name} Run Complete. ");
                };

                // Now do the run.
                experiment.Reset();
                experiment.Run();
                //experiment.RunAsync(); // Another option

                if (saveModelAfterRun)
                {
                    marker = $"Save Project After Experiment Run to= (SimioProjectFactory.SaveProject)";
                    LogIt($"Info: {marker}");

                    string[] warnings;
                    SimioProjectFactory.SaveProject(project, projectFullPath, out warnings);
                    foreach (string warning in warnings)
                    {
                        LogIt($"Warning: {warning}");
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                throw new ApplicationException($"Marker={marker} Err={ex}");
            }
        }
Esempio n. 29
0
 public void createModel()
 {
     CreateMap();
     SimioProjectFactory.SaveProject(proyectoApi, rutafinal, out warnings);
 }