public void CreatePsoRastriginSampleTest()
        {
            var    pso  = CreatePsoRastriginSample();
            string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(pso, path);
        }
        public void CreateGpSymbolicClassificationSampleTest()
        {
            var    ga   = CreateGpSymbolicClassificationSample();
            string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(ga, path);
        }
예제 #3
0
        public void CreateScatterSearchVRPSampleTest()
        {
            var    ss   = CreateScatterSearchVRPSample();
            string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(ss, path);
        }
예제 #4
0
        public void CreateOSGARastriginScriptTest()
        {
            var    script = CreateOSGARastriginScript();
            string path   = Path.Combine(ScriptingUtils.ScriptsDirectory, ScriptFileName + ScriptingUtils.ScriptFileExtension);

            XmlGenerator.Serialize(script, path);
        }
예제 #5
0
        public void CreateGPSymbolicRegressionSampleWithOSTest()
        {
            var    osga = CreateGpSymbolicRegressionSample();
            string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(osga, path);
        }
예제 #6
0
        public void CreateAlpsGaSymRegSampleTest()
        {
            var    alpsGa = CreateAlpsGaSymRegSample();
            string path   = Path.Combine(SamplesUtils.SamplesDirectory, SymRegSampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(alpsGa, path);
        }
        public void CreateGaussianProcessRegressionSampleTest()
        {
            var    gpr  = CreateGaussianProcessRegressionSample();
            string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(gpr, path);
        }
예제 #8
0
        public void CreateCFGGPSampleTest()
        {
            var    ga   = CreateCFGGPSample();
            string path = Path.Combine(SampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(ga, path);
        }
예제 #9
0
        public void CreateGeSymbolicRegressionSampleTest()
        {
            var    geSymbReg = CreateGeSymbolicRegressionSample();
            string path      = Path.Combine(SamplesUtils.SamplesDirectory, GeSymbolicRegressionSampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(geSymbReg, path);
        }
예제 #10
0
        public void CreateGridSearchSVMClassificationScriptTest()
        {
            var    script = CreateGridSearchSVMClassificationScript();
            string path   = Path.Combine(ScriptingUtils.ScriptsDirectory, ScriptFileName + ScriptingUtils.ScriptFileExtension);

            XmlGenerator.Serialize(script, path);
        }
예제 #11
0
        public void CreateGeArtificialAntSampleTest()
        {
            var    geaa = CreateGeArtificialAntSample();
            string path = Path.Combine(SamplesUtils.SamplesDirectory, GeArtificialAntSampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(geaa, path);
        }
        public void CreateSimulatedAnnealingRastriginSampleTest()
        {
            var    sa   = CreateSimulatedAnnealingRastriginSample();
            string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(sa, path);
        }
        public void CreateOSESGriewankSampleTest()
        {
            var    es   = CreateOSESGriewankSample();
            string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(es, path);
        }
예제 #14
0
        private void SaveItems(object param)
        {
            Directory.Delete(ItemsPath, true);
            Directory.CreateDirectory(ItemsPath);
            // directory creation might take some time -> wait until it is definitively created
            while (!Directory.Exists(ItemsPath))
            {
                Thread.Sleep(100);
                Directory.CreateDirectory(ItemsPath);
            }

            int i = 0;

            T[] items = GetStorableItems(itemListViewItemMapping.Keys);

            foreach (T item in items)
            {
                try {
                    i++;
                    SetEnabledStateOfContentViews(item, false);
                    XmlGenerator.Serialize(item, ItemsPath + Path.DirectorySeparatorChar + i.ToString("00000000") + ".hl", CompressionLevel.Optimal);
                    OnItemSaved(item, progressBar.Maximum / listView.Items.Count);
                }
                catch (Exception) { }
                finally {
                    SetEnabledStateOfContentViews(item, true);
                }
            }
            OnAllItemsSaved();
        }
예제 #15
0
        public void CreateVnsOpSampleTest()
        {
            var    vns  = CreateVnsOpSample();
            string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(vns, path);
        }
예제 #16
0
        public void CreateTabuSearchTspSampleTest()
        {
            var    ts   = CreateTabuSearchTspSample();
            string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(ts, path);
        }
        public void CreateLocalSearchKnapsackSampleTest()
        {
            var    ls   = CreateLocalSearchKnapsackSample();
            string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(ls, path);
        }
예제 #18
0
        public void CreateRAPGASchedulingSampleTest()
        {
            var    ss   = CreateRAPGASchedulingSample();
            string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(ss, path);
        }
예제 #19
0
        public void CreateGaGroupingProblemSampleTest()
        {
            var    ga   = CreateGaGroupingProblemSample();
            string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);

            XmlGenerator.Serialize(ga, path);
        }
예제 #20
0
 public static byte[] Serialize(object obj, out IEnumerable <Type> types)
 {
     using (MemoryStream memStream = new MemoryStream()) {
         XmlGenerator.Serialize(obj, memStream, ConfigurationService.Instance.GetConfiguration(new XmlFormat()), false, out types);
         byte[] jobByteArray = memStream.ToArray();
         return(jobByteArray);
     }
 }
예제 #21
0
 public static byte[] Serialize(object obj)
 {
     using (MemoryStream memStream = new MemoryStream()) {
         XmlGenerator.Serialize(obj, memStream);
         byte[] jobByteArray = memStream.ToArray();
         return(jobByteArray);
     }
 }
예제 #22
0
 protected T CloneByPersistence <T>(T value)
 {
     using (var serializerStream = new MemoryStream()) {
         XmlGenerator.Serialize(value, serializerStream);
         var bytes = serializerStream.GetBuffer();
         using (var deserializerStream = new MemoryStream(bytes)) {
             return(XmlParser.Deserialize <T>(deserializerStream));
         }
     }
 }
예제 #23
0
 private void storeDataButton_Click(object sender, EventArgs e)
 {
     CallAsync(
         () => {
         if (dataViewHost.Content != null)
         {
             using (MemoryStream stream = new MemoryStream()) {
                 XmlGenerator.Serialize(dataViewHost.Content, stream);
                 stream.Close();
                 data = stream.ToArray();
             }
         }
         AdministrationClient.UpdateProblemData(Content.Id, data);
     },
         "Store problem data failed.",
         null
         );
 }
예제 #24
0
 private void storeDataButton_Click(object sender, EventArgs e)
 {
     CallAsync(
         () => {
         if (dataViewHost.Content != null)
         {
             using (MemoryStream stream = new MemoryStream()) {
                 IAlgorithm algorithm = dataViewHost.Content as IAlgorithm;
                 algorithm.Prepare(true);
                 XmlGenerator.Serialize(algorithm, stream);
                 stream.Close();
                 data = stream.ToArray();
             }
         }
         AdministrationClient.UpdateAlgorithmData(Content.Id, data);
     },
         "Store algorithm data failed.",
         null
         );
 }
예제 #25
0
 private void saveFileButton_Click(object sender, EventArgs e)
 {
     if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
     {
         CallAsync(
             () => {
             if (dataViewHost.Content != null)
             {
                 XmlGenerator.Serialize(dataViewHost.Content, saveFileDialog.FileName);
             }
             else
             {
                 using (FileStream stream = new FileStream(saveFileDialog.FileName, FileMode.Create, FileAccess.Write)) {
                     stream.Write(data, 0, data.Length);
                     stream.Close();
                 }
             }
         },
             "Save algorithm data into file failed.",
             null
             );
     }
 }
 public override void Upload()
 {
     if (SolutionId != -1)
     {
         throw new InvalidOperationException("Solution exists already.");
     }
     using (var stream = new MemoryStream()) {
         if (Solution != null)
         {
             XmlGenerator.Serialize(Solution, stream);
         }
         SolutionId = RunCreationClient.Instance.AddSolution(
             new SingleObjectiveSolution()
         {
             ProblemId = ProblemId,
             Quality   = Quality,
             DataType  = Solution != null ? new DataType()
             {
                 Name     = Solution.GetType().Name,
                 TypeName = Solution.GetType().FullName
             } : null
         }, stream.ToArray());
     }
 }
예제 #27
0
        public Value ConvertToValue(IItem item, string name)
        {
            Value result = null;

            if (item is ValueTypeValue <bool> )
            {
                var boolValue = (ValueTypeValue <bool>)item;
                result = new BoolValue()
                {
                    Value = boolValue.Value
                };
            }
            else if (item is ValueTypeValue <int> )
            {
                var intValue = (ValueTypeValue <int>)item;
                result = new IntValue()
                {
                    Value = intValue.Value
                };
            }
            else if (item is ValueTypeValue <long> )
            {
                var longValue = (ValueTypeValue <long>)item;
                result = new LongValue()
                {
                    Value = longValue.Value
                };
            }
            else if (item is ValueTypeValue <float> )
            {
                var floatValue = (ValueTypeValue <float>)item;
                result = new FloatValue()
                {
                    Value = floatValue.Value
                };
            }
            else if (item is ValueTypeValue <double> )
            {
                var doubleValue = (ValueTypeValue <double>)item;
                if (item is Data.PercentValue)
                {
                    result = new PercentValue()
                    {
                        Value = doubleValue.Value
                    }
                }
                ;
                else
                {
                    result = new DoubleValue()
                    {
                        Value = doubleValue.Value
                    }
                };
            }
            else if (item is ValueTypeValue <TimeSpan> )
            {
                var timeSpanValue = (ValueTypeValue <TimeSpan>)item;
                result = new TimeSpanValue()
                {
                    Value = (long)timeSpanValue.Value.TotalSeconds
                };
            }
            else if (item is Data.StringValue)
            {
                var stringValue = (Data.StringValue)item;
                result = new StringValue()
                {
                    Value = stringValue.Value
                };
            }
            if (result == null)
            {
                var binaryValue = new BinaryValue {
                    DataType = new DataType()
                    {
                        Name     = item.GetType().Name,
                        TypeName = item.GetType().AssemblyQualifiedName
                    }
                };
                using (var memStream = new MemoryStream()) {
                    XmlGenerator.Serialize(item, memStream);
                    binaryValue.Value = memStream.ToArray();
                }
                result = binaryValue;
            }
            result.Name = name;
            return(result);
        }
예제 #28
0
 protected override void SaveContent(IStorableContent content, string filename, bool compressed)
 {
     XmlGenerator.Serialize(content, filename, compressed ? CompressionLevel.Optimal : CompressionLevel.NoCompression);
 }
예제 #29
0
        private void ProfilePersistenceToDisk(string fileName)
        {
            var  REPS = 5;
            var  oldDeserStopwatch = new Stopwatch();
            var  oldSerStopwatch = new Stopwatch();
            var  newDeserStopwatch = new Stopwatch();
            var  newSerStopwatch = new Stopwatch();
            long oldSize = 0, newSize = 0;

            int[] oldCollections = new int[3];
            int[] newCollections = new int[3];

            for (int i = 0; i < REPS; i++)
            {
                var original = XmlParser.Deserialize(fileName);
                System.GC.Collect();
                var collection0 = System.GC.CollectionCount(0);
                var collection1 = System.GC.CollectionCount(1);
                var collection2 = System.GC.CollectionCount(2);

                oldSerStopwatch.Start();
                XmlGenerator.Serialize(original, tempFile);
                oldSerStopwatch.Stop();

                oldSize += new FileInfo(tempFile).Length;
                oldDeserStopwatch.Start();
                var clone = XmlParser.Deserialize(tempFile);
                oldDeserStopwatch.Stop();
                System.GC.Collect();
                oldCollections[0] += System.GC.CollectionCount(0) - collection0;
                oldCollections[1] += System.GC.CollectionCount(1) - collection1;
                oldCollections[2] += System.GC.CollectionCount(2) - collection2;

                collection0 = System.GC.CollectionCount(0);
                collection1 = System.GC.CollectionCount(1);
                collection2 = System.GC.CollectionCount(2);

                newSerStopwatch.Start();
                (new ProtoBufSerializer()).Serialize(original, tempFile);
                newSerStopwatch.Stop();
                newSize += new FileInfo(tempFile).Length;
                newDeserStopwatch.Start();
                var newClone = (new ProtoBufSerializer()).Deserialize(tempFile);
                newDeserStopwatch.Stop();
                System.GC.Collect();
                newCollections[0] += System.GC.CollectionCount(0) - collection0;
                newCollections[1] += System.GC.CollectionCount(1) - collection1;
                newCollections[2] += System.GC.CollectionCount(2) - collection2;
            }
            Console.WriteLine($"{fileName} " +
                              $"{oldSize / (double)REPS} " +
                              $"{newSize / (double)REPS} " +
                              $"{oldSerStopwatch.ElapsedMilliseconds / (double)REPS} " +
                              $"{newSerStopwatch.ElapsedMilliseconds / (double)REPS} " +
                              $"{oldDeserStopwatch.ElapsedMilliseconds / (double)REPS} " +
                              $"{newDeserStopwatch.ElapsedMilliseconds / (double)REPS} " +
                              $"{oldCollections[0] / (double)REPS} " +
                              $"{newCollections[0] / (double)REPS} " +
                              $"{oldCollections[1] / (double)REPS} " +
                              $"{newCollections[1] / (double)REPS} " +
                              $"{oldCollections[2] / (double)REPS} " +
                              $"{newCollections[2] / (double)REPS} " +
                              $"");
        }
예제 #30
0
        List <Value> ConvertToValues(IDictionary <string, IItem> items)
        {
            List <Value> values = new List <Value>();
            bool         add    = true;

            foreach (var item in items)
            {
                Value value;
                if (item.Value is Data.BoolValue)
                {
                    BoolValue v = new BoolValue();
                    v.Value = ((Data.BoolValue)item.Value).Value;
                    value   = v;
                }
                else if (item.Value is Data.IntValue)
                {
                    IntValue v = new IntValue();
                    v.Value = ((Data.IntValue)item.Value).Value;
                    value   = v;
                }
                else if (item.Value is Data.TimeSpanValue)
                {
                    TimeSpanValue v = new TimeSpanValue();
                    v.Value = (long)((Data.TimeSpanValue)item.Value).Value.TotalSeconds;
                    value   = v;
                }
                else if (item.Value is Data.PercentValue)
                {
                    PercentValue v = new PercentValue();
                    v.Value = ((Data.PercentValue)item.Value).Value;
                    value   = v;
                    if (double.IsNaN(v.Value))
                    {
                        add = false;
                    }
                }
                else if (item.Value is Data.DoubleValue)
                {
                    DoubleValue v = new DoubleValue();
                    v.Value = ((Data.DoubleValue)item.Value).Value;
                    value   = v;
                    if (double.IsNaN(v.Value))
                    {
                        add = false;
                    }
                }
                else if (item.Value is Data.StringValue)
                {
                    StringValue v = new StringValue();
                    v.Value = ((Data.StringValue)item.Value).Value;
                    value   = v;
                }
                else
                {
                    BinaryValue v = new BinaryValue();
                    using (MemoryStream stream = new MemoryStream()) {
                        XmlGenerator.Serialize(item.Value, stream);
                        stream.Close();
                        v.Value = stream.ToArray();
                    }
                    value = v;
                }
                if (add)
                {
                    value.Name              = item.Key;
                    value.DataType          = new DataType();
                    value.DataType.Name     = item.Value.GetType().Name;
                    value.DataType.TypeName = item.Value.GetType().AssemblyQualifiedName;
                    values.Add(value);
                }
                else
                {
                    add = true;
                }
            }
            return(values);
        }