-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
633 lines (581 loc) · 18.5 KB
/
Copy pathProgram.cs
File metadata and controls
633 lines (581 loc) · 18.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
using System;
using System.Linq;
using ASD.Graphs;
using ASD.Graphs.Testing;
namespace ASD
{
public class Lab06Stage1Case : Lab06StageBase
{
readonly int start;
public Lab06Stage1Case(DiGraph<int> c,
Graph<int> g,
int start,
int end,
int? expectedResult,
double timeLimit,
string description) : base(c, g, end, expectedResult, timeLimit, description)
{
this.start = start;
}
protected override bool CheckResultValue => false;
protected override int[] PossibleStarts => new int[] { start };
protected override void PerformTestCase(object prototypeObject)
{
var res = ((Lab06)prototypeObject).Stage1(c.VertexCount, cClone, gClone, end, start);
foundResult = res.Item1;
resultPath = res.Item2;
}
}
public class Lab06Stage2Case : Lab06StageBase
{
readonly int[] starts;
public Lab06Stage2Case(DiGraph<int> c,
Graph<int> g,
int start,
int end,
int? expectedResult,
double timeLimit,
string description) : base(c, g, end, expectedResult, timeLimit, description)
{
starts = new int[] { start };
}
public Lab06Stage2Case(DiGraph<int> c,
Graph<int> g,
int[] starts,
int end,
int? expectedResult,
double timeLimit,
string description) : base(c, g, end, expectedResult, timeLimit, description)
{
this.starts = starts;
}
protected override bool CheckResultValue => true;
protected override int[] PossibleStarts => starts;
protected override void PerformTestCase(object prototypeObject)
{
var res = ((Lab06)prototypeObject).Stage2(c.VertexCount, cClone, gClone, end, starts);
foundResult = res.Item1.HasValue;
if (foundResult.Value)
{
foundResultCost = res.Item1.Value;
}
resultPath = res.Item2;
}
}
public abstract class Lab06StageBase : TestCase
{
protected readonly DiGraph<int> c;
protected readonly Graph<int> g;
protected readonly DiGraph<int> cClone;
protected readonly Graph<int> gClone;
protected readonly int end;
protected readonly int? expectedResult;
protected bool? foundResult = null;
protected int foundResultCost = -1;
protected int[] resultPath = null;
public Lab06StageBase(DiGraph<int> c,
Graph<int> g,
int end,
int? expectedResult,
double timeLimit,
string description) : base(timeLimit, null, description)
{
this.c = c;
this.g = g;
this.cClone = new DiGraph<int>(c);
this.gClone = new Graph<int>(g);
this.end = end;
this.expectedResult = expectedResult;
}
protected abstract bool CheckResultValue { get; }
protected abstract int[] PossibleStarts { get; }
public (Result resultCode, string message) OkResult(string message) => (TimeLimit < PerformanceTime ? Result.LowEfficiency : Result.Success, $"{message} {PerformanceTime.ToString("#0.00")}s");
protected override (Result resultCode, string message) VerifyTestCase(object settings)
{
if (foundResult is null)
{
return (Result.NotPerformed, "Test not performed. Internal error.");
}
else
{
if (foundResult != expectedResult.HasValue)
{
return (Result.WrongResult, foundResult.Value ? "Zwrócono, że rozwiązanie istnieje, choć tak nie jest" : "Zwrócono, że rozwiązanie nie istnieje mimo, że w rzeczywistośći istnieje");
}
else
{
if (resultPath is null)
{
return (Result.WrongResult, "Tablica z rozwiązaniem jest nullem");
}
else
{
if (!expectedResult.HasValue)
{
if (resultPath.Length == 0)
{
return OkResult("OK.");
}
else
{
return (Result.WrongResult, $"Tablica z rozwiązaniem powinna mieć długość 0, a ma {resultPath.Length}");
}
}
else
{
return CheckPath(resultPath);
}
}
}
}
}
private (Result resultCode, string message) CheckPath(int[] path)
{
if (path.Length < 1)
{
return (Result.WrongResult, "Zwrócono tablicę o długości 0, a rozwiązanie istnieje");
}
else
{
if (!this.PossibleStarts.Contains(path[0]))
{
return (Result.WrongResult, $"Pierwszym elementem ścieżki nie jest wierzchołek ze zbioru [{String.Join(",", PossibleStarts)}], a wierzchołek {path[0]}");
}
else if (path.Last() != end)
{
return (Result.WrongResult, $"Ostatnim elementem ścieżki nie jest {end}, a wierzchołek {path.Last()}");
}
else
{
string resultMsg = null;
int costSum = path.Length - 1; // Liczba krawędzi
for (int i = 0; i < path.Length - 2 && resultMsg is null; i++)
{
var u = path[i];
var v = path[i + 1];
var w = path[i + 2];
if (!g.HasEdge(u, v))
{
resultMsg = $"Rozwiązanie zawiera przejście z {u} do {v}, choć w grafie g nie ma takiej krawędzi";
}
else if (!g.HasEdge(v, w))
{
resultMsg = $"Rozwiązanie zawiera przejście z {v} do {w}, choć w grafie g nie ma takiej krawędzi";
}
else
{
var color1 = g.GetEdgeWeight(u, v);
var color2 = g.GetEdgeWeight(v, w);
if (color1 != color2 && !c.HasEdge(color1, color2))
{
resultMsg = $"W rozwiązaniu jest przejście {u}->{v} w kolorze {color1}, a następnie {v}->{w} w kolorze {color2}, ale w grafie c nie ma krawędzi {color1}->{color2}";
}
else if (color1 != color2)
{
costSum += c.GetEdgeWeight(color1, color2);
}
}
}
if (resultMsg is null)
{
if (CheckResultValue && (costSum != expectedResult.Value || costSum != foundResultCost))
{
return (Result.WrongResult, $"Wysiłek zwróconej trasy to {costSum}, wartość zwrócona to {foundResultCost}, a powinno być {expectedResult.Value}");
}
else
{
return OkResult("OK");
}
}
else
{
return (Result.WrongResult, resultMsg);
}
}
}
}
}
class Lab06Tests : TestModule
{
public TestSet stage1Tests;
public TestSet stage2Tests;
public override void PrepareTestSets()
{
stage1Tests = new TestSet(new Lab06(), "Etap 1");
stage2Tests = new TestSet(new Lab06(), "Etap 2");
TestSets["Etap 1"] = stage1Tests;
TestSets["Etap 2"] = stage2Tests;
PrepareStage1();
}
private void PrepareStage1()
{
{//Test 1
Graph<int> g = new Graph<int>(5);
g.AddEdge(0, 1, 0);
g.AddEdge(1, 2, 1);
g.AddEdge(2, 4, 2);
g.AddEdge(0, 3, 0);
g.AddEdge(3, 4, 2);
DiGraph<int> c = new DiGraph<int>(3);
c.AddEdge(0, 1, 1);
c.AddEdge(1, 2, 1);
const int Start = 0;
const int End = 4;
const int ExpectedResult = 5;
stage1Tests.TestCases.Add(new Lab06Stage1Case(c, g, Start, End, ExpectedResult, 1, "Przykład 1"));
stage2Tests.TestCases.Add(new Lab06Stage2Case(c, g, Start, End, ExpectedResult, 1, "Przykład 1"));
}
{//Test 2
Graph<int> g = new Graph<int>(5);
g.AddEdge(0, 1, 0);
g.AddEdge(1, 2, 1);
g.AddEdge(2, 3, 2);
g.AddEdge(3, 1, 2);
g.AddEdge(1, 4, 3);
DiGraph<int> c = new DiGraph<int>(4);
c.AddEdge(0, 1, 1);
c.AddEdge(1, 2, 1);
c.AddEdge(2, 3, 0);
const int Start = 0;
const int End = 4;
const int ExpectedResult = 7;
stage1Tests.TestCases.Add(new Lab06Stage1Case(c, g, Start, End, ExpectedResult, 1, "Przykład 2"));
stage2Tests.TestCases.Add(new Lab06Stage2Case(c, g, Start, End, ExpectedResult, 1, "Przykład 2"));
}
{//Test 3
Graph<int> g = new Graph<int>(5);
g.AddEdge(0, 1, 0);
g.AddEdge(1, 2, 1);
g.AddEdge(1, 4, 2);
DiGraph<int> c = new DiGraph<int>(3);
c.AddEdge(0, 1, 1);
c.AddEdge(1, 2, 1);
c.AddEdge(0, 2, 5);
const int Start = 0;
const int End = 4;
const int ExpectedResult = 6;
stage1Tests.TestCases.Add(new Lab06Stage1Case(c, g, Start, End, ExpectedResult, 1, "Przykład 3"));
stage2Tests.TestCases.Add(new Lab06Stage2Case(c, g, Start, End, ExpectedResult, 1, "Przykład 3"));
}
{//Test 4
Graph<int> g = new Graph<int>(7);
g.AddEdge(0, 1, 0);
g.AddEdge(1, 2, 1);
g.AddEdge(2, 3, 2);
g.AddEdge(3, 1, 2);
g.AddEdge(1, 4, 3);
g.AddEdge(1, 5, 4);
g.AddEdge(1, 6, 5);
DiGraph<int> c = new DiGraph<int>(6);
c.AddEdge(0, 1, 1);
c.AddEdge(1, 2, 1);
c.AddEdge(2, 3, 1);
c.AddEdge(3, 4, 1);
c.AddEdge(4, 5, 1);
const int Start = 0;
const int End = 6;
const int ExpectedResult = 14;
stage1Tests.TestCases.Add(new Lab06Stage1Case(c, g, Start, End, ExpectedResult, 1, "Przykład 4"));
stage2Tests.TestCases.Add(new Lab06Stage2Case(c, g, Start, End, ExpectedResult, 1, "Przykład 4"));
}
{//Test 5
Graph<int> g = new Graph<int>(5);
DiGraph<int> c = new DiGraph<int>(5);
g.AddEdge(0, 1, 0);
g.AddEdge(1, 2, 1);
g.AddEdge(2, 4, 4);
g.AddEdge(0, 3, 0);
g.AddEdge(3, 4, 2);
c.AddEdge(0, 1, 1);
c.AddEdge(1, 2, 1);
c.AddEdge(2, 3, 1);
const int Start = 0;
const int End = 4;
int? ExpectedResult = null;
stage1Tests.TestCases.Add(new Lab06Stage1Case(c, g, Start, End, ExpectedResult, 1, "Cykl -- niemożliwe zmiany kolorów"));
stage2Tests.TestCases.Add(new Lab06Stage2Case(c, g, Start, End, ExpectedResult, 1, "Cykl -- niemożliwe zmiany kolorow"));
}
{//Test 6
int w = 4;
int h = 3;
DiGraph<int> c = new DiGraph<int>(1);
Graph<int> g = GridGraph(w, h);
int start = 0;
int end = w * h - 1;
const int ExpectedResult = 5;
stage1Tests.TestCases.Add(new Lab06Stage1Case(c, g, start, end, ExpectedResult, 1, "Jednokolorowa siatka 4×3"));
stage2Tests.TestCases.Add(new Lab06Stage2Case(c, g, start, end, ExpectedResult, 1, "Jednokolorowa siatka 4×3"));
}
AddGridTest(11, 10, 1, 1);//Test 7
AddGridTest(111, 110, 3, 12);//Test 8
AddTreeBasedTest(5, 2, 5, 3, 8);//Test 9
AddRandomTest(150, 10, 4523, 2, 1, 8); // Test 10
AddRandomTest(150, 100, 1337, 5, 1, 8); // Test 11
{//Test 12
Graph<int> g = new Graph<int>(5);
g.AddEdge(0, 1, 0);
g.AddEdge(1, 2, 1);
g.AddEdge(2, 4, 2);
g.AddEdge(0, 3, 0);
g.AddEdge(3, 4, 2);
DiGraph<int> c = new DiGraph<int>(3);
c.AddEdge(1, 0, 1);
c.AddEdge(2, 1, 1);
const int Start = 0;
const int End = 4;
int? ExpectedResult = null;
stage1Tests.TestCases.Add(new Lab06Stage1Case(c, g, Start, End, ExpectedResult, 1, "Przykład 1 z odwróconymi krawędziami grafu c"));
stage2Tests.TestCases.Add(new Lab06Stage2Case(c, g, Start, End, ExpectedResult, 1, "Przykład 1 z odwróconymi krawędziami grafu c"));
}
{//Test 13
Graph<int> g = new Graph<int>(7);
g.AddEdge(0, 1, 0);
g.AddEdge(1, 2, 1);
g.AddEdge(2, 3, 2);
g.AddEdge(3, 1, 2);
g.AddEdge(1, 4, 3);
g.AddEdge(1, 5, 4);
g.AddEdge(1, 6, 5);
DiGraph<int> c = new DiGraph<int>(6);
c.AddEdge(1, 0, 1);
c.AddEdge(2, 1, 1);
c.AddEdge(3, 2, 1);
c.AddEdge(4, 3, 1);
c.AddEdge(5, 4, 1);
const int Start = 0;
const int End = 6;
int? ExpectedResult = null;
stage1Tests.TestCases.Add(new Lab06Stage1Case(c, g, Start, End, ExpectedResult, 1, "Przykład 4 z odwróconymi krawędziami grafu c"));
stage2Tests.TestCases.Add(new Lab06Stage2Case(c, g, Start, End, ExpectedResult, 1, "Przykład 4 z odwróconymi krawędziami grafu c"));
}
{//Test 14
int w = 4;
int h = 3;
DiGraph<int> c = new DiGraph<int>(30);
for (int i = 0; i < c.VertexCount; i++)
{
for (int j = 0; j < c.VertexCount; j++)
{
if (i != j)
{
c.AddEdge(i, j, 1);
}
}
}
Graph<int> g = GridGraph(w, h);
int start = 0;
int end = w * h - 1;
const int ExpectedResult = 5;
stage1Tests.TestCases.Add(new Lab06Stage1Case(c, g, start, end, ExpectedResult, 1, "Jednokolorowa siatka 4×3, dużo kolorów w grafie c"));
stage2Tests.TestCases.Add(new Lab06Stage2Case(c, g, start, end, ExpectedResult, 1, "Jednokolorowa siatka 4×3, dużo kolorów w grafie c"));
}
{//Test 15
int w = 4;
int h = 3;
DiGraph<int> c = new DiGraph<int>(30);
for (int i = 0; i < c.VertexCount; i++)
{
for (int j = 0; j < c.VertexCount; j++)
{
if (i != j)
{
c.AddEdge(i, j, 1);
}
}
}
Graph<int> g = GridGraphMulticolor(w, h, c.VertexCount);
int start = 0;
int end = w * h - 1;
const int ExpectedResult = 7;
stage1Tests.TestCases.Add(new Lab06Stage1Case(c, g, start, end, ExpectedResult, 1, "Wielokolorowa siatka 4×3, dużo kolorów w grafie c"));
stage2Tests.TestCases.Add(new Lab06Stage2Case(c, g, start, end, ExpectedResult, 1, "Wielokolorowa siatka 4×3, dużo kolorów w grafie c"));
}
AddMultiinputGridTest(11, 10, 1, 1); // Test 16
AddMultiinputGridTest(111, 110, 1, 12); //Test 17
}
private void AddRandomTest(int gSize, int cSize, int seed, int? expectedResult, double timeLimitS1, double timeLimitS2)
{
var rgg = new RandomGraphGenerator(seed);
Graph prawieG = rgg.Graph(gSize, 0.2);
Graph<int> g = rgg.AssignWeights(prawieG, 0, cSize - 1);
DiGraph prawieC = rgg.DiGraph(cSize, 0.4);
DiGraph<int> c = rgg.AssignWeights(prawieC, 0, 15);
int start = 0;
int end = 1;
stage1Tests.TestCases.Add(new Lab06Stage1Case(c, g, start, end, expectedResult, timeLimitS1, $"Losowy graf, seed {seed}"));
stage2Tests.TestCases.Add(new Lab06Stage2Case(c, g, start, end, expectedResult, timeLimitS2, $"Losowy graf, seed {seed}"));
}
private void AddGridTest(int w, int h, double timeLimitS1, double timeLimitS2)
{
string name = $"Siatka {w}×{h} wierzchołków, kolory dopuszczają tylko przejście zygzakiem przez siatkę";
DiGraph<int> c = new DiGraph<int>(h + 1);
c.AddEdge(0, 1, 1);
c.AddEdge(1, 0, 1);
for (int i = 2; i < h; i++)
{
for (int j = i + 1; j < h; j++)
{
c.AddEdge(i, j, 0);
c.AddEdge(j, i, 0);
}
}
Graph<int> g = new Graph<int>(w * h);
int vertexId(int x, int y) => x + y * w;
for (int i = 0; i < w; i++)
{
for (int j = 0; j < h - 1; j++)
{
g.AddEdge(vertexId(i, j), vertexId(i, j + 1), 0);
}
}
for (int i = 0; i < w - 1; i++)
{
for (int j = 0; j < h; j++)
{
g.AddEdge(vertexId(i, j), vertexId(i + 1, j), i % 2 == 0 ? h - j : j + 1);
}
}
int start = 0;
int end = w * h - 1; // Tylko jeśli w jest nieparzyste
int ExpectedResult = w * h - 1 + 2 * (w - 1);
stage1Tests.TestCases.Add(new Lab06Stage1Case(c, g, start, end, ExpectedResult, timeLimitS1, name));
stage2Tests.TestCases.Add(new Lab06Stage2Case(c, g, start, end, ExpectedResult, timeLimitS2, name));
}
private void AddMultiinputGridTest(int w, int h, double timeLimitS1, double timeLimitS2)
{
string name = $"Siatka {w}×{h} wierzchołków, kolory dopuszczają tylko przejście zygzakiem przez siatkę, wejśćia na lewej krawędzi";
DiGraph<int> c = new DiGraph<int>(h + 1);
c.AddEdge(0, 1, 1);
c.AddEdge(1, 0, 1);
for (int i = 2; i < h; i++)
{
for (int j = i + 1; j < h; j++)
{
c.AddEdge(i, j, 0);
c.AddEdge(j, i, 0);
}
}
Graph<int> g = new Graph<int>(w * h);
int vertexId(int x, int y) => x + y * w;
for (int i = 0; i < w; i++)
{
for (int j = 0; j < h - 1; j++)
{
g.AddEdge(vertexId(i, j), vertexId(i, j + 1), 0);
}
}
for (int i = 0; i < w - 1; i++)
{
for (int j = 0; j < h; j++)
{
g.AddEdge(vertexId(i, j), vertexId(i + 1, j), i % 2 == 0 ? h - j : j + 1);
}
}
int[] starts = Enumerable.Range(0, w).ToArray();
int end = w * h - 1; // Tylko jeśli w jest nieparzyste
int ExpectedResult = h - 1;
stage2Tests.TestCases.Add(new Lab06Stage2Case(c, g, starts, end, ExpectedResult, timeLimitS2, name));
}
private void AddTreeBasedTest(int branching, int shift, int depth, double timeLimitS1, double timeLimitS2)
{
string name = $"Graf oparty o drzewo, branching {branching}, głębokość {depth}";
Graph<int> g = new Graph<int>((1 - (int)Math.Pow(branching, depth)) / (1 - branching) + 1);
DiGraph<int> c = new DiGraph<int>((int)Math.Pow(branching, depth - 1) + 1);
int zeroidx = shift % (int)Math.Pow(branching, depth - 1);
for (int level = depth - 1; level > 0; level--)
{
int levelOffset = (1 - (int)Math.Pow(branching, level) / (1 - branching)) - 1;
int prevLevelOffset = (1 - (int)Math.Pow(branching, level - 1) / (1 - branching)) - 1;
int levelSize = (int)Math.Pow(branching, level);
for (int i = 0; i < levelSize; i++)
{
g.AddEdge(i + levelOffset, prevLevelOffset + (i / branching), (depth - level) + (levelSize - zeroidx + i) % levelSize);
}
zeroidx /= 3;
}
int leavesCount = (1 - (int)Math.Pow(branching, depth - 1) / (1 - branching));
int lastLevelOffset = (1 - (int)Math.Pow(branching, depth - 1) / (1 - branching)) - 1;
for (int i = 0; i < leavesCount; i++)
{
g.AddEdge(i + lastLevelOffset, g.VertexCount - 1, 0);
}
for (int i = 0; i < c.VertexCount; i++)
{
for (int j = 0; j < c.VertexCount; j++)
{
if (i != j)
{
c.AddEdge(i, j, Math.Abs(i - j));
}
}
}
int start = 0;
int end = g.VertexCount - 1;
int expectedResult = depth * 2 - 1;
stage1Tests.TestCases.Add(new Lab06Stage1Case(c, g, start, end, expectedResult, timeLimitS1, name));
stage2Tests.TestCases.Add(new Lab06Stage2Case(c, g, start, end, expectedResult, timeLimitS2, name));
}
private static Graph<int> GridGraph(int w, int h)
{
Graph<int> g = new Graph<int>(w * h);
for (int i = 0; i < w; i++)
{
for (int j = 1; j < h; j++)
{
g.AddEdge(i + (j - 1) * w, i + j * w, 0);
}
}
for (int i = 1; i < w; i++)
{
for (int j = 0; j < h; j++)
{
g.AddEdge(i - 1 + j * w, i + j * w, 0);
}
}
return g;
}
private static Graph<int> GridGraphMulticolor(int w, int h, int c)
{
Graph<int> g = new Graph<int>(w * h);
for (int i = 0; i < w; i++)
{
for (int j = 1; j < h; j++)
{
g.AddEdge(i + (j - 1) * w, i + j * w, (i + j * w) % c);
}
}
for (int i = 1; i < w; i++)
{
for (int j = 0; j < h; j++)
{
g.AddEdge(i - 1 + j * w, i + j * w, 0);
}
}
return g;
}
public override double ScoreResult()
{
if (stage1Tests.FailedCount > 0 || stage1Tests.TimeoutsCount > 0 || stage1Tests.LowEfficiencyCount > 0 ||
stage2Tests.FailedCount > 0 || stage2Tests.TimeoutsCount > 0 || stage2Tests.LowEfficiencyCount > 0)
{
return -2.5;
}
else
{
return 2.5;
}
}
}
class Program
{
public static void Main(string[] args)
{
var tests = new Lab06Tests();
tests.PrepareTestSets();
foreach (var ts in tests.TestSets)
{
ts.Value.PerformTests(verbose: true, checkTimeLimit: false);
}
}
}
}