Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/23/15 12:50:05 (9 years ago)
Author:
gkronber
Message:

#2261: merged trunk changes to branch
r12494
#2403: added a null check in the MatlabParameterVectorEvaluator to prevent exceptions when clearstate is called


r12493
#2369: added support for squared errors and relative errors to error-characteristic-curve view


r12492
#2392: implemented PearsonsRCalculator to fix incorrect correlation values in the correlation matrix.


r12491
#2402 don't set task state to waiting when it fails


r12490
#2401 added missing Mono.Cecil plugin dependency


r12488
#2400 - Interfaces for Capaciated-, PickupAndDelivery- and TimeWindowed-ProblemInstances now specify an additional penalty parameter to set the current penalty factor for the constraint relaxation. - The setter of the penalty-property in ...


r12485
#2374 made RegressionSolution and ClassificationSolution non-abstract


r12482
#2320: Fixed warnings in unit test solutions introduced in r12420 by marking methods as obsolete.


r12481
#2320: Fixed AfterDeserialization of GEArtifialAntEvaluator.


r12480
#2320: Fixed error in symbolicexpressiontree crossover regarding the wiring of lookup parameters if persisted file is loaded.


r12479
#2397 moved GeoIP project into ExtLibs


r12478
#2329 fixed bug in simple code editor


r12476
#2331 removed outdated plugins


r12475
#2368 fixed compile warnings


r12474
#2399 worked on Mono project prepare script


r12473
#2329 added a simple code editor for Linux


r12472
#2399 - fixed MathJax.js file name - worked on Mono project prepare script


r12471
#2399 worked on Mono project prepare script


r12470
#2399 fixed pre-build events in project files


r12465
#2399 worked on mono project prepare script


r12464
#2399 added patch to project


r12463
#2399 fixed EPPlus so that it compiles on Linux


r12461
#2398: Skip root and start symbols when calculating impacts and replacement values in the pruning operators.


r12458
#2354 show label when no data is displayed and don't show the legend


r12457
#2353 removed duplicated call to Any() in Hive Status page


r12456
#2368 fixed modifier


r12455
#2368 added support in persistence for typecaches in streams


r12445
#2394: Changed Web.config compilation from debug to release to force script bundling. Changed history loading type from lazy to eager loading to increase performance. Fixed "getCoreStatus" typo in statusCtrl.js


r12443
#2394: Fixed UserTaskQuery and GetStatusHistory in the WebApp.Status plugin


r12442
#2394 added nuget folders to svn ignore list


r12435
#2394: Improved PluginManager and updated hive status monitor.


r12434
#2396 added symbolic expression tree formatter for C#


r12433
#2395: Minor change in DoubleValue.GetValue.


r12432
#2395 Use simple round-trip format for doubles because G17 prints some strange numbers (20.22 to 20.219999999999999999). Some accuracy can still be lost on 64bit machines, but should be very rare and minimal. double.MaxValue can still be pa...


r12431
#2395 Fixed parsing issues by using the G17 format.


r12430
#2394 added missing package config


r12429
#2394 added missing package config


r12428
#2394 added web app and status page to trunk


r12424
#2320: Adapted plugin file and updated project file of SymbolicExpressionTreeEncoding.


r12422
#2320: Merged the encoding class and all accompanying changes in the trunk.


r12401
#2387 Fixed a bug where the automatic selection of the first element behaved differently for the NewItemDialog.


r12400
#2387 Forgot to commit a file.


r12399
#2387 - Added context-menu for expanding and collapsing tree-nodes. - Improve response time when expanding/collapsing all nodes for TypeSelector and NewItemDialog.


r12398
#2387 - Added clearSearch-button in TypeSelector. - Adapted behavior of TypeSelector and NewItemDialog that a selected node stays selected as long as it matches the search criteria.


r12397
#2387 - Adapted behavior of the matching in the TypeSelector that it behave the same as the NewItemDialog. The search string is tokenized by space and matches if all tokens are contained, (eg. "Sym Reg" matches "SymbolicRegression...")...


r12393
#2025 - Removed Expand/CollapseAll buttons. - Removed cycling of items.


