Ejemplo n.º 1
0
        /// <summary>
        /// Load the project file and return a SimioProject
        /// </summary>
        /// <param name="projectFullPath"></param>
        private static ISimioProject LoadProject(string projectFullPath, out string explanation)
        {
            explanation = "";
            string marker = "Begin.";

            string[] warnings;

            try
            {
                // If File Not Exist, Throw Exeption
                if (File.Exists(projectFullPath) == false)
                {
                    explanation = $"Project File={projectFullPath} not found.";
                    return(null);
                }

                // Open project file.
                marker = "Loading Model";
                LogIt($"Info: {marker}");
                ISimioProject simioProject = SimioProjectFactory.LoadProject(projectFullPath, out warnings);
                foreach (string warning in warnings)
                {
                    LogIt($"Warning: {warning}");
                }
                return(simioProject);
            }
            catch (Exception ex)
            {
                throw new ApplicationException($"Cannot load={projectFullPath} Err={ex}");
            }
        }
Ejemplo n.º 2
0
 public ApiSimio(String rbase, String rfinal)
 {
     rutabase           = rbase;
     rutafinal          = rfinal;
     proyectoApi        = SimioProjectFactory.LoadProject(rutabase, out warnings);
     model              = proyectoApi.Models[1];
     intelligentObjects = model.Facility.IntelligentObjects;
 }
Ejemplo n.º 3
0
        public Form1()
        {
            APIProject       = SimioProjectFactory.LoadProject(rutabase, out warnings);
            modelo           = APIProject.Models[1];
            InteligentObject = modelo.Facility.IntelligentObjects;

            InitializeComponent();
        }
Ejemplo n.º 4
0
        public Modelo(string nombreMdlBase, string nombreMdlFinal)
        {
            this.nombrePryctBase  = nombreMdlBase;
            this.nombrePryctNuevo = nombreMdlFinal;

            modSimioNuevo = SimioProjectFactory.LoadProject(nombrePryctBase, out warnings);
            Base.model    = modSimioNuevo.Models[(int)Tipo.Model];
        }
Ejemplo n.º 5
0
        public Form1()
        {
            proyectoApi        = SimioProjectFactory.LoadProject(rutabase, out warnings);
            modelo             = proyectoApi.Models[1];
            intelligentObjects = modelo.Facility.IntelligentObjects;

            InitializeComponent();
        }
Ejemplo n.º 6
0
 public Objetos()
 {
     //creamos el constructor de la clase en el cual se creara el proyecto y
     // vamos a utilizar el modelo base para poder crear los elementos necesarios
     // para la consturccion de los datos correspondientes.
     proyectoApi        = SimioProjectFactory.LoadProject(rutabase, out warnings);
     model              = proyectoApi.Models[1];
     intelligentObjects = model.Facility.IntelligentObjects;
 }
Ejemplo n.º 7
0
 public SimioFile()
 {
     if (File.Exists(this.outputFile))
     {
         File.Delete(this.outputFile);
     }
     SimioProject = SimioProjectFactory.LoadProject(inputFiele, out warnings);
     this.model   = SimioProject.Models[1];
 }
Ejemplo n.º 8
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
     {
     }
 }
Ejemplo n.º 9
0
        private void Form1_Load(object sender, EventArgs e)
        {
            if (File.Exists(_rutaSalida))
            {
                File.Delete(_rutaSalida);
            }
            _simioproyecto = SimioProjectFactory.LoadProject(_rutaBase, out warnings);
            _modelo        = _simioproyecto.Models[1];


            //crear();


            //guardarModeloSalida();
        }
