Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OaaS/HeuristicLab.Services.Optimization.Controller/Utility.cs @ 13067

Last change on this file since 13067 was 8817, checked in by fschoepp, 12 years ago

#1888:

  • Added a parser for independent scenarios (using the model of the optimization backend)
  • Optimization scenario sample can be found in mappings folder of the web project.
  • Added IScenarioMapper interface which provides functionality to map from the optimization data model to a backend model (e.g. Heuristic Lab data model)
  • Implementations of IScenarioMapper have to be provided as C# code (strings) which will be compiled by using a CSharpCodeProvider. Once compiled, the implementations of the IScenarioMapper are being cached within the platform for further usage.
  • Fixed a bug in web template DecimalMatrix (using i instead of j)
  • Added missing thumprint of localhost certificate to the optimization web project (ServiceConfiguration.Local.cscfg / ServiceConfiguration.Cloud.cscfg)
  • Test project now provides following test cases: Mapping types using IronPython and mapping types using Otis
File size: 977 bytes
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5
6namespace HeuristicLab.Services.Optimization.ControllerService {
7  public static class Utility {
8    public static T[,] ToMultiD<T>(T[][] jArray) {
9      int i = jArray.Count();
10      int j = jArray.Select(x => x.Count()).Aggregate(0, (current, c) => (current > c) ? current : c);
11
12
13      var mArray = new T[i, j];
14
15      for (int ii = 0; ii < i; ii++) {
16        for (int jj = 0; jj < j; jj++) {
17          mArray[ii, jj] = jArray[ii][jj];
18        }
19      }
20
21      return mArray;
22    }
23
24    public static T[][] ToJagged<T>(T[,] mArray) {
25      var cols = mArray.GetLength(0);
26      var rows = mArray.GetLength(1);
27      var jArray = new T[cols][];
28      for (int i = 0; i < cols; i++) {
29        jArray[i] = new T[rows];
30        for (int j = 0; j < rows; j++) {
31          jArray[i][j] = mArray[i, j];
32        }
33      }
34      return jArray;
35    }
36  }
37}
Note: See TracBrowser for help on using the repository browser.