Exemplo n.º 1
0
 internal Application(StoredApplicationDescription applicationDescription, string resourceName)
     : this(applicationDescription.AppId)
 {
     foreach (var model in applicationDescription.Models)
     {
         AddModel(model.ModelId);
         var machineParams = model.MachinesSettings.SingleOrDefault(m => m.MachineId == resourceName);
         var resultParams = Enumerable.Empty<KeyValuePair<string, string>>().ToDictionary(p => p.Key, p => p.Value);
         if (machineParams != null)
         {
             resultParams = machineParams.Parameters.ToDictionary(p => p.ParameterId, p => p.Value);
         }
         resultParams = resultParams.Union(model.Parameters.Where(p => !resultParams.ContainsKey(p.ParameterId)).ToDictionary(p => p.ParameterId, p => p.Value)).ToDictionary(p => p.Key, p => p.Value);
         GetModel(model.ModelId).SetParametersValues(resultParams);
     }
 }
Exemplo n.º 2
0
 internal Application(StoredApplicationDescription applicationDescription, string resourceName)
     : this(applicationDescription.AppId)
 {
     foreach (var model in applicationDescription.Models)
     {
         AddModel(model.ModelId);
         var machineParams = model.MachinesSettings.SingleOrDefault(m => m.MachineId == resourceName);
         var resultParams  = Enumerable.Empty <KeyValuePair <string, string> >().ToDictionary(p => p.Key, p => p.Value);
         if (machineParams != null)
         {
             resultParams = machineParams.Parameters.ToDictionary(p => p.ParameterId, p => p.Value);
         }
         resultParams = resultParams.Union(model.Parameters.Where(p => !resultParams.ContainsKey(p.ParameterId)).ToDictionary(p => p.ParameterId, p => p.Value)).ToDictionary(p => p.Key, p => p.Value);
         GetModel(model.ModelId).SetParametersValues(resultParams);
     }
 }
