- Timestamp:
- 09/10/11 16:25:22 (13 years ago)
- Location:
- branches/GeneralizedQAP/HeuristicLab.Services.ProblemInstances.QAPInitializer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GeneralizedQAP/HeuristicLab.Services.ProblemInstances.QAPInitializer/Program.cs
r6659 r6733 1 1 using System; 2 using System.Linq; 2 3 using System.Text; 3 4 using HeuristicLab.Problems.QuadraticAssignment; … … 10 11 foreach (string instance in qap.EmbeddedInstances) { 11 12 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]; 21 20 } 22 21 } 23 22 24 23 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); 33 33 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 } 35 44 } 36 45 context.SaveChanges(); -
branches/GeneralizedQAP/HeuristicLab.Services.ProblemInstances.QAPInitializer/app.config
r6659 r6733 6 6 </system.serviceModel> 7 7 <connectionStrings> 8 <add name="ProblemInstancesEntities" connectionString="metadata=res://*/ProblemInstancesModel.csdl|res://*/ProblemInstancesModel.ssdl|res://*/ProblemInstancesModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=MRPINK\SQLEXPRESS;Initial Catalog= ProblemInstances;Integrated Security=True;Pooling=False;MultipleActiveResultSets=True"" 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="Data Source=MRPINK\SQLEXPRESS;Initial Catalog=HeuristicLab.ProblemInstances;Integrated Security=True;Pooling=False;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" /> 9 9 </connectionStrings> 10 10 </configuration>
Note: See TracChangeset
for help on using the changeset viewer.