/// <summary> /// Get the optimized objective from a permformance result /// </summary> bool GetResult(PerformanceMatrix r, out decimal result) { result = 0; if (_resultproperty == null) { foreach (var pr in r.GetType().GetProperties()) { if (pr.Name == OptimizeDecisionsName) { _resultproperty = pr; break; } } } try { var o = _resultproperty.GetValue(r, null); result = (decimal)o; return true; } catch (Exception ex) { Debug("error getting result from OptimizeDecision name: " + OptimizeDecisionsName + " err: " + ex.Message + ex.StackTrace); } return false; }
/// <summary> /// Get performance measure as optimization objective /// </summary> /// <returns></returns> public static List<string> GetDecideable() { List<string> dr = new List<string>(); // Type r = typeof(PerformanceMatrix); PerformanceMatrix r = new PerformanceMatrix(); foreach (var pi in r.GetType().GetProperties()) { if (!pi.GetAccessors()[0].IsPublic) continue; var pt = pi.PropertyType; if ((pt == typeof(decimal)) || (pt == typeof(int))) dr.Add(pi.Name); } foreach (var pi in r.GetType().GetFields()) { if (!pi.IsPublic) continue; var pt = pi.FieldType; if ((pt == typeof(decimal)) || (pt == typeof(int))) dr.Add(pi.Name); } var tmp = dr.ToArray(); Array.Sort(tmp); return new List<string>(tmp); }