Ejemplo n.º 10
0
        public void SetProject(string project, string model, string experiment)
        {
            // Set extension folder path
            //SimioProjectFactory.SetExtensionsPath(Directory.GetCurrentDirectory().ToString());

            // Open project
            string[] warnings;
            currentProject = SimioProjectFactory.LoadProject(project, out warnings);
            if (model != null || model != "")
            {
                SetModel(model);
                SetExperiment(experiment);
                //return currentProject;
            }
            //return null;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Initialize, which means setting the ExtensionsPath and loading the project.
        /// If there are warnings, they are placed in LoadWarningsList.
        /// </summary>
        /// <param name="projectFullPath"></param>
        /// <param name="explanation"></param>
        /// <returns></returns>
        public bool LoadProject(string projectFullPath, out string explanation)
        {
            explanation = "";
            string marker = "Checking extension and project paths.";

            if (ExtensionsPath == null)
            {
                explanation = $"Cannot LoadProject with null ExtensionsPath";
                return(false);
            }

            try
            {
                // If File Not Exist, Throw Exception
                if (File.Exists(projectFullPath) == false)
                {
                    explanation = $"Project File={projectFullPath} not found.";
                    return(false);
                }

                ProjectPath = projectFullPath;

                marker = $"Setting extensions path={ExtensionsPath}";
                SimioProjectFactory.SetExtensionsPath(ExtensionsPath); // No harm in doing it again.

                // Open project file.
                marker         = $"Loading Project={projectFullPath}.";
                CurrentProject = SimioProjectFactory.LoadProject(projectFullPath, out string[] warnings);

                ProjectLoadErrorList = null;
                if (warnings.Length > 0)
                {
                    ProjectLoadErrorList = new List <string>();
                    foreach (string warning in warnings)
                    {
                        ProjectLoadErrorList.Add(warning);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                explanation = $"Failed to LoadProject={projectFullPath} Err={ex.Message}";
                return(false);
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Set the extensions path and then Load the project file and return a SimioProject.
        /// </summary>
        /// <param name="projectFullPath"></param>
        public static ISimioProject LoadProject(string extensionsPath, string projectFullPath, out string explanation)
        {
            explanation = "";
            string marker = "Begin.";

            string[] warnings;

            try
            {
                // If File Not Exist, Throw Exeption
                if (File.Exists(projectFullPath) == false)
                {
                    explanation = $"Project File={projectFullPath} not found.";
                    return(null);
                }

                if (Directory.Exists(extensionsPath) == false)
                {
                    explanation = $"ExtensionsPath={extensionsPath} not found.";
                    return(null);
                }

                marker = $"Setting extensions path={extensionsPath}";
                LogIt($"Info: {marker}");
                SimioProjectFactory.SetExtensionsPath(extensionsPath);

                // Open project file.
                marker = $"Loading Project={projectFullPath}.";
                LogIt($"Info: {marker}");
                ISimioProject simioProject = SimioProjectFactory.LoadProject(projectFullPath, out warnings);

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

                return(simioProject);
            }
            catch (Exception ex)
            {
                throw new ApplicationException($"Cannot load={projectFullPath} Err={ex.Message}");
            }
        }
Ejemplo n.º 13
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);
     }
 }
Ejemplo n.º 14
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);
     }
 }
Ejemplo n.º 15
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
     {
     }
 }
Ejemplo 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.");
            }
        }
Ejemplo 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);
            }
        }
Ejemplo n.º 18
0
 public llenarCarnet()
 {
     apiCarnet          = SimioProjectFactory.LoadProject(ruta, out warnings);
     model              = apiCarnet.Models[1];
     intelligentObjects = model.Facility.IntelligentObjects;
 }
Ejemplo n.º 19
0
 public objetos()
 {
     practica4          = SimioProjectFactory.LoadProject(ruta, out warnings);
     model              = practica4.Models[1];
     intelligentObjects = model.Facility.IntelligentObjects;
 }
Ejemplo n.º 20
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}");
            }
        }
Ejemplo n.º 21
0
 public generador_carnets()
 {
     proyectoApi        = SimioProjectFactory.LoadProject(rutabase, out warnings);
     model              = proyectoApi.Models[1];
     intelligentObjects = model.Facility.IntelligentObjects;
 }
Ejemplo n.º 22
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);
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Run an experiment and save.
        /// </summary>
        /// <param name="extensionsPath"></param>
        /// <param name="projectPath"></param>
        /// <param name="argList"></param>
        /// <param name="explanation"></param>
        /// <returns></returns>
        public static bool RunProjectExperiment(string extensionsPath, string projectPath, List <RequestArgument> argList,
                                                out string explanation)
        {
            explanation = "";

            string marker = "Begin";

            try
            {
                if (!File.Exists(projectPath))
                {
                    explanation = $"No such Project={projectPath}";
                    return(false);
                }

                string projectFolder   = Path.GetDirectoryName(projectPath);
                string projectFilename = Path.GetFileName(projectPath);


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

                string saveFilename = GetArgumentAsString(argList, "saveFilename", projectFilename, out explanation);
                string savePath     = Path.Combine(saveFolder, saveFilename);

                string modelName      = GetArgumentAsString(argList, "model", "model", out explanation);
                string experimentName = GetArgumentAsString(argList, "experiment", "experiment1", out explanation);

                marker = $"Loading Project from={projectPath}";
                string[] warnings;

                var _simioProject = SimioProjectFactory.LoadProject(projectPath, out warnings);
                if (warnings.Length > 0)
                {
                    explanation = $"Cannot load Project={projectPath} as there were {warnings.Length} warnings";
                    return(false);
                }

                marker = $"Access the model={modelName} and Experiment={experimentName}";
                var model = _simioProject.Models[modelName];
                if (model == null)
                {
                    explanation = "Model Not Found In Project";
                    return(false);
                }
                else
                {
                    if (model.Experiments == null)
                    {
                        explanation = $"Model's Experiments collection is null.";
                        return(false);
                    }

                    // Start Experiment
                    Console.WriteLine("Starting Experiment");

                    if (!SimEngineHelpers.RunModelExperiment(extensionsPath, projectPath, savePath,
                                                             modelName, experimentName,
                                                             out explanation))
                    {
                        return(false);
                    }
                    else
                    {
                        marker = $"Info: Model={modelName} Experiment={experimentName} performed the actions successfully. Check the logs for more information.";
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                explanation = $"Marker={marker} Project={projectPath}. Err={ex.Message}";
                return(false);
            }
        }
Ejemplo n.º 24
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);
            }
        }