Exemplo n.º 3
0
        public static void UpdateDescriptions()
        {
            var descr = new StoredApplicationDescription();

            descr.AppId                                       = "SWAN";
            descr.Models                                      = new StoredModelDescription[1];
            descr.Models[0]                                   = new StoredModelDescription();
            descr.Models[0].ModelId                           = "SWAN_AMDAHL";
            descr.Models[0].MachinesSettings                  = new MachineSpecificModelSettings[3];
            descr.Models[0].MachinesSettings[0]               = new MachineSpecificModelSettings();
            descr.Models[0].MachinesSettings[0].MachineId     = "machine1";
            descr.Models[0].MachinesSettings[0].Parameters    = new StoredModelParameterDescription[4];
            descr.Models[0].MachinesSettings[0].Parameters[0] = new StoredModelParameterDescription()
            {
                ParameterId = "ALPHA", Value = "0.224"
            };
            descr.Models[0].MachinesSettings[0].Parameters[1] = new StoredModelParameterDescription()
            {
                ParameterId = "GAMMA", Value = "0.9"
            };
            descr.Models[0].MachinesSettings[0].Parameters[2] = new StoredModelParameterDescription()
            {
                ParameterId = "P", Value = "2"
            };
            descr.Models[0].MachinesSettings[0].Parameters[3] = new StoredModelParameterDescription()
            {
                ParameterId = "T0", Value = "1445"
            };
            descr.Models[0].MachinesSettings[1]               = new MachineSpecificModelSettings();
            descr.Models[0].MachinesSettings[1].MachineId     = "machine2";
            descr.Models[0].MachinesSettings[1].Parameters    = new StoredModelParameterDescription[4];
            descr.Models[0].MachinesSettings[1].Parameters[0] = new StoredModelParameterDescription()
            {
                ParameterId = "ALPHA", Value = "0.0001"
            };
            descr.Models[0].MachinesSettings[1].Parameters[1] = new StoredModelParameterDescription()
            {
                ParameterId = "GAMMA", Value = "0.593"
            };
            descr.Models[0].MachinesSettings[1].Parameters[2] = new StoredModelParameterDescription()
            {
                ParameterId = "P", Value = "6"
            };
            descr.Models[0].MachinesSettings[1].Parameters[3] = new StoredModelParameterDescription()
            {
                ParameterId = "T0", Value = "816"
            };
            descr.Models[0].MachinesSettings[2]               = new MachineSpecificModelSettings();
            descr.Models[0].MachinesSettings[2].MachineId     = "machine3";
            descr.Models[0].MachinesSettings[2].Parameters    = new StoredModelParameterDescription[4];
            descr.Models[0].MachinesSettings[2].Parameters[0] = new StoredModelParameterDescription()
            {
                ParameterId = "ALPHA", Value = "0.0007"
            };
            descr.Models[0].MachinesSettings[2].Parameters[1] = new StoredModelParameterDescription()
            {
                ParameterId = "GAMMA", Value = "0.602"
            };
            descr.Models[0].MachinesSettings[2].Parameters[2] = new StoredModelParameterDescription()
            {
                ParameterId = "P", Value = "8"
            };
            descr.Models[0].MachinesSettings[2].Parameters[3] = new StoredModelParameterDescription()
            {
                ParameterId = "T0", Value = "703"
            };
            descr.Models[0].Parameters    = new StoredModelParameterDescription[4];
            descr.Models[0].Parameters[0] = new StoredModelParameterDescription()
            {
                ParameterId = "ALPHA", Value = "0.224"
            };
            descr.Models[0].Parameters[1] = new StoredModelParameterDescription()
            {
                ParameterId = "GAMMA", Value = "0.9"
            };
            descr.Models[0].Parameters[2] = new StoredModelParameterDescription()
            {
                ParameterId = "P", Value = "2"
            };
            descr.Models[0].Parameters[3] = new StoredModelParameterDescription()
            {
                ParameterId = "T0", Value = "1445"
            };

            AppDescriptions[descr.AppId] = descr;

            descr                            = new StoredApplicationDescription();
            descr.AppId                      = "BSM";
            descr.Models                     = new StoredModelDescription[1];
            descr.Models[0]                  = new StoredModelDescription();
            descr.Models[0].ModelId          = "BSM";
            descr.Models[0].MachinesSettings = new MachineSpecificModelSettings[0];
            descr.Models[0].Parameters       = new StoredModelParameterDescription[0];

            /*descr.Models[0].MachinesSettings[0] = new MachineSpecificModelSettings();
             * descr.Models[0].MachinesSettings[0].MachineId = "machine1";
             * descr.Models[0].MachinesSettings[0].Parameters = new StoredModelParameterDescription[2];
             * descr.Models[0].MachinesSettings[0].Parameters[0] = new StoredModelParameterDescription() { ParameterId = "NO_ASM", Value = "825" };
             * descr.Models[0].MachinesSettings[0].Parameters[1] = new StoredModelParameterDescription() { ParameterId = "WITH_ASM", Value = "856" };
             * descr.Models[0].MachinesSettings[1] = new MachineSpecificModelSettings();
             * descr.Models[0].MachinesSettings[1].MachineId = "machine2";
             * descr.Models[0].MachinesSettings[1].Parameters = new StoredModelParameterDescription[2];
             * descr.Models[0].MachinesSettings[1].Parameters[0] = new StoredModelParameterDescription() { ParameterId = "NO_ASM", Value = "668" };
             * descr.Models[0].MachinesSettings[1].Parameters[1] = new StoredModelParameterDescription() { ParameterId = "WITH_ASM", Value = "669" };
             * descr.Models[0].MachinesSettings[2] = new MachineSpecificModelSettings();
             * descr.Models[0].MachinesSettings[2].MachineId = "machine3";
             * descr.Models[0].MachinesSettings[2].Parameters = new StoredModelParameterDescription[2];
             * descr.Models[0].MachinesSettings[2].Parameters[0] = new StoredModelParameterDescription() { ParameterId = "NO_ASM", Value = "525" };
             * descr.Models[0].MachinesSettings[2].Parameters[1] = new StoredModelParameterDescription() { ParameterId = "WITH_ASM", Value = "532" };
             * descr.Models[0].Parameters[0] = new StoredModelParameterDescription() { ParameterId = "NO_ASM", Value = "825" };
             * descr.Models[0].Parameters[1] = new StoredModelParameterDescription() { ParameterId = "WITH_ASM", Value = "856" };*/

            AppDescriptions[descr.AppId] = descr;

            var resCount = 10;

            descr                            = new StoredApplicationDescription();
            descr.AppId                      = "SHIPX";
            descr.Models                     = new StoredModelDescription[1];
            descr.Models[0]                  = new StoredModelDescription();
            descr.Models[0].ModelId          = "SHIPX";
            descr.Models[0].MachinesSettings = new MachineSpecificModelSettings[resCount];
            var r = new Random(System.DateTime.Now.Millisecond);

            for (var i = 0; i < resCount; i++)
            {
                descr.Models[0].MachinesSettings[i]               = new MachineSpecificModelSettings();
                descr.Models[0].MachinesSettings[i].MachineId     = String.Format("machine{0}", i + 1);
                descr.Models[0].MachinesSettings[i].Parameters    = new StoredModelParameterDescription[1];
                descr.Models[0].MachinesSettings[i].Parameters[0] = new StoredModelParameterDescription()
                {
                    ParameterId = "SIM_COUNT", Value = r.Next(20, 1200).ToString()
                };
            }

            descr.Models[0].Parameters    = new StoredModelParameterDescription[1];
            descr.Models[0].Parameters[0] = new StoredModelParameterDescription()
            {
                ParameterId = "SIM_COUNT", Value = r.Next(20, 1200).ToString()
            };

            AppDescriptions[descr.AppId] = descr;

            descr                                             = new StoredApplicationDescription();
            descr.AppId                                       = "LPE";
            descr.Models                                      = new StoredModelDescription[1];
            descr.Models[0]                                   = new StoredModelDescription();
            descr.Models[0].ModelId                           = "LPE";
            descr.Models[0].MachinesSettings                  = new MachineSpecificModelSettings[3];
            descr.Models[0].MachinesSettings[0]               = new MachineSpecificModelSettings();
            descr.Models[0].MachinesSettings[0].MachineId     = "machine1";
            descr.Models[0].MachinesSettings[0].Parameters    = new StoredModelParameterDescription[1];
            descr.Models[0].MachinesSettings[0].Parameters[0] = new StoredModelParameterDescription()
            {
                ParameterId = "TIME", Value = "6"
            };
            descr.Models[0].MachinesSettings[1]               = new MachineSpecificModelSettings();
            descr.Models[0].MachinesSettings[1].MachineId     = "machine2";
            descr.Models[0].MachinesSettings[1].Parameters    = new StoredModelParameterDescription[1];
            descr.Models[0].MachinesSettings[1].Parameters[0] = new StoredModelParameterDescription()
            {
                ParameterId = "TIME", Value = "2"
            };
            descr.Models[0].MachinesSettings[2]               = new MachineSpecificModelSettings();
            descr.Models[0].MachinesSettings[2].MachineId     = "machine3";
            descr.Models[0].MachinesSettings[2].Parameters    = new StoredModelParameterDescription[1];
            descr.Models[0].MachinesSettings[2].Parameters[0] = new StoredModelParameterDescription()
            {
                ParameterId = "TIME", Value = "2"
            };
            descr.Models[0].Parameters    = new StoredModelParameterDescription[1];
            descr.Models[0].Parameters[0] = new StoredModelParameterDescription()
            {
                ParameterId = "TIME", Value = "3"
            };

            AppDescriptions[descr.AppId] = descr;

            foreach (var d in AppDescriptions)
            {
                foreach (var m in d.Value.Models)
                {
                    if (m.MachinesSettings == null)
                    {
                        m.MachinesSettings = new MachineSpecificModelSettings[0];
                    }
                }
            }

            descr = new StoredApplicationDescription()
            {
                AppId  = Models.TestPModel.TESTP,
                Models = new StoredModelDescription[] {
                    new StoredModelDescription()
                    {
                        MachinesSettings = new MachineSpecificModelSettings[] {},
                        ModelId          = Models.TestPModel.TESTP,
                        Parameters       = new StoredModelParameterDescription[] {}
                    }
                }
            };

            AppDescriptions[descr.AppId] = descr;
        }
