Changeset 6377 for branches/GP.Grammar.Editor/HeuristicLab.Analysis
- Timestamp:
- 06/07/11 12:49:03 (14 years ago)
- Location:
- branches/GP.Grammar.Editor/HeuristicLab.Analysis/3.3
- Files:
-
- 5 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/GP.Grammar.Editor/HeuristicLab.Analysis/3.3/DataVisualization/DataRowVisualProperties.cs
r5445 r6377 36 36 Columns, 37 37 Points, 38 Bars 38 Bars, 39 Histogram 40 } 41 #endregion 42 #region LineStyle 43 public enum DataRowLineStyle { 44 Dash, 45 DashDot, 46 DashDotDot, 47 Dot, 48 NotSet, 49 Solid 39 50 } 40 51 #endregion … … 60 71 } 61 72 } 73 private bool secondXAxis; 74 public bool SecondXAxis { 75 get { return secondXAxis; } 76 set { 77 if (secondXAxis != value) { 78 secondXAxis = value; 79 OnPropertyChanged("SecondXAxis"); 80 } 81 } 82 } 62 83 private Color color; 63 84 public Color Color { … … 70 91 } 71 92 } 93 private DataRowLineStyle lineStyle; 94 public DataRowLineStyle LineStyle { 95 get { return lineStyle; } 96 set { 97 if (lineStyle != value) { 98 lineStyle = value; 99 OnPropertyChanged("LineStyle"); 100 } 101 } 102 } 72 103 private bool startIndexZero; 73 104 public bool StartIndexZero { … … 77 108 startIndexZero = value; 78 109 OnPropertyChanged("StartIndexZero"); 110 } 111 } 112 } 113 private int lineWidth; 114 public int LineWidth { 115 get { return lineWidth; } 116 set { 117 if (lineWidth != value) { 118 lineWidth = value; 119 OnPropertyChanged("LineWidth"); 120 } 121 } 122 } 123 private int bins; 124 public int Bins { 125 get { return bins; } 126 set { 127 if (bins != value) { 128 bins = value; 129 OnPropertyChanged("Bins"); 130 } 131 } 132 } 133 private bool exactBins; 134 public bool ExactBins { 135 get { return exactBins; } 136 set { 137 if (exactBins != value) { 138 exactBins = value; 139 OnPropertyChanged("ExactBins"); 79 140 } 80 141 } … … 92 153 set { secondYAxis = value; } 93 154 } 155 [Storable(Name = "SecondXAxis")] 156 private bool StorableSecondXAxis { 157 get { return secondXAxis; } 158 set { secondXAxis = value; } 159 } 94 160 [Storable(Name = "Color")] 95 161 private Color StorableColor { … … 97 163 set { color = value; } 98 164 } 165 [Storable(Name = "LineStyle")] 166 private DataRowLineStyle StorableLineStyle { 167 get { return lineStyle; } 168 set { lineStyle = value; } 169 } 99 170 [Storable(Name = "StartIndexZero")] 100 171 private bool StorableStartIndexZero { 101 172 get { return startIndexZero; } 102 173 set { startIndexZero = value; } 174 } 175 [Storable(Name = "LineWidth")] 176 private int StorableLineWidth { 177 get { return lineWidth; } 178 set { lineWidth = value; } 179 } 180 [Storable(Name = "Bins")] 181 private int StorableBins { 182 get { return bins; } 183 set { bins = value; } 184 } 185 [Storable(Name = "ExactBins")] 186 private bool StorableExactBins { 187 get { return exactBins; } 188 set { exactBins = value; } 103 189 } 104 190 #endregion … … 110 196 this.chartType = original.chartType; 111 197 this.secondYAxis = original.secondYAxis; 198 this.secondXAxis = original.secondXAxis; 112 199 this.color = original.color; 200 this.lineStyle = original.lineStyle; 113 201 this.startIndexZero = original.startIndexZero; 202 this.lineWidth = original.lineWidth; 203 this.bins = original.bins; 204 this.exactBins = original.exactBins; 114 205 } 115 206 public DataRowVisualProperties() { 116 207 chartType = DataRowChartType.Line; 117 208 secondYAxis = false; 209 secondXAxis = false; 118 210 color = Color.Empty; 211 lineStyle = DataRowLineStyle.Solid; 119 212 startIndexZero = false; 213 lineWidth = 1; 214 bins = 10; 215 exactBins = false; 120 216 } 121 217 -
branches/GP.Grammar.Editor/HeuristicLab.Analysis/3.3/DataVisualization/DataTableVisualProperties.cs
r5445 r6377 21 21 22 22 using System.ComponentModel; 23 using System.Drawing; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 30 31 [StorableClass] 31 32 public class DataTableVisualProperties : DeepCloneable, INotifyPropertyChanged { 33 private Font titleFont; 34 public Font TitleFont { 35 get { return titleFont; } 36 set { 37 if (titleFont == null || value == null 38 || titleFont.Name != value.Name || titleFont.Size != value.Size || titleFont.Style != value.Style) { 39 titleFont = value; 40 OnPropertyChanged("TitleFont"); 41 } 42 } 43 } 44 private Color titleColor; 45 public Color TitleColor { 46 get { return titleColor; } 47 set { 48 if (titleColor != value) { 49 titleColor = value; 50 OnPropertyChanged("TitleFontColor"); 51 } 52 } 53 } 54 private Font axisTitleFont; 55 public Font AxisTitleFont { 56 get { return axisTitleFont; } 57 set { 58 if (axisTitleFont == null || axisTitleFont == null 59 || axisTitleFont.Name != value.Name || axisTitleFont.Size != value.Size || axisTitleFont.Style != value.Style) { 60 axisTitleFont = value; 61 OnPropertyChanged("AxisTitleFont"); 62 } 63 } 64 } 65 private Color axisTitleColor; 66 public Color AxisTitleColor { 67 get { return axisTitleColor; } 68 set { 69 if (axisTitleColor != value) { 70 axisTitleColor = value; 71 OnPropertyChanged("AxisTitleColor"); 72 } 73 } 74 } 32 75 private string xAxisTitle; 33 76 public string XAxisTitle { … … 54 97 } 55 98 99 private string secondXAxisTitle; 100 public string SecondXAxisTitle { 101 get { return secondXAxisTitle; } 102 set { 103 if (value == null) value = string.Empty; 104 if (secondXAxisTitle != value) { 105 secondXAxisTitle = value; 106 OnPropertyChanged("SecondXAxisTitle"); 107 } 108 } 109 } 110 56 111 private string secondYAxisTitle; 57 112 public string SecondYAxisTitle { … … 66 121 } 67 122 123 private bool xAxisMinimumAuto; 124 public bool XAxisMinimumAuto { 125 get { return xAxisMinimumAuto; } 126 set { 127 if (xAxisMinimumAuto != value) { 128 xAxisMinimumAuto = value; 129 if (value) xAxisMinimumFixedValue = double.NaN; 130 OnPropertyChanged("XAxisMinimumAuto"); 131 } 132 } 133 } 134 135 private bool xAxisMaximumAuto; 136 public bool XAxisMaximumAuto { 137 get { return xAxisMaximumAuto; } 138 set { 139 if (xAxisMaximumAuto != value) { 140 xAxisMaximumAuto = value; 141 if (value) xAxisMaximumFixedValue = double.NaN; 142 OnPropertyChanged("XAxisMaximumAuto"); 143 } 144 } 145 } 146 147 private double xAxisMinimumFixedValue; 148 public double XAxisMinimumFixedValue { 149 get { return xAxisMinimumFixedValue; } 150 set { 151 if (xAxisMinimumFixedValue != value) { 152 xAxisMinimumFixedValue = value; 153 OnPropertyChanged("XAxisMinimumFixedValue"); 154 } 155 } 156 } 157 158 private double xAxisMaximumFixedValue; 159 public double XAxisMaximumFixedValue { 160 get { return xAxisMaximumFixedValue; } 161 set { 162 if (xAxisMaximumFixedValue != value) { 163 xAxisMaximumFixedValue = value; 164 OnPropertyChanged("XAxisMaximumFixedValue"); 165 } 166 } 167 } 168 169 private bool secondXAxisMinimumAuto; 170 public bool SecondXAxisMinimumAuto { 171 get { return secondXAxisMinimumAuto; } 172 set { 173 if (secondXAxisMinimumAuto != value) { 174 secondXAxisMinimumAuto = value; 175 if (value) secondXAxisMinimumFixedValue = double.NaN; 176 OnPropertyChanged("SecondXAxisMinimumAuto"); 177 } 178 } 179 } 180 181 private bool secondXAxisMaximumAuto; 182 public bool SecondXAxisMaximumAuto { 183 get { return secondXAxisMaximumAuto; } 184 set { 185 if (secondXAxisMaximumAuto != value) { 186 secondXAxisMaximumAuto = value; 187 if (value) secondXAxisMaximumFixedValue = double.NaN; 188 OnPropertyChanged("SecondXAxisMaximumAuto"); 189 } 190 } 191 } 192 193 private double secondXAxisMinimumFixedValue; 194 public double SecondXAxisMinimumFixedValue { 195 get { return secondXAxisMinimumFixedValue; } 196 set { 197 if (secondXAxisMinimumFixedValue != value) { 198 secondXAxisMinimumFixedValue = value; 199 OnPropertyChanged("SecondXAxisMinimumFixedValue"); 200 } 201 } 202 } 203 204 private double secondXAxisMaximumFixedValue; 205 public double SecondXAxisMaximumFixedValue { 206 get { return secondXAxisMaximumFixedValue; } 207 set { 208 if (secondXAxisMaximumFixedValue != value) { 209 secondXAxisMaximumFixedValue = value; 210 OnPropertyChanged("SecondXAxisMaximumFixedValue"); 211 } 212 } 213 } 214 215 private bool yAxisMinimumAuto; 216 public bool YAxisMinimumAuto { 217 get { return yAxisMinimumAuto; } 218 set { 219 if (yAxisMinimumAuto != value) { 220 yAxisMinimumAuto = value; 221 if (value) yAxisMinimumFixedValue = double.NaN; 222 OnPropertyChanged("YAxisMinimumAuto"); 223 } 224 } 225 } 226 227 private bool yAxisMaximumAuto; 228 public bool YAxisMaximumAuto { 229 get { return yAxisMaximumAuto; } 230 set { 231 if (yAxisMaximumAuto != value) { 232 yAxisMaximumAuto = value; 233 if (value) yAxisMaximumFixedValue = double.NaN; 234 OnPropertyChanged("YAxisMaximumAuto"); 235 } 236 } 237 } 238 239 private double yAxisMinimumFixedValue; 240 public double YAxisMinimumFixedValue { 241 get { return yAxisMinimumFixedValue; } 242 set { 243 if (yAxisMinimumFixedValue != value) { 244 yAxisMinimumFixedValue = value; 245 OnPropertyChanged("YAxisMinimumFixedValue"); 246 } 247 } 248 } 249 250 private double yAxisMaximumFixedValue; 251 public double YAxisMaximumFixedValue { 252 get { return yAxisMaximumFixedValue; } 253 set { 254 if (yAxisMaximumFixedValue != value) { 255 yAxisMaximumFixedValue = value; 256 OnPropertyChanged("YAxisMaximumFixedValue"); 257 } 258 } 259 } 260 261 private bool secondYAxisMinimumAuto; 262 public bool SecondYAxisMinimumAuto { 263 get { return secondYAxisMinimumAuto; } 264 set { 265 if (secondYAxisMinimumAuto != value) { 266 secondYAxisMinimumAuto = value; 267 if (value) secondYAxisMinimumFixedValue = double.NaN; 268 OnPropertyChanged("SecondYAxisMinimumAuto"); 269 } 270 } 271 } 272 273 private bool secondYAxisMaximumAuto; 274 public bool SecondYAxisMaximumAuto { 275 get { return secondYAxisMaximumAuto; } 276 set { 277 if (secondYAxisMaximumAuto != value) { 278 secondYAxisMaximumAuto = value; 279 if (value) secondYAxisMaximumFixedValue = double.NaN; 280 OnPropertyChanged("SecondYAxisMaximumAuto"); 281 } 282 } 283 } 284 285 private double secondYAxisMinimumFixedValue; 286 public double SecondYAxisMinimumFixedValue { 287 get { return secondYAxisMinimumFixedValue; } 288 set { 289 if (secondYAxisMinimumFixedValue != value) { 290 secondYAxisMinimumFixedValue = value; 291 OnPropertyChanged("SecondYAxisMinimumFixedValue"); 292 } 293 } 294 } 295 296 private double secondYAxisMaximumFixedValue; 297 public double SecondYAxisMaximumFixedValue { 298 get { return secondYAxisMaximumFixedValue; } 299 set { 300 if (secondYAxisMaximumFixedValue != value) { 301 secondYAxisMaximumFixedValue = value; 302 OnPropertyChanged("SecondYAxisMaximumFixedValue"); 303 } 304 } 305 } 306 68 307 #region Persistence Properties 308 [Storable(Name = "TitleFont")] 309 private Font StorableTitleFont { 310 get { return titleFont; } 311 set { titleFont = value; } 312 } 313 [Storable(Name = "TitleColor")] 314 private Color StorableTitleColor { 315 get { return titleColor; } 316 set { titleColor = value; } 317 } 318 [Storable(Name = "AxisTitleFont")] 319 private Font StorableAxisTitleFont { 320 get { return axisTitleFont; } 321 set { axisTitleFont = value; } 322 } 323 [Storable(Name = "AxisTitleColor")] 324 private Color StorableAxisTitleColor { 325 get { return axisTitleColor; } 326 set { axisTitleColor = value; } 327 } 69 328 [Storable(Name = "XAxisTitle")] 70 329 private string StorableXAxisTitle { … … 77 336 set { yAxisTitle = value; } 78 337 } 338 [Storable(Name = "SecondXAxisTitle")] 339 private string StorableSecondXAxisTitle { 340 get { return secondXAxisTitle; } 341 set { secondXAxisTitle = value; } 342 } 79 343 [Storable(Name = "SecondYAxisTitle")] 80 344 private string StorableSecondYAxisTitle { … … 82 346 set { secondYAxisTitle = value; } 83 347 } 348 [Storable(Name = "XAxisMinimumAuto")] 349 private bool StorableXAxisMinimumAuto { 350 get { return xAxisMinimumAuto; } 351 set { xAxisMinimumAuto = value; } 352 } 353 [Storable(Name = "XAxisMaximumAuto")] 354 private bool StorableXAxisMaximumAuto { 355 get { return xAxisMaximumAuto; } 356 set { xAxisMaximumAuto = value; } 357 } 358 [Storable(Name = "XAxisMinimumFixedValue")] 359 private double StorableXAxisMinimumFixedValue { 360 get { return xAxisMinimumFixedValue; } 361 set { xAxisMinimumFixedValue = value; } 362 } 363 [Storable(Name = "XAxisMaximumFixedValue")] 364 private double StorableXAxisMaximumFixedValue { 365 get { return xAxisMaximumFixedValue; } 366 set { xAxisMaximumFixedValue = value; } 367 } 368 [Storable(Name = "SecondXAxisMinimumAuto")] 369 private bool StorableSecondXAxisMinimumAuto { 370 get { return secondXAxisMinimumAuto; } 371 set { secondXAxisMinimumAuto = value; } 372 } 373 [Storable(Name = "SecondXAxisMaximumAuto")] 374 private bool StorableSecondXAxisMaximumAuto { 375 get { return secondXAxisMaximumAuto; } 376 set { secondXAxisMaximumAuto = value; } 377 } 378 [Storable(Name = "SecondXAxisMinimumFixedValue")] 379 private double StorableSecondXAxisMinimumFixedValue { 380 get { return secondXAxisMinimumFixedValue; } 381 set { secondXAxisMinimumFixedValue = value; } 382 } 383 [Storable(Name = "SecondXAxisMaximumFixedValue")] 384 private double StorableSecondXAxisMaximumFixedValue { 385 get { return secondXAxisMaximumFixedValue; } 386 set { secondXAxisMaximumFixedValue = value; } 387 } 388 [Storable(Name = "YAxisMinimumAuto")] 389 private bool StorableYAxisMinimumAuto { 390 get { return yAxisMinimumAuto; } 391 set { yAxisMinimumAuto = value; } 392 } 393 [Storable(Name = "YAxisMaximumAuto")] 394 private bool StorableYAxisMaximumAuto { 395 get { return yAxisMaximumAuto; } 396 set { yAxisMaximumAuto = value; } 397 } 398 [Storable(Name = "YAxisMinimumFixedValue")] 399 private double StorableYAxisMinimumFixedValue { 400 get { return yAxisMinimumFixedValue; } 401 set { yAxisMinimumFixedValue = value; } 402 } 403 [Storable(Name = "YAxisMaximumFixedValue")] 404 private double StorableYAxisMaximumFixedValue { 405 get { return yAxisMaximumFixedValue; } 406 set { yAxisMaximumFixedValue = value; } 407 } 408 [Storable(Name = "SecondYAxisMinimumAuto")] 409 private bool StorableSecondYAxisMinimumAuto { 410 get { return secondYAxisMinimumAuto; } 411 set { secondYAxisMinimumAuto = value; } 412 } 413 [Storable(Name = "SecondYAxisMaximumAuto")] 414 private bool StorableSecondYAxisMaximumAuto { 415 get { return secondYAxisMaximumAuto; } 416 set { secondYAxisMaximumAuto = value; } 417 } 418 [Storable(Name = "SecondYAxisMinimumFixedValue")] 419 private double StorableSecondYAxisMinimumFixedValue { 420 get { return secondYAxisMinimumFixedValue; } 421 set { secondYAxisMinimumFixedValue = value; } 422 } 423 [Storable(Name = "SecondYAxisMaximumFixedValue")] 424 private double StorableSecondYAxisMaximumFixedValue { 425 get { return secondYAxisMaximumFixedValue; } 426 set { secondYAxisMaximumFixedValue = value; } 427 } 84 428 #endregion 85 429 … … 88 432 protected DataTableVisualProperties(DataTableVisualProperties original, Cloner cloner) 89 433 : base(original, cloner) { 434 if (original.titleFont != null) 435 this.titleFont = (Font)original.titleFont.Clone(); 436 if (original.axisTitleFont != null) 437 this.axisTitleFont = (Font)original.axisTitleFont.Clone(); 90 438 this.xAxisTitle = original.xAxisTitle; 91 439 this.yAxisTitle = original.yAxisTitle; 440 this.secondXAxisTitle = original.secondXAxisTitle; 92 441 this.secondYAxisTitle = original.secondYAxisTitle; 442 this.xAxisMinimumAuto = original.xAxisMinimumAuto; 443 this.xAxisMinimumFixedValue = original.xAxisMinimumFixedValue; 444 this.xAxisMaximumAuto = original.xAxisMaximumAuto; 445 this.xAxisMaximumFixedValue = original.xAxisMaximumFixedValue; 446 this.secondXAxisMinimumAuto = original.secondXAxisMinimumAuto; 447 this.secondXAxisMinimumFixedValue = original.secondXAxisMinimumFixedValue; 448 this.secondXAxisMaximumAuto = original.secondXAxisMaximumAuto; 449 this.secondXAxisMaximumFixedValue = original.secondXAxisMaximumFixedValue; 450 this.yAxisMinimumAuto = original.yAxisMinimumAuto; 451 this.yAxisMinimumFixedValue = original.yAxisMinimumFixedValue; 452 this.yAxisMaximumAuto = original.yAxisMaximumAuto; 453 this.yAxisMaximumFixedValue = original.yAxisMaximumFixedValue; 454 this.secondYAxisMinimumAuto = original.secondYAxisMinimumAuto; 455 this.secondYAxisMinimumFixedValue = original.secondYAxisMinimumFixedValue; 456 this.secondYAxisMaximumAuto = original.secondYAxisMaximumAuto; 457 this.secondYAxisMaximumFixedValue = original.secondYAxisMaximumFixedValue; 93 458 } 94 459 public DataTableVisualProperties() { 460 titleColor = Color.Black; 461 axisTitleColor = Color.Black; 95 462 this.xAxisTitle = string.Empty; 96 463 this.yAxisTitle = string.Empty; 464 this.secondXAxisTitle = string.Empty; 97 465 this.secondYAxisTitle = string.Empty; 466 this.xAxisMinimumAuto = true; 467 this.xAxisMinimumFixedValue = double.NaN; 468 this.xAxisMaximumAuto = true; 469 this.xAxisMaximumFixedValue = double.NaN; 470 this.secondXAxisMinimumAuto = true; 471 this.secondXAxisMinimumFixedValue = double.NaN; 472 this.secondXAxisMaximumAuto = true; 473 this.secondXAxisMaximumFixedValue = double.NaN; 474 this.yAxisMinimumAuto = true; 475 this.yAxisMinimumFixedValue = double.NaN; 476 this.yAxisMaximumAuto = true; 477 this.yAxisMaximumFixedValue = double.NaN; 478 this.secondYAxisMinimumAuto = true; 479 this.secondYAxisMinimumFixedValue = double.NaN; 480 this.secondYAxisMaximumAuto = true; 481 this.secondYAxisMaximumFixedValue = double.NaN; 98 482 } 99 483 -
branches/GP.Grammar.Editor/HeuristicLab.Analysis/3.3/HeuristicLab.Analysis-3.3.csproj
r5933 r6377 138 138 <Compile Include="HeuristicLabAnalysisPlugin.cs" /> 139 139 <Compile Include="Properties\AssemblyInfo.cs" /> 140 <Compile Include="QualityAnalysis\QualityDistributionAnalyzer.cs" /> 140 141 <Compile Include="ValueAnalysis\MinAverageMaxValueAnalyzer.cs" /> 141 142 <Compile Include="ValueAnalysis\MinAverageMaxValueCalculator.cs" /> -
branches/GP.Grammar.Editor/HeuristicLab.Analysis/3.3/MultidimensionalScaling/MultidimensionalScaling.cs
r5933 r6377 68 68 /// In every iteration it tries to find the best location for every item.</param> 69 69 /// <returns>A Nx2 matrix where the first column represents the x- and the second column the y coordinates.</returns> 70 public static DoubleMatrix KruskalShepard(DoubleMatrix dissimilarities, DoubleMatrix coordinates, int maximumIterations = 20) {70 public static DoubleMatrix KruskalShepard(DoubleMatrix dissimilarities, DoubleMatrix coordinates, int maximumIterations = 10) { 71 71 int dimension = dissimilarities.Rows; 72 72 if (dimension != dissimilarities.Columns || coordinates.Rows != dimension) throw new ArgumentException("The number of coordinates and the number of rows and columns in the dissimilarities matrix do not match."); … … 75 75 double epsf = 0; 76 76 double epsx = 0; 77 int maxits = 100; 78 alglib.mincgstate state = null; 79 alglib.mincgreport rep; 77 int maxits = 0; 80 78 79 alglib.minlmstate state; 80 alglib.minlmreport rep; 81 81 for (int iterations = 0; iterations < maximumIterations; iterations++) { 82 82 bool changed = false; … … 85 85 86 86 try { 87 if ((iterations == 0 && i == 0)) { 88 alglib.mincgcreate(c, out state); 89 alglib.mincgsetcond(state, epsg, epsf, epsx, maxits); 90 } else { 91 alglib.mincgrestartfrom(state, c); 92 } 93 alglib.mincgoptimize(state, StressGradient, null, new Info(coordinates, dissimilarities, i)); 94 alglib.mincgresults(state, out c, out rep); 87 alglib.minlmcreatevj(dimension - 1, c, out state); 88 alglib.minlmsetcond(state, epsg, epsf, epsx, maxits); 89 alglib.minlmoptimize(state, StressFitness, StressJacobian, null, new Info(coordinates, dissimilarities, i)); 90 alglib.minlmresults(state, out c, out rep); 95 91 } catch (alglib.alglibexception) { } 96 92 if (!double.IsNaN(c[0]) && !double.IsNaN(c[1])) { … … 105 101 } 106 102 107 // computes the function and the gradient of the raw stress function. 108 private static void StressGradient(double[] x, ref double func, double[] grad, object obj) { 109 func = 0; grad[0] = 0; grad[1] = 0; 103 private static void StressFitness(double[] x, double[] fi, object obj) { 110 104 Info info = (obj as Info); 111 105 for (int i = 0; i < info.Coordinates.Rows; i++) { 112 double c = info.Dissimilarities[info.Row, i]; 106 double f = Stress(x, info.Dissimilarities[info.Row, i], info.Coordinates[i, 0], info.Coordinates[i, 1]); 107 if (i < info.Row) fi[i] = f; 108 else if (i > info.Row) fi[i - 1] = f; 109 } 110 } 111 112 private static void StressJacobian(double[] x, double[] fi, double[,] jac, object obj) { 113 Info info = (obj as Info); 114 int idx = 0; 115 for (int i = 0; i < info.Coordinates.Rows; i++) { 113 116 if (i != info.Row) { 117 double c = info.Dissimilarities[info.Row, i]; 114 118 double a = info.Coordinates[i, 0]; 115 119 double b = info.Coordinates[i, 1]; 116 func += Stress(x, c, a, b); 117 grad[0] += ((2 * x[0] - 2 * a) * Math.Sqrt(x[1] * x[1] - 2 * b * x[1] + x[0] * x[0] - 2 * a * x[0] + b * b + a * a) - 2 * c * x[0] + 2 * a * c) / Math.Sqrt(x[1] * x[1] - 2 * b * x[1] + x[0] * x[0] - 2 * a * x[0] + b * b + a * a); 118 grad[1] += ((2 * x[1] - 2 * b) * Math.Sqrt(x[1] * x[1] - 2 * b * x[1] + x[0] * x[0] - 2 * a * x[0] + b * b + a * a) - 2 * c * x[1] + 2 * b * c) / Math.Sqrt(x[1] * x[1] - 2 * b * x[1] + x[0] * x[0] - 2 * a * x[0] + b * b + a * a); 120 double f = Stress(x, c, a, b); 121 fi[idx] = f; 122 jac[idx, 0] = 2 * (x[0] - a) * (Math.Sqrt((a - x[0]) * (a - x[0]) + (b - x[1]) * (b - x[1])) - c) / Math.Sqrt((a - x[0]) * (a - x[0]) + (b - x[1]) * (b - x[1])); 123 jac[idx, 1] = 2 * (x[1] - b) * (Math.Sqrt((a - x[0]) * (a - x[0]) + (b - x[1]) * (b - x[1])) - c) / Math.Sqrt((a - x[0]) * (a - x[0]) + (b - x[1]) * (b - x[1])); 124 idx++; 119 125 } 120 126 } -
branches/GP.Grammar.Editor/HeuristicLab.Analysis/3.3/Tests/MultidimensionalScalingTest.cs
r5938 r6377 21 21 22 22 using System; 23 using System.Globalization; 23 24 using HeuristicLab.Data; 24 25 using Microsoft.VisualStudio.TestTools.UnitTesting; … … 42 43 distances3[0, 2] = distances3[2, 0] = 6.4; 43 44 distances3[1, 2] = distances3[2, 1] = 5; 44 stress = MultidimensionalScaling.CalculateNormalizedStress(distances3, 45 MultidimensionalScaling.KruskalShepard(distances3)); 45 DoubleMatrix coords3 = MultidimensionalScaling.KruskalShepard(distances3); 46 Console.WriteLine("Coordinates: "); 47 Console.WriteLine("A = ({0}, {1}), B = ({2}, {3}), C = ({4}, {5})", coords3[0, 0], coords3[0, 1], coords3[1, 0], coords3[1, 1], coords3[2, 0], coords3[2, 1]); 48 stress = MultidimensionalScaling.CalculateNormalizedStress(distances3, coords3); 49 Console.WriteLine("Stress = " + stress.ToString(CultureInfo.InvariantCulture.NumberFormat)); 46 50 Assert.IsTrue(stress < 0.1); 47 51 DoubleMatrix distances4 = new DoubleMatrix(4, 4);
Note: See TracChangeset
for help on using the changeset viewer.