r12392
#2386: Updated GetHashCode method in the EnumerableBoolEqualityComparer.


Location:
branches/GBT
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/GBT

  • branches/GBT/HeuristicLab.Persistence

  • branches/GBT/HeuristicLab.Persistence/3.3/Default/Xml/XmlGenerator.cs

    r12012 r12495  
    311311    }
    312312
     313    private static void Serialize(object obj, Stream stream, Configuration config, bool includeAssemblies
     314   , CompressionLevel compression) {
     315      Serializer serializer = new Serializer(obj, config);
     316      Serialize(stream, includeAssemblies, compression, serializer);
     317    }
     318
     319    private static void Serialize(Stream stream, bool includeAssemblies, CompressionLevel compression, Serializer serializer) {
     320      try {
     321        DateTime start = DateTime.Now;
     322        serializer.InterleaveTypeInformation = false;
     323        XmlGenerator generator = new XmlGenerator();
     324        using (ZipArchive zipArchive = new ZipArchive(stream, ZipArchiveMode.Create)) {
     325          ZipArchiveEntry entry = zipArchive.CreateEntry("data.xml", compression);
     326          using (StreamWriter writer = new StreamWriter(entry.Open())) {
     327            foreach (ISerializationToken token in serializer) {
     328              string line = generator.Format(token);
     329              writer.Write(line);
     330            }
     331          }
     332          entry = zipArchive.CreateEntry("typecache.xml", compression);
     333          using (StreamWriter writer = new StreamWriter(entry.Open())) {
     334            foreach (string line in generator.Format(serializer.TypeCache)) {
     335              writer.Write(line);
     336            }
     337          }
     338          if (includeAssemblies) {
     339            foreach (string name in serializer.RequiredFiles) {
     340              Uri uri = new Uri(name);
     341              if (!uri.IsFile) {
     342                Logger.Warn("cannot read non-local files");
     343                continue;
     344              }
     345              entry = zipArchive.CreateEntry(Path.GetFileName(uri.PathAndQuery), compression);
     346              using (BinaryWriter bw = new BinaryWriter(entry.Open())) {
     347                using (FileStream reader = File.OpenRead(uri.PathAndQuery)) {
     348                  byte[] buffer = new byte[1024 * 1024];
     349                  while (true) {
     350                    int bytesRead = reader.Read(buffer, 0, 1024 * 1024);
     351                    if (bytesRead == 0)
     352                      break;
     353                    bw.Write(buffer, 0, bytesRead);
     354                  }
     355                }
     356              }
     357            }
     358          }
     359        }
     360        Logger.Info(String.Format("serialization took {0} seconds with compression level {1}",
     361          (DateTime.Now - start).TotalSeconds, compression));
     362      }
     363      catch (Exception) {
     364        Logger.Warn("Exception caught, no data has been serialized.");
     365        throw;
     366      }
     367    }
     368
    313369    /// <summary>
    314370    /// Serializes the specified object into a file.
     
    322378      try {
    323379        string tempfile = Path.GetTempFileName();
    324         DateTime start = DateTime.Now;
     380
    325381        using (FileStream stream = File.Create(tempfile)) {
    326           Serializer serializer = new Serializer(obj, config);
    327           serializer.InterleaveTypeInformation = false;
    328           XmlGenerator generator = new XmlGenerator();
    329           using (ZipArchive zipArchive = new ZipArchive(stream, ZipArchiveMode.Create)) {
    330             ZipArchiveEntry entry = zipArchive.CreateEntry("data.xml", compression);
    331             using (StreamWriter writer = new StreamWriter(entry.Open())) {
    332               foreach (ISerializationToken token in serializer) {
    333                 string line = generator.Format(token);
    334                 writer.Write(line);
    335               }
    336             }
    337             entry = zipArchive.CreateEntry("typecache.xml", compression);
    338             using (StreamWriter writer = new StreamWriter(entry.Open())) {
    339               foreach (string line in generator.Format(serializer.TypeCache)) {
    340                 writer.Write(line);
    341               }
    342             }
    343             if (includeAssemblies) {
    344               foreach (string name in serializer.RequiredFiles) {
    345                 Uri uri = new Uri(name);
    346                 if (!uri.IsFile) {
    347                   Logger.Warn("cannot read non-local files");
    348                   continue;
    349                 }
    350                 entry = zipArchive.CreateEntry(Path.GetFileName(uri.PathAndQuery), compression);
    351                 using (BinaryWriter bw = new BinaryWriter(entry.Open())) {
    352                   using (FileStream reader = File.OpenRead(uri.PathAndQuery)) {
    353                     byte[] buffer = new byte[1024 * 1024];
    354                     while (true) {
    355                       int bytesRead = reader.Read(buffer, 0, 1024 * 1024);
    356                       if (bytesRead == 0)
    357                         break;
    358                       bw.Write(buffer, 0, bytesRead);
    359                     }
    360                   }
    361                 }
    362               }
    363             }
    364           }
    365         }
    366         Logger.Info(String.Format("serialization took {0} seconds with compression level {1}",
    367           (DateTime.Now - start).TotalSeconds, compression));
     382          Serialize(obj, stream, config, includeAssemblies, compression);
     383        }
     384
    368385        File.Copy(tempfile, filename, true);
    369386        File.Delete(tempfile);
     
    381398    /// <param name="obj">The object.</param>
    382399    /// <param name="stream">The stream.</param>
    383     public static void Serialize(object obj, Stream stream) {
    384       Serialize(obj, stream, ConfigurationService.Instance.GetConfiguration(new XmlFormat()));
     400    /// <param name="useZip">If true, uses zip for compression, otherwise gzip.</param>
     401    public static void Serialize(object obj, Stream stream, bool useZip = false) {
     402      Serialize(obj, stream, ConfigurationService.Instance.GetConfiguration(new XmlFormat()), useZip);
    385403    }
    386404
     
    392410    /// <param name="stream">The stream.</param>
    393411    /// <param name="config">The configuration.</param>
    394     public static void Serialize(object obj, Stream stream, Configuration config) {
    395       Serialize(obj, stream, config, false);
     412    /// <param name="useZip">If true, uses zip for compression, otherwise gzip.</param>
     413    public static void Serialize(object obj, Stream stream, Configuration config, bool useZip = false) {
     414      Serialize(obj, stream, config, false, useZip);
    396415    }
    397416
     
    403422    /// <param name="config">The configuration.</param>
    404423    /// <param name="includeAssemblies">if set to <c>true</c> include need assemblies.</param>
    405     public static void Serialize(object obj, Stream stream, Configuration config, bool includeAssemblies) {
     424    /// <param name="useZip">If true, uses zip for compression, otherwise gzip.</param>
     425    public static void Serialize(object obj, Stream stream, Configuration config, bool includeAssemblies, bool useZip = false) {
    406426      try {
    407427        Serializer serializer = new Serializer(obj, config);
    408         Serialize(stream, serializer);
     428        if (useZip) {
     429          Serialize(obj, stream, config, includeAssemblies, CompressionLevel.Optimal);
     430        } else {
     431          Serialize(stream, serializer);
     432        }
    409433      }
    410434      catch (PersistenceException) {
     
    424448    /// <param name="includeAssemblies">if set to <c>true</c> include need assemblies.</param>
    425449    /// <param name="types">The list of all serialized types.</param>
    426     public static void Serialize(object obj, Stream stream, Configuration config, bool includeAssemblies, out IEnumerable<Type> types) {
     450    /// <param name="useZip">If true, uses zip for compression, otherwise gzip.</param>
     451    public static void Serialize(object obj, Stream stream, Configuration config, bool includeAssemblies, out IEnumerable<Type> types, bool useZip = false) {
    427452      try {
    428453        Serializer serializer = new Serializer(obj, config);
    429         Serialize(stream, serializer);
     454        if (useZip) {
     455          Serialize(stream, includeAssemblies, CompressionLevel.Optimal, serializer);
     456        } else {
     457          Serialize(stream, serializer);
     458        }
    430459        types = serializer.SerializedTypes;
    431460      }
Note: See TracChangeset for help on using the changeset viewer.