Exemplo n.º 4
0
        public static void UpdateDescriptions()
        {
            var descr = new StoredApplicationDescription();
            descr.AppId = "SWAN";
            descr.Models = new StoredModelDescription[1];
            descr.Models[0] = new StoredModelDescription();
            descr.Models[0].ModelId = "SWAN_AMDAHL";
            descr.Models[0].MachinesSettings = new MachineSpecificModelSettings[3];
            descr.Models[0].MachinesSettings[0] = new MachineSpecificModelSettings();
            descr.Models[0].MachinesSettings[0].MachineId = "machine1";
            descr.Models[0].MachinesSettings[0].Parameters = new StoredModelParameterDescription[4];
            descr.Models[0].MachinesSettings[0].Parameters[0] = new StoredModelParameterDescription() { ParameterId = "ALPHA", Value = "0.224" };
            descr.Models[0].MachinesSettings[0].Parameters[1] = new StoredModelParameterDescription() { ParameterId = "GAMMA", Value = "0.9" };
            descr.Models[0].MachinesSettings[0].Parameters[2] = new StoredModelParameterDescription() { ParameterId = "P", Value = "2" };
            descr.Models[0].MachinesSettings[0].Parameters[3] = new StoredModelParameterDescription() { ParameterId = "T0", Value = "1445" };
            descr.Models[0].MachinesSettings[1] = new MachineSpecificModelSettings();
            descr.Models[0].MachinesSettings[1].MachineId = "machine2";
            descr.Models[0].MachinesSettings[1].Parameters = new StoredModelParameterDescription[4];
            descr.Models[0].MachinesSettings[1].Parameters[0] = new StoredModelParameterDescription() { ParameterId = "ALPHA", Value = "0.0001" };
            descr.Models[0].MachinesSettings[1].Parameters[1] = new StoredModelParameterDescription() { ParameterId = "GAMMA", Value = "0.593" };
            descr.Models[0].MachinesSettings[1].Parameters[2] = new StoredModelParameterDescription() { ParameterId = "P", Value = "6" };
            descr.Models[0].MachinesSettings[1].Parameters[3] = new StoredModelParameterDescription() { ParameterId = "T0", Value = "816" };
            descr.Models[0].MachinesSettings[2] = new MachineSpecificModelSettings();
            descr.Models[0].MachinesSettings[2].MachineId = "machine3";
            descr.Models[0].MachinesSettings[2].Parameters = new StoredModelParameterDescription[4];
            descr.Models[0].MachinesSettings[2].Parameters[0] = new StoredModelParameterDescription() { ParameterId = "ALPHA", Value = "0.0007" };
            descr.Models[0].MachinesSettings[2].Parameters[1] = new StoredModelParameterDescription() { ParameterId = "GAMMA", Value = "0.602" };
            descr.Models[0].MachinesSettings[2].Parameters[2] = new StoredModelParameterDescription() { ParameterId = "P", Value = "8" };
            descr.Models[0].MachinesSettings[2].Parameters[3] = new StoredModelParameterDescription() { ParameterId = "T0", Value = "703" };
            descr.Models[0].Parameters = new StoredModelParameterDescription[4];
            descr.Models[0].Parameters[0] = new StoredModelParameterDescription() { ParameterId = "ALPHA", Value = "0.224" };
            descr.Models[0].Parameters[1] = new StoredModelParameterDescription() { ParameterId = "GAMMA", Value = "0.9" };
            descr.Models[0].Parameters[2] = new StoredModelParameterDescription() { ParameterId = "P", Value = "2" };
            descr.Models[0].Parameters[3] = new StoredModelParameterDescription() { ParameterId = "T0", Value = "1445" };

            AppDescriptions[descr.AppId] = descr;

            descr = new StoredApplicationDescription();
            descr.AppId = "BSM";
            descr.Models = new StoredModelDescription[1];
            descr.Models[0] = new StoredModelDescription();
            descr.Models[0].ModelId = "BSM";
            descr.Models[0].MachinesSettings = new MachineSpecificModelSettings[0];
            descr.Models[0].Parameters = new StoredModelParameterDescription[0];

            /*descr.Models[0].MachinesSettings[0] = new MachineSpecificModelSettings();
            descr.Models[0].MachinesSettings[0].MachineId = "machine1";
            descr.Models[0].MachinesSettings[0].Parameters = new StoredModelParameterDescription[2];
            descr.Models[0].MachinesSettings[0].Parameters[0] = new StoredModelParameterDescription() { ParameterId = "NO_ASM", Value = "825" };
            descr.Models[0].MachinesSettings[0].Parameters[1] = new StoredModelParameterDescription() { ParameterId = "WITH_ASM", Value = "856" };
            descr.Models[0].MachinesSettings[1] = new MachineSpecificModelSettings();
            descr.Models[0].MachinesSettings[1].MachineId = "machine2";
            descr.Models[0].MachinesSettings[1].Parameters = new StoredModelParameterDescription[2];
            descr.Models[0].MachinesSettings[1].Parameters[0] = new StoredModelParameterDescription() { ParameterId = "NO_ASM", Value = "668" };
            descr.Models[0].MachinesSettings[1].Parameters[1] = new StoredModelParameterDescription() { ParameterId = "WITH_ASM", Value = "669" };
            descr.Models[0].MachinesSettings[2] = new MachineSpecificModelSettings();
            descr.Models[0].MachinesSettings[2].MachineId = "machine3";
            descr.Models[0].MachinesSettings[2].Parameters = new StoredModelParameterDescription[2];
            descr.Models[0].MachinesSettings[2].Parameters[0] = new StoredModelParameterDescription() { ParameterId = "NO_ASM", Value = "525" };
            descr.Models[0].MachinesSettings[2].Parameters[1] = new StoredModelParameterDescription() { ParameterId = "WITH_ASM", Value = "532" };
            descr.Models[0].Parameters[0] = new StoredModelParameterDescription() { ParameterId = "NO_ASM", Value = "825" };
            descr.Models[0].Parameters[1] = new StoredModelParameterDescription() { ParameterId = "WITH_ASM", Value = "856" };*/

            AppDescriptions[descr.AppId] = descr;

            var resCount = 10;

            descr = new StoredApplicationDescription();
            descr.AppId = "SHIPX";
            descr.Models = new StoredModelDescription[1];
            descr.Models[0] = new StoredModelDescription();
            descr.Models[0].ModelId = "SHIPX";
            descr.Models[0].MachinesSettings = new MachineSpecificModelSettings[resCount];
            var r = new Random(System.DateTime.Now.Millisecond);

            for (var i = 0; i < resCount; i++)
            {
                descr.Models[0].MachinesSettings[i] = new MachineSpecificModelSettings();
                descr.Models[0].MachinesSettings[i].MachineId = String.Format("machine{0}", i + 1);
                descr.Models[0].MachinesSettings[i].Parameters = new StoredModelParameterDescription[1];
                descr.Models[0].MachinesSettings[i].Parameters[0] = new StoredModelParameterDescription() { ParameterId = "SIM_COUNT", Value = r.Next(20, 1200).ToString() };
            }

            descr.Models[0].Parameters = new StoredModelParameterDescription[1];
            descr.Models[0].Parameters[0] = new StoredModelParameterDescription() { ParameterId = "SIM_COUNT", Value = r.Next(20, 1200).ToString() };

            AppDescriptions[descr.AppId] = descr;

            descr = new StoredApplicationDescription();
            descr.AppId = "LPE";
            descr.Models = new StoredModelDescription[1];
            descr.Models[0] = new StoredModelDescription();
            descr.Models[0].ModelId = "LPE";
            descr.Models[0].MachinesSettings = new MachineSpecificModelSettings[3];
            descr.Models[0].MachinesSettings[0] = new MachineSpecificModelSettings();
            descr.Models[0].MachinesSettings[0].MachineId = "machine1";
            descr.Models[0].MachinesSettings[0].Parameters = new StoredModelParameterDescription[1];
            descr.Models[0].MachinesSettings[0].Parameters[0] = new StoredModelParameterDescription() { ParameterId = "TIME", Value = "6" };
            descr.Models[0].MachinesSettings[1] = new MachineSpecificModelSettings();
            descr.Models[0].MachinesSettings[1].MachineId = "machine2";
            descr.Models[0].MachinesSettings[1].Parameters = new StoredModelParameterDescription[1];
            descr.Models[0].MachinesSettings[1].Parameters[0] = new StoredModelParameterDescription() { ParameterId = "TIME", Value = "2" };
            descr.Models[0].MachinesSettings[2] = new MachineSpecificModelSettings();
            descr.Models[0].MachinesSettings[2].MachineId = "machine3";
            descr.Models[0].MachinesSettings[2].Parameters = new StoredModelParameterDescription[1];
            descr.Models[0].MachinesSettings[2].Parameters[0] = new StoredModelParameterDescription() { ParameterId = "TIME", Value = "2" };
            descr.Models[0].Parameters = new StoredModelParameterDescription[1];
            descr.Models[0].Parameters[0] = new StoredModelParameterDescription() { ParameterId = "TIME", Value = "3" };

            AppDescriptions[descr.AppId] = descr;

            foreach (var d in AppDescriptions)
            {
                foreach (var m in d.Value.Models)
                {
                    if (m.MachinesSettings == null)
                    {
                        m.MachinesSettings = new MachineSpecificModelSettings[0];
                    }
                }
            }

            descr = new StoredApplicationDescription()
            {
                AppId = Models.TestPModel.TESTP,
                Models = new StoredModelDescription[] {
                    new StoredModelDescription()
                    {
                        MachinesSettings = new MachineSpecificModelSettings[] {},
                        ModelId = Models.TestPModel.TESTP,
                        Parameters = new StoredModelParameterDescription[] {}
                    }
                }
            };

            AppDescriptions[descr.AppId] = descr;
        }