Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/10/11 16:25:22 (13 years ago)
Author:
abeham
Message:

#1619

  • Updated the model slightly
  • Deployed the service
  • Updated the GUI to perform asynchronous calls to the service
Location:
branches/GeneralizedQAP/HeuristicLab.Services.ProblemInstances.QAPInitializer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/GeneralizedQAP/HeuristicLab.Services.ProblemInstances.QAPInitializer/Program.cs

    r6659 r6733  
    11using System;
     2using System.Linq;
    23using System.Text;
    34using HeuristicLab.Problems.QuadraticAssignment;
     
    1011        foreach (string instance in qap.EmbeddedInstances) {
    1112          qap.LoadEmbeddedInstance(instance);
    12           // transform matrices into jagged arrays
    13           double[][] weights = new double[qap.Weights.Rows][];
    14           double[][] distances = new double[qap.Weights.Rows][];
    15           for (int i = 0; i < weights.Length; i++) {
    16             weights[i] = new double[weights.Length];
    17             distances[i] = new double[weights.Length];
    18             for (int j = 0; j < weights.Length; j++) {
    19               weights[i][j] = qap.Weights[i, j];
    20               distances[i][j] = qap.Distances[i, j];
     13          // transform DoubleMatrix into multidimensional array
     14          double[,] weights = new double[qap.Weights.Rows, qap.Weights.Columns];
     15          double[,] distances = new double[qap.Distances.Rows, qap.Distances.Columns];
     16          for (int i = 0; i < weights.GetLength(0); i++) {
     17            for (int j = 0; j < weights.GetLength(1); j++) {
     18              weights[i, j] = qap.Weights[i, j];
     19              distances[i, j] = qap.Distances[i, j];
    2120            }
    2221          }
    2322
    2423          QAPInstance dbInstance = context.CreateObject<QAPInstance>();
    25           dbInstance.name = qap.Name;
    26           dbInstance.description = qap.Description;
    27           dbInstance.maximization = qap.Maximization.Value;
    28           dbInstance.weights = PrimitiveSerializer.SerializeDoubleMatrix(weights);
    29           dbInstance.weights_sha1 = GetSHA1Hash(dbInstance.weights);
    30           dbInstance.distances = PrimitiveSerializer.SerializeDoubleMatrix(distances);
    31           dbInstance.distances_sha1 = GetSHA1Hash(dbInstance.distances);
    32           dbInstance.problemsize = qap.Weights.Rows;
     24          dbInstance.Name = qap.Name;
     25          dbInstance.Description = qap.Description;
     26          dbInstance.Maximization = qap.Maximization.Value;
     27          dbInstance.Weights = SimpleSerializer.SerializeDoubleMatrix(weights);
     28          dbInstance.WeightsHash = GetSHA1Hash(dbInstance.Weights);
     29          dbInstance.Distances = SimpleSerializer.SerializeDoubleMatrix(distances);
     30          dbInstance.DistancesHash = GetSHA1Hash(dbInstance.Distances);
     31          dbInstance.ProblemSize = qap.Weights.Rows;
     32          context.QAPInstances.AddObject(dbInstance);
    3333
    34           context.QAPInstances.AddObject(dbInstance);
     34          if (qap.BestKnownQuality != null) {
     35            QAPSolution dbSolution = context.CreateObject<QAPSolution>();
     36            if (qap.BestKnownSolution != null) {
     37              dbSolution.Assignment = SimpleSerializer.SerializeIntArray(qap.BestKnownSolution.ToArray());
     38              dbSolution.AssignmentHash = GetSHA1Hash(dbSolution.Assignment);
     39            }
     40            dbSolution.Instance = dbInstance;
     41            dbSolution.Quality = qap.BestKnownQuality.Value;
     42            context.QAPSolutions.AddObject(dbSolution);
     43          }
    3544        }
    3645        context.SaveChanges();
  • branches/GeneralizedQAP/HeuristicLab.Services.ProblemInstances.QAPInitializer/app.config

    r6659 r6733  
    66    </system.serviceModel>
    77  <connectionStrings>
    8     <add name="ProblemInstancesEntities" connectionString="metadata=res://*/ProblemInstancesModel.csdl|res://*/ProblemInstancesModel.ssdl|res://*/ProblemInstancesModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=MRPINK\SQLEXPRESS;Initial Catalog=ProblemInstances;Integrated Security=True;Pooling=False;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
     8    <add name="ProblemInstancesEntities" connectionString="metadata=res://*/ProblemInstancesModel.csdl|res://*/ProblemInstancesModel.ssdl|res://*/ProblemInstancesModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=MRPINK\SQLEXPRESS;Initial Catalog=HeuristicLab.ProblemInstances;Integrated Security=True;Pooling=False;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
    99  </connectionStrings>
    1010</configuration>
Note: See TracChangeset for help on using the changeset viewer.