-
Notifications
You must be signed in to change notification settings - Fork 1
/
Usage.java
1384 lines (1247 loc) · 72.1 KB
/
Usage.java
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
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package DOEMatrixGen;
import DOEMatrixGen.MathsContxtLAv0_1_Prod.DiffExpr;
import DOEMatrixGen.MathsContxtLAv0_1_Prod.Expression;
import DOEMatrixGen.MathsContxtLAv0_1_Prod.FoG;
import DOEMatrixGen.MathsContxtLAv0_1_Prod.IntegrExpr;
import static DOEMatrixGen.MathsContxtLAv0_1_Prod.MyFuncDiff;
import static DOEMatrixGen.MathsContxtLAv0_1_Prod.MyFuncExpress;
import static DOEMatrixGen.MathsContxtLAv0_1_Prod.MyFuncIntegr;
import static DOEMatrixGen.MathsContxtLAv0_1_Prod.MyFuncSimple;
import DOEMatrixGen.MathsContxtLAv0_1_Prod.OrderVar;
import DOEMatrixGen.MathsContxtLAv0_1_Prod.Predicate;
import DOEMatrixGen.MathsContxtLAv0_1_Prod.SimpleAlgebra;
import DOEMatrixGen.MathsContxtLAv0_1_Prod.SimpleExpression;
import static DOEMatrixGen.MathsContxtLAv0_1_Prod.eatAll;
import static DOEMatrixGen.MathsContxtLAv0_1_Prod.parse;
import static DOEMatrixGen.MathsContxtLAv0_1_Prod.parseAlgebra;
import static DOEMatrixGen.MathsContxtLAv0_1_Prod.parseDiff;
import static DOEMatrixGen.MathsContxtLAv0_1_Prod.parseFoG;
import static DOEMatrixGen.MathsContxtLAv0_1_Prod.parseIntegr;
import static DOEMatrixGen.MathsContxtLAv0_1_Prod.parseOrder;
import static DOEMatrixGen.MathsContxtLAv0_1_Prod.parsePredicate;
import static DOEMatrixGen.MathsContxtLAv0_1_Prod.parseSimple;
import static DOEMatrixGen.MathsContxtLAv0_1_Prod.variablesDiff;
import static DOEMatrixGen.TestHarness.PassFailTestCaseString;
import static DOEMatrixGen.TestHarness.PassFailTestCaseValue;
import static DOEMatrixGen.TestHarness.TestPredicate;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Scanner;
import org.apache.log4j.Logger;
/**
*
* @author Administrator
*/
public class Usage {
public static Logger log = Logger.getLogger(Usage.class.getName());
public static String DiffWithRespTo = "x";
public static int MaxDiffOrder = 6;
public static int MaxIntegreOrder = 6;
static String EqnUnderTest;
// Differentiation Mapping
static String[] EqnSolArrayMap1;
static String[] EqnSolArrayDiffAlone;
static String[] EqnSolArrayMap2;
// Integration Mapping
static String[] EqnSolArrayMap3;
static String[] EqnSolArrayIntegrAlone;
static String[] EqnSolArrayMap4;
static String[] EqnSolArrayIntegr_BeforeDiff;
static String[] EqnSolArrayDiff_AfterIntegr;
static String[] EqnSolArrayDiff_BeforeIntegr;
static String[] EqnSolArrayIntegr_AfterDiff;
static int[] EqnSolOrder;
static int TestCase = 0;
static int EndTestCase = 0;
static int LastTestCaseHarness=0;
static int TestCaseLoopTimes = 0;
static String EqnRegressionDiffStatus = "All RED";
static String EqnRegressionIntegreStatus = "All RED";
static String TestCaseName = "Standard";
static String TestCaseMatrixID = "Standard";
public static String FailingTestHarnessDiff(String AlgoName,int j) {
//Equation Component Testing
//1) Variables :L=3:Single Letter, Multi Letter, with Numerics
//2) Coefficient:L=9:0.0,0,1.0,1,-1.0,-1,5,-5,-5.0
//3) Exponent:L=6: +ve,-ve,0,1,Independent Constants, Long Form (x * x*x)
//4) Operator:L=2: *,/
//5) Constants:L=3: Start of Expr, Middle (2-5) Terms, End Term
//6) Independent Constants:L=3:Single Letter, Multi Letter, with Numerics
//7) Expression
//8) Term:L=3: Start Term, Middle (2-5) Terms, End Term
//9) Term Sign:L=3: +ve, -ve, No Sign
//10) Exponent Sign:L=3: +ve, -ve, No Sign
//11) Coefficient Sign:L=3: +ve, -ve, No Sign
//12) Variable Sign:L=3: +ve, -ve, No Sign
//13) Parenthesis:L=3 : 1st Term, 2nd Term , 3-5 Terms
//14) Functions:L5: Sin, Cos, Tan, Log, Ln
//15) Argument of Functions:L=4: Expr Alone(3 types), Expr with Inner Function
if((j >= 100)&&(j <= 105))
TestHarness.SanityTestCases(AlgoName,j);
else if((j >= 5019)&&(j <= 5042))
TestHarnessUnitTest.UnitTestCases(AlgoName,j);
//
// Variants
//
else if ((j >= 10001)&&(j <= 10005))
TestHarnessNames.Names(j);
else if((j >= 20001)&&(j <= 20092))
TestHarnessCoefficients.Coefficients(AlgoName,j);
else if((j >= 30001)&&(j <= 30011))
TestHarness.Exponent(AlgoName,j);
else if((j >= 40001)&&(j <= 40034))
TestHarnessSignedX.SignedX(AlgoName,j);
else if((j >= 50001)&&(j <= 50029))
TestHarnessIndConstant.IndConstant(AlgoName,j);
else if((j >= 80001)&&(j <= 80012))
TestHarness.Parenthesis(AlgoName,j);
else if((j >= 110001)&&(j <= 110007))
TestHarness.SoftwareEngg(AlgoName,j);
else {
switch (j) {
//Function Test Cases
case 90001:
TestHarness.TestCaseDiff90001();
break;
//Function Argument Test Cases
case 100001:
TestHarness.TestCaseDiff100001();
break;
default:
System.out.println(ConsoleColors.RED +"FailingTestHarnessDiff:j= " + j + ": Infinite Loop"+ ConsoleColors.RESET);
break;
}
}
return EqnUnderTest;
}
public static void mainPredicate(String[] args) {
Map<String, Double> variables = new HashMap<>();
String Exprn = TestPredicate();
String DiffWithRespTo = "x";
Predicate expValue;
MyFuncExpress();
Exprn = eatAll(Exprn, ' ');
int i = 1;
for (double x = -2, y = 7; i < 10; y++, x++, i++) {
variables.put("x", x);
variables.put("y", y);
System.out.println("main: x=" + x + " Exprn=" + Exprn);
expValue = parsePredicate(Exprn, variables);
System.out.println(" main:Result(Simplified Diff Value)=" + expValue.eval());
System.out.print(System.lineSeparator());
}
}
public static void mainDiff(String... args) {
Map<String, Double> variables = new HashMap<>();
Map<String, String> variablesDiff = new HashMap<>();
//String Exprn = eatAll(TestCases(), ' ');
//String Exprn = eatAll(HighLevelUnitTestCases(), ' ');
//String Exprn = eatAll(FailingHighLevelUnitTestCases(), ' ');
String Exprn = "";//eatAll(FailingLowLevelUnitTestCases(), ' ');
SimpleExpression expSimple;
Expression expValue;
DiffExpr exp;
MyFuncExpress();
MyFuncDiff();
MyFuncSimple();
String DiffWithRespTo = "x";
String Constant = "C";
//String DiffWithRespTo = "Xn";
variablesDiff.put(DiffWithRespTo, DiffWithRespTo);
String StrexpSimpleExpress = "";
int i = 1;
for (double x = 1, y = 7; i < 5; y++, x++, i++) {
variables.put(DiffWithRespTo, x);
variables.put("y", y);
variables.put(Constant, 5.0);
System.out.println("main: x=" + x + " Exprn=" + Exprn);
expSimple = parseSimple(Exprn, variables, variablesDiff, DiffWithRespTo);
expValue = parse(Exprn, variables, DiffWithRespTo);
System.out.println(" main:Result(Expn Value)=" + expValue.eval());
StrexpSimpleExpress = expSimple.SimpleExpr();
System.out.println("main: x=" + x + " Basic Simple Exprn=" + StrexpSimpleExpress);
expValue = parse(StrexpSimpleExpress, variables, DiffWithRespTo);
System.out.println("main: x=" + x + " Basic Simple (Exprn Value)=" + expValue.eval());
exp = parseDiff(Exprn, variables, variablesDiff, DiffWithRespTo);
StrexpSimpleExpress = exp.DiffExpr();
System.out.println(" main:Result(Diff Equation)(" + i + " th order)=> " + StrexpSimpleExpress);
expValue = parse(StrexpSimpleExpress, variables, DiffWithRespTo);
System.out.println(" main:Result(Diff Value)=" + expValue.eval());
expSimple = parseSimple(StrexpSimpleExpress, variables, variablesDiff, DiffWithRespTo);
StrexpSimpleExpress = expSimple.SimpleExpr();
System.out.println(" main:Result(Simplified Diff Equation)(" + i + " th order)=> " + StrexpSimpleExpress);
expValue = parse(StrexpSimpleExpress, variables, DiffWithRespTo);
System.out.println(" main:Result(Simplified Diff Value)=" + expValue.eval());
System.out.print(System.lineSeparator());
expValue = parse(Exprn, variables, DiffWithRespTo);
System.out.println(" main:Result(Expn Value)=" + expValue.eval());
Exprn = StrexpSimpleExpress;
}
}
public static void mainIntegral(String... args) {
Map<String, Double> variables = new HashMap<>();
Map<String, String> variablesIntegr = new HashMap<>();
//String Exprn = eatAll(TestCases(), ' ');
//String Exprn = eatAll(HighLevelUnitTestCases(), ' ');
//String Exprn = eatAll(FailingHighLevelUnitTestCases(), ' ');
String Exprn = "";//eatAll(FailingLowLevelUnitTestCases(), ' ');
SimpleExpression expSimple;
Expression expValue;
IntegrExpr expIntgr;
MyFuncExpress();
MyFuncSimple();
MyFuncIntegr();
String DiffWithRespTo = "x";
String Constant = "C";
//String DiffWithRespTo = "Xn";
String StrexpIntegrExpress = "";
String StrexpSimpleExpress = "";
variablesIntegr.put(DiffWithRespTo, DiffWithRespTo);
variablesIntegr.put(Constant, Constant);
StrexpIntegrExpress = Exprn;
int i = 1;
for (double x = -20, y = 7; i < 2; y++, x++, i++) {
variables.put(DiffWithRespTo, x);
variables.put("y", y);
variables.put(Constant, 5.0);
System.out.println("main: x=" + x + " Basic Simple Exprn=" + StrexpIntegrExpress);
expValue = parse(StrexpIntegrExpress, variables, DiffWithRespTo);
System.out.println("main: x=" + x + " Basic Simple (Exprn Value)=" + expValue.eval());
expIntgr = parseIntegr(StrexpIntegrExpress, variables, variablesDiff, DiffWithRespTo);
StrexpIntegrExpress = expIntgr.IntegrExpr();
System.out.println(" main:Result(Integral Equation)(" + i + " th order)=> " + StrexpIntegrExpress);
expValue = parse(StrexpIntegrExpress, variables, DiffWithRespTo);
System.out.println(" main:Result(Integral Value)=" + expValue.eval());
expSimple = parseSimple(StrexpIntegrExpress, variables, variablesDiff, DiffWithRespTo);
StrexpIntegrExpress = expSimple.SimpleExpr();
System.out.println(" main:Result(Simplified Integral Equation)(" + i + " th order)=> " + StrexpIntegrExpress);
expValue = parse(StrexpIntegrExpress, variables, DiffWithRespTo);
System.out.println(" main:Result(Simplified Integral Value)=" + expValue.eval());
expValue = parse(Exprn, variables, DiffWithRespTo);
System.out.println(" main:Result(Expn Value)=" + expValue.eval());
System.out.print(System.lineSeparator());
}
}
public static void mainDiffIntegral(String[] args) {
Map<String, Double> variables = new HashMap<>();
Map<String, String> variablesDiff = new HashMap<>();
Map<String, String> variablesIntegr = new HashMap<>();
//String Exprn = eatAll(TestCases(), ' ');
//String Exprn = eatAll(HighLevelUnitTestCases(), ' ');
//String Exprn = eatAll(FailingHighLevelUnitTestCases(), ' ');
String Exprn = "";//eatAll(FailingLowLevelUnitTestCases(), ' ');
SimpleExpression expSimple;
Expression expValue;
DiffExpr exp;
IntegrExpr expIntgr;
MyFuncExpress();
MyFuncDiff();
MyFuncSimple();
MyFuncIntegr();
String DiffWithRespTo = "x";
String Constant = "C";
//String DiffWithRespTo = "Xn";
variablesDiff.put(DiffWithRespTo, DiffWithRespTo);
String StrexpIntegrExpress = "";
String StrexpSimpleExpress = "";
variablesIntegr.put(DiffWithRespTo, DiffWithRespTo);
variablesIntegr.put(Constant, Constant);
int i = 1;
for (double x = -20, y = 7; i < 14; y++, x++, i++) {
variables.put(DiffWithRespTo, x);
variables.put("y", y);
variables.put(Constant, 5.0);
for (int j = 1; j <= i; j++) {
System.out.println("main: x=" + x + " Exprn=" + Exprn);
expSimple = parseSimple(Exprn, variables, variablesDiff, DiffWithRespTo);
expValue = parse(Exprn, variables, DiffWithRespTo);
System.out.println(" main:Result(Expn Value)=" + expValue.eval());
StrexpSimpleExpress = expSimple.SimpleExpr();
System.out.println("main: x=" + x + " Basic Simple Exprn=" + StrexpSimpleExpress);
expValue = parse(StrexpSimpleExpress, variables, DiffWithRespTo);
System.out.println("main: x=" + x + " Basic Simple (Exprn Value)=" + expValue.eval());
exp = parseDiff(StrexpSimpleExpress, variables, variablesDiff, DiffWithRespTo);
StrexpSimpleExpress = exp.DiffExpr();
System.out.println(" main:Result(Diff Equation)(" + j + " th order)=> " + StrexpSimpleExpress);
expValue = parse(StrexpSimpleExpress, variables, DiffWithRespTo);
System.out.println(" main:Result(Diff Value)=" + expValue.eval());
expSimple = parseSimple(StrexpSimpleExpress, variables, variablesDiff, DiffWithRespTo);
StrexpSimpleExpress = expSimple.SimpleExpr();
System.out.println(" main:Result(Simplified Diff Equation)(" + i + " th order)=> " + StrexpSimpleExpress);
expValue = parse(StrexpSimpleExpress, variables, DiffWithRespTo);
System.out.println(" main:Result(Simplified Diff Value)=" + expValue.eval());
System.out.print(System.lineSeparator());
expValue = parse(Exprn, variables, DiffWithRespTo);
System.out.println(" main:Result(Expn Value)=" + expValue.eval());
Exprn = StrexpSimpleExpress;
}
StrexpIntegrExpress = StrexpSimpleExpress;
for (int j = 1; j <= i; j++) {
System.out.println("main: x=" + x + " Basic Simple Exprn=" + StrexpIntegrExpress);
expValue = parse(StrexpIntegrExpress, variables, DiffWithRespTo);
System.out.println("main: x=" + x + " Basic Simple (Exprn Value)=" + expValue.eval());
expIntgr = parseIntegr(StrexpIntegrExpress, variables, variablesDiff, DiffWithRespTo);
StrexpIntegrExpress = expIntgr.IntegrExpr();
System.out.println(" main:Result(Integral Equation)(" + j + " th order)=> " + StrexpIntegrExpress);
expValue = parse(StrexpIntegrExpress, variables, DiffWithRespTo);
System.out.println(" main:Result(Integral Value)=" + expValue.eval());
expSimple = parseSimple(StrexpIntegrExpress, variables, variablesDiff, DiffWithRespTo);
StrexpIntegrExpress = expSimple.SimpleExpr();
System.out.println(" main:Result(Simplified Integral Equation)(" + i + " th order)=> " + StrexpIntegrExpress);
expValue = parse(StrexpIntegrExpress, variables, DiffWithRespTo);
System.out.println(" main:Result(Simplified Integral Value)=" + expValue.eval());
expValue = parse(Exprn, variables, DiffWithRespTo);
System.out.println(" main:Result(Expn Value)=" + expValue.eval());
System.out.print(System.lineSeparator());
}
Exprn = StrexpIntegrExpress;
}
}
public static String RandomEquation(String a, String c, String RandVar) {
String Exprn = a + " * " + RandVar + "^7" + " + " + RandVar + "^5" + " + " + RandVar + "^2" + " - " + RandVar + " + " + c;
Exprn = eatAll(Exprn, ' ');
return Exprn;
}
public static String BrownianMotionEquation(String N, String ETA, String r, String R, String T, String x, String t, String RandVar) {
String Exprn = N + "*" + "sqrt((3*" + N + "*" + ETA + "*" + r + ")/(2*" + R + "*" + T + "))" + "*" + "exp((-3*" + Math.PI + "*" + ETA + "*" + N + "*" + r + "*" + x + "^2)/(2*" + R + "*" + T + "*" + t + "))";
Exprn = eatAll(Exprn, ' ');
return Exprn;
}
public static String FormEquation(long Xn,long MgtACoeff, long Mgtc, long MgtbCoeff,String TechDiffWithRespTo, int MgtMaxExponent) {
//if(Xn==0) MaxExponent=5;
//else MaxExponent=(int)Xn;
long bCoeffStore=MgtbCoeff;
//log.fatal("FormEquation: MgtbCoeff=" + MgtbCoeff );
String Exprn = MgtACoeff + " * " + TechDiffWithRespTo + "^" + (MgtMaxExponent );
for (int i = MgtMaxExponent - 1; i > 1; i--) {
if(MgtbCoeff >2)
Exprn = Exprn + " + " + MgtbCoeff + "*" + TechDiffWithRespTo + "^" + i;
else {
Exprn = Exprn + " + " + MgtbCoeff + "*" + TechDiffWithRespTo + "^" + i;
MgtbCoeff=bCoeffStore;
}
//MgtbCoeff=GetPrimeNumber(MgtbCoeff,i);
MgtbCoeff++;
//log.fatal("FormEquation: MgtbCoeff=" + MgtbCoeff + " i=" + i);
}
if(MgtbCoeff > 2)
Exprn =Exprn + " + " + MgtbCoeff + "*" + TechDiffWithRespTo;
else
Exprn =Exprn + " + " + TechDiffWithRespTo;
Exprn = Exprn + " + " + Mgtc;
Exprn = eatAll(Exprn, ' ');
log.warn("FormEquation:Exprn=" + Exprn);
return Exprn;
}
public static void mainRegresssionDiffTest(int MaxOrder, TestHarness TestData) {
String Exprn = "";
Map<String, Double> variables = new HashMap<>();
Map<String, String> variablesDiff = new HashMap<>();
//String Exprn = eatAll(TestCases(), ' ');
//String Exprn = eatAll(HighLevelUnitTestCases(), ' ');
//String Exprn = eatAll(FailingHighLevelUnitTestCases(), ' ');
//String Exprn = eatAll(FailingLowLevelUnitTestCases(), ' ');
//Exprn = eatAll(Exprn, ' ');
SimpleExpression expSimple;
Expression expValue;
DiffExpr exp;
OrderVar expOrder;
MyFuncExpress();
MyFuncDiff();
MyFuncSimple();
String Constant = "C";
//String DiffWithRespTo = "Xn";
String StrexpSimpleExpressMap1 = "";
String StrexpDiffExpress = "";
String StrexpSimpleExpressMap2 = "";
String myOrder = "";
double ExprnexpValue = 0;
double DblexpValueMap1 = 0;
double DblexpDiffValue = 0;
double DblexpValueMap2 = 0;
int j = TestCase;
boolean TestCasePassStrFlag = false;
boolean TestCasePassValFlag = false;
boolean TestCasePassHighLevelFlag = true;
HashMap<Integer, String> FailedTestCases = new HashMap<Integer, String>();
HashMap<Integer, String> ExceptionTestCases = new HashMap<Integer, String>();
int MaxIndexFail = 0;
int MaxIndexExcept = 0;
int MaxOrder1 = MaxOrder;
int i = 1;
int TotalTestCases = 0;
String OverallRegressionStatus = "Diff:Pass All (5019 to 100001) Except Test Cases: "
+ "\n" + "TestCases:Unit Test Cases" + " All Passing"
+ "\n" + "TestCases:Names " + " All Passing"
+ "\n" + "TestCases:Coefficients " + " 20016 , 20017"
+ "\n" + "TestCases:Exponent " + " 30006 to 30008";
System.out.print(ConsoleColors.BLUE + "Diff Overall Regression Status" + OverallRegressionStatus + ConsoleColors.RESET);
System.out.print(System.lineSeparator());
if(EndTestCase > LastTestCaseHarness)
EndTestCase=LastTestCaseHarness;
while (j <= EndTestCase) {
EqnUnderTest = "";
String TempExprn = "";
TempExprn = FailingTestHarnessDiff("mainDiffTest",j);
if (MaxOrder == -1) {
MaxOrder1 = MaxDiffOrder; //From Test Case
} else if (MaxOrder >= MaxDiffOrder) {
MaxOrder1 = MaxDiffOrder;
} else {
MaxOrder1 = MaxOrder;
}
if ((!EqnUnderTest.equalsIgnoreCase("")) && (TempExprn != null) && (!TempExprn.equalsIgnoreCase(""))) {
Exprn = eatAll(TempExprn, ' ');
} else {
j = RegressionControl(j);
System.out.println(ConsoleColors.RED + "mainDiffTest: j=" + j + " TestCase=" + TestCase);
continue;
}
System.out.println(ConsoleColors.YELLOW + "Test Case " + TestCase + " EndTestCase=" + EndTestCase + " j=" + j + ConsoleColors.RESET);
System.out.println(ConsoleColors.BLUE + "Test Case " + TestCase + " Exprn=" + Exprn + ConsoleColors.RESET);
System.out.println(ConsoleColors.BLUE + "Test Case Name=" + TestCaseName + ConsoleColors.RESET);
System.out.println(ConsoleColors.BLUE + "Test Case Name=" + TestCaseMatrixID + ConsoleColors.RESET);
System.out.println(ConsoleColors.BLUE + "Regression Status : Test Case should be " + EqnRegressionDiffStatus + ConsoleColors.RESET);
i = 1;
TotalTestCases++;
TestCasePassHighLevelFlag=true;
String StageMapping = "";
variablesDiff.put(DiffWithRespTo, DiffWithRespTo);
try {
for (double x = 1, y = 7; i < MaxOrder1; y++, x++, i++) {
TestCasePassStrFlag = false;
TestCasePassValFlag = false;
variables.put(DiffWithRespTo, x);
variables.put("y", y);
variables.put("a", 1.0);
variables.put("b", 2.0);//variables.put("b", 0.0);
variables.put("c", -1.0);
variables.put("d", 2.0);
variables.put("p", 3.0);
variables.put("q", 0.0);
variables.put("r", -1.0);
variables.put("s", 2.0);
variables.put(Constant, 5.0);
StageMapping = "Basic Mapping";
expOrder = parseOrder(Exprn, DiffWithRespTo);
myOrder = expOrder.eval();
System.out.println("main: " + DiffWithRespTo + "=" + x + " Exprn=" + Exprn + " Order=" + myOrder);
expSimple = parseSimple(Exprn, variables, variablesDiff, DiffWithRespTo);
StrexpSimpleExpressMap1 = expSimple.SimpleExpr();
System.out.println("main: " + DiffWithRespTo + "=" + x + " Basic Simple Exprn=" + StrexpSimpleExpressMap1);
expValue = parse(StrexpSimpleExpressMap1, variables, DiffWithRespTo);
ExprnexpValue = expValue.eval();
System.out.println(" main:Result(Expn Value)=" + ExprnexpValue);
expValue = parse(StrexpSimpleExpressMap1, variables, DiffWithRespTo);
DblexpValueMap1 = expValue.eval();
System.out.println("main: " + DiffWithRespTo + "=" + x + " Basic Simple (Exprn Value)=" + DblexpValueMap1);
StageMapping = "Differentiation";
exp = parseDiff(StrexpSimpleExpressMap1, variables, variablesDiff, DiffWithRespTo);
StrexpDiffExpress = exp.DiffExpr();
System.out.println(" main:Result(Diff Equation)(" + i + " th order)=> " + StrexpDiffExpress);
StageMapping = "Differentiation Mapping";
expSimple = parseSimple(StrexpDiffExpress, variables, variablesDiff, DiffWithRespTo);
StrexpSimpleExpressMap2 = expSimple.SimpleExpr();
expValue = parse(StrexpDiffExpress, variables, DiffWithRespTo);
DblexpDiffValue = expValue.eval();
System.out.println("main: " + DiffWithRespTo + "=" + x + " Result(Diff Value)=" + DblexpDiffValue);
System.out.println(" main:Result(Simplified Diff Equation)(" + i + " th order)=> " + StrexpSimpleExpressMap2);
expValue = parse(StrexpSimpleExpressMap2, variables, DiffWithRespTo);
DblexpValueMap2 = expValue.eval();
System.out.println("main: " + DiffWithRespTo + "=" + x + " Result(Simplified Diff Value)=" + expValue.eval());
System.out.print(System.lineSeparator());
if (PassFailTestCaseString(TestCase, i, "Diff" , Exprn, StrexpSimpleExpressMap1, StrexpDiffExpress, StrexpSimpleExpressMap2, EqnUnderTest, EqnSolArrayMap1[i], EqnSolArrayDiffAlone[i], EqnSolArrayMap2[i])) {
System.out.println(ConsoleColors.GREEN + " main:Test Case Status=" + "Pass STRING TEST Complete" + ConsoleColors.RESET);
TestCasePassStrFlag = true;
} else {
System.out.println(ConsoleColors.RED + " main:Test Case Status=" + "FAIL STRING TEST Complete" + ConsoleColors.RESET);
if(TestCasePassHighLevelFlag==true)
TestCasePassHighLevelFlag=false;
}
if (PassFailTestCaseValue(TestCase, i, "Diff",Exprn, ExprnexpValue, DblexpValueMap1, DblexpDiffValue, DblexpValueMap2,variables)) {
System.out.println(ConsoleColors.GREEN + " main:Test Case Status=" + "Pass VALUE TEST Complete" + ConsoleColors.RESET);
TestCasePassValFlag = true;
} else {
System.out.println(ConsoleColors.RED + " main:Test Case Status=" + "FAIL VALUE TEST Complete" + ConsoleColors.RESET);
if(TestCasePassHighLevelFlag==true)
TestCasePassHighLevelFlag=false;
}
Exprn = StrexpSimpleExpressMap2;
System.out.print(System.lineSeparator());
if ((TestCasePassStrFlag == true) && (TestCasePassValFlag == true))
;//Do Nothing : Test Case Passed
else {
String Temp = FailedTestCases.get(MaxIndexFail);
String HashVal = "";
if ((Temp != null) && (!Temp.equalsIgnoreCase(""))) {
HashVal = Temp + "," + ":Order=" + (i ) + ":Str=" + TestCasePassStrFlag + ":Val=" + TestCasePassValFlag;
} else {
HashVal = "TestCase=" + TestCase + ":Order=" + (i ) + ":Str=" + TestCasePassStrFlag + ":Val=" + TestCasePassValFlag;
}
FailedTestCases.put(MaxIndexFail, HashVal);
//i=MaxOrder1;
}
}
} catch (Exception MyException) {
System.out.print(System.lineSeparator());
System.out.print(System.lineSeparator());
MyException.printStackTrace();
System.out.println(ConsoleColors.RED + "TestCase " + TestCase + " Failed at Order=" + i + " due to Exception at Stage=" + StageMapping + "." + ConsoleColors.RESET);
System.out.print(System.lineSeparator());
String Temp = FailedTestCases.get(MaxIndexFail);
String HashVal = "";
if ((Temp != null) && (!Temp.equalsIgnoreCase(""))) {
HashVal = Temp + "," + ":Order=" + (i ) + ":Str=" + TestCasePassStrFlag + ":Val=" + TestCasePassValFlag;
} else {
HashVal = "TestCase=" + TestCase + ":Order=" + (i ) + ":Str=" + TestCasePassStrFlag + ":Val=" + TestCasePassValFlag;
}
FailedTestCases.put(MaxIndexFail, HashVal);
String Temp1 = ExceptionTestCases.get(MaxIndexExcept);
String HashVal1 = "";
if ((Temp1 != null) && (!Temp1.equalsIgnoreCase(""))) {
HashVal1 = Temp1 + "," + ":Order=" + (i ) ;
} else {
HashVal1 = "TestCase=" + TestCase + ":Order=" + (i ) ;
}
ExceptionTestCases.put(MaxIndexExcept, HashVal);
MaxIndexExcept++;
//i=MaxOrder1;
TestCasePassHighLevelFlag=false;
}
System.out.print(System.lineSeparator());
if (TestCaseLoopTimes == 1) {
break;
} else {
j = RegressionControl(j);
//System.out.println(ConsoleColors.RED +"mainDiffTest: j="+ j + " TestCase=" + TestCase);
}
if (TestCasePassHighLevelFlag==false) MaxIndexFail++;
}
System.out.println(ConsoleColors.RED + "mainDiffTest: TestCase Summary : Total Failed=" + MaxIndexFail + " Out of Run TestCases=" + TotalTestCases + " Failed Test Cases are:" + ConsoleColors.RESET);
for (int y = 0; y < MaxIndexFail; y++) {
System.out.print(ConsoleColors.RED + " " + FailedTestCases.get(y) + ", " + ConsoleColors.RESET);
if ((y >= 10) && (y % 5 == 0)) {
System.out.print(System.lineSeparator());
}
}
System.out.print(System.lineSeparator());
System.out.println(ConsoleColors.RED + "mainDiffTest: Exception TestCase Summary : Total Exceptions=" + MaxIndexExcept + " Exception Test Cases are:" + ConsoleColors.RESET);
for (int y = 0; y < MaxIndexExcept; y++) {
System.out.print(ConsoleColors.RED + " " + ExceptionTestCases.get(y) + ", " + ConsoleColors.RESET);
if ((y >= 10) && (y % 5 == 0)) {
System.out.print(System.lineSeparator());
}
}
System.out.print(System.lineSeparator());
}
public static int RegressionControl(int j) {
if ((j >= 100) && (j < 105)) {
j++;
} else if ((j >= 5019) && (j < 5042)) {
j++;
} else if ((j >= 10001) && (j < 10005)) {
j++;
} else if ((j >= 20001) && (j < 20092)) {
j++;
} else if ((j >= 30001) && (j < 30011)) {
j++;
} else if ((j >= 40001) && (j < 40034)) {
j++;
}else if ((j >= 50001) && (j < 50029)) {
j++;
}else if( (j >= 80001) && (j < 80012)){
j++;
} else if( (j >= 110001) && (j < 110007)){
j++;
} else if (j == 90001) {
j = 100001;
}else if (j == 100001) {
j = 110001;
}else if (j == 110007) {
j = 120001;
}
// else if ((j >= 90001) && (j < 90002)) {
// j++;
// } else if ((j >= 100001) && (j < 100002)) {
// j++;
// }
//Bypass Gaps Section
else if ((j < 100)) {
j = 100;
}else if ((j == 105)) {
j = 5019;
}else if (j == 5042) {
j = 10001;
} else if (j == 10005) {
j = 20001;
} else if (j == 20092) {
j = 30001;
} else if (j == 30011) {
j = 40001;
}else if (j == 40034) {
j = 50001;
}else if (j == 50029) {
j = 80001;
} else if (j == 80012) {
j = 90001;
}
else {
System.out.println(ConsoleColors.RED + "RegressionControl:j= " + j + ": Infinite Loop" + ConsoleColors.RESET);
}
return j;
}
public static void mainRegressionIntegrTest(int MaxOrder, TestHarness TestData) {
String Exprn = "";
Map<String, Double> variables = new HashMap<>();
Map<String, String> variablesDiff = new HashMap<>();
//String Exprn = eatAll(TestCases(), ' ');
//String Exprn = eatAll(HighLevelUnitTestCases(), ' ');
//String Exprn = eatAll(FailingHighLevelUnitTestCases(), ' ');
//String Exprn = eatAll(FailingLowLevelUnitTestCases(), ' ');
//Exprn = eatAll(Exprn, ' ');
SimpleExpression expSimple;
Expression expValue;
IntegrExpr exp;
OrderVar expOrder;
MyFuncExpress();
MyFuncDiff();
MyFuncSimple();
MyFuncIntegr();
String Constant = "C";
//String DiffWithRespTo = "Xn";
String StrexpSimpleExpressMap1 = "";
String StrexpDiffExpress = "";
String StrexpSimpleExpressMap2 = "";
String myOrder = "";
double ExprnexpValue = 0;
double DblexpValueMap1 = 0;
double DblexpDiffValue = 0;
double DblexpValueMap2 = 0;
int j = TestCase;
boolean TestCasePassStrFlag = false;
boolean TestCasePassValFlag = false;
boolean TestCasePassHighLevelFlag = true;
HashMap<Integer, String> FailedTestCases = new HashMap<Integer, String>();
HashMap<Integer, String> ExceptionTestCases = new HashMap<Integer, String>();
int MaxIndexFail = 0;
int MaxIndexExcept = 0;
int MaxOrder1 = MaxOrder;
int i = 1;
int TotalTestCases=0;
String OverallRegressionStatus = "Integral:"
+ "\n" + "TestCases:Unit Test Cases" + " 24"
+ "\n" + "TestCases:Names "
+ "\n" + "TestCases:Coefficients " + " 20016, 20017 "
+ "\n" + "TestCases:Exponent " + " 30002 to 30008";
System.out.print(ConsoleColors.BLUE + "Integral Overall Regression Status =" + OverallRegressionStatus + ConsoleColors.RESET);
System.out.print(System.lineSeparator());
if(EndTestCase > LastTestCaseHarness)
EndTestCase=LastTestCaseHarness;
while (j <= EndTestCase) {
EqnUnderTest = "";
String TempExprn = "";
TempExprn = FailingTestHarnessDiff("mainIntegrTest",j);
if (MaxOrder == -1) {
MaxOrder1 = MaxIntegreOrder; //From Test Case
} else if (MaxOrder > MaxIntegreOrder) {
MaxOrder1 = MaxIntegreOrder;
} else {
MaxOrder1 = MaxOrder;
}
if ((!EqnUnderTest.equalsIgnoreCase("")) && (TempExprn != null) && (!TempExprn.equalsIgnoreCase(""))) {
Exprn = eatAll(TempExprn, ' ');
} else {
j = RegressionControl(j);
System.out.println(ConsoleColors.RED + "mainIntegrTest: j=" + j + " TestCase=" + TestCase);
continue;
}
System.out.println(ConsoleColors.BLUE + "Test Case " + TestCase + " Exprn=" + Exprn + ConsoleColors.RESET);
System.out.println(ConsoleColors.BLUE + "Test Case Name=" + TestCaseName + ConsoleColors.RESET);
System.out.println(ConsoleColors.BLUE + "Test Case Name=" + TestCaseMatrixID + ConsoleColors.RESET);
System.out.println(ConsoleColors.BLUE + "Integral Regression Status : Test Case should be " + EqnRegressionIntegreStatus + ConsoleColors.RESET);
i = 1;
TotalTestCases++;
TestCasePassHighLevelFlag=true;
String StageMapping = "";
variablesDiff.put(DiffWithRespTo, DiffWithRespTo);
try {
for (double x = 1, y = 7; i < MaxOrder1; y++, /*x++,*/ i++) {
TestCasePassStrFlag = false;
TestCasePassValFlag = false;
variables.put(DiffWithRespTo, x);
variables.put("y", y);
variables.put("a", 1.0);
variables.put("b", 2.0);//variables.put("b", 0.0);
variables.put("c", -1.0);
variables.put("d", 2.0);
variables.put("p", 1.0);
variables.put("q", 0.0);
variables.put("r", -1.0);
variables.put("s", 2.0);
variables.put(Constant, 5.0);
StageMapping = "Basic Mapping";
expOrder = parseOrder(Exprn, DiffWithRespTo);
myOrder = expOrder.eval();
System.out.println("main: " + DiffWithRespTo + "=" + x + " Exprn=" + Exprn + " Order=" + myOrder);
expSimple = parseSimple(Exprn, variables, variablesDiff, DiffWithRespTo);
StrexpSimpleExpressMap1 = expSimple.SimpleExpr();
System.out.println("main: " + DiffWithRespTo + "=" + x + " Basic Simple Exprn=" + StrexpSimpleExpressMap1);
expValue = parse(StrexpSimpleExpressMap1, variables, DiffWithRespTo);
ExprnexpValue = expValue.eval();
System.out.println(" main:Result(Expn Value)=" + ExprnexpValue);
expValue = parse(StrexpSimpleExpressMap1, variables, DiffWithRespTo);
DblexpValueMap1 = expValue.eval();
System.out.println("main: " + DiffWithRespTo + "=" + x + " Basic Simple (Exprn Value)=" + DblexpValueMap1);
StageMapping = "Integration";
exp = parseIntegr(StrexpSimpleExpressMap1, variables, variablesDiff, DiffWithRespTo);
StrexpDiffExpress = exp.IntegrExpr();
System.out.println(" main:Result(Integral Equation)(" + i + " th order)=> " + StrexpDiffExpress);
StageMapping = "Integration Mapping";
expSimple = parseSimple(StrexpDiffExpress, variables, variablesDiff, DiffWithRespTo);
StrexpSimpleExpressMap2 = expSimple.SimpleExpr();
System.out.println(" main:Result(Simplified Integral Equation)(" + i + " th order)=> " + StrexpSimpleExpressMap2);
expValue = parse(StrexpDiffExpress, variables, DiffWithRespTo);
DblexpDiffValue = expValue.eval();
System.out.println("main: " + DiffWithRespTo + "=" + x + " Result(Integral Value)=" + DblexpDiffValue);
expValue = parse(StrexpSimpleExpressMap2, variables, DiffWithRespTo);
DblexpValueMap2 = expValue.eval();
System.out.println("main: " + DiffWithRespTo + "=" + x + " Result(Simplified Integral Value)=" + expValue.eval());
System.out.print(System.lineSeparator());
if (PassFailTestCaseString(TestCase, i, "Integre" , Exprn, StrexpSimpleExpressMap1, StrexpDiffExpress, StrexpSimpleExpressMap2, EqnUnderTest, EqnSolArrayMap3[i], EqnSolArrayIntegrAlone[i], EqnSolArrayMap4[i])) {
System.out.println(ConsoleColors.GREEN + " main:Test Case Status=" + "Pass STRING TEST Complete" + ConsoleColors.RESET);
TestCasePassStrFlag = true;
} else {
System.out.println(ConsoleColors.RED + " main:Test Case Status=" + "FAIL STRING TEST Complete" + ConsoleColors.RESET);
if(TestCasePassHighLevelFlag==true)
TestCasePassHighLevelFlag=false;
}
if (PassFailTestCaseValue(TestCase, i, "Integre" , Exprn, ExprnexpValue, DblexpValueMap1, DblexpDiffValue, DblexpValueMap2,variables)) {
System.out.println(ConsoleColors.GREEN + " main:Test Case Status=" + "Pass VALUE TEST Complete" + ConsoleColors.RESET);
TestCasePassValFlag = true;
} else {
System.out.println(ConsoleColors.RED + " main:Test Case Status=" + "FAIL VALUE TEST Complete" + ConsoleColors.RESET);
if(TestCasePassHighLevelFlag==true)
TestCasePassHighLevelFlag=false;
}
Exprn = StrexpSimpleExpressMap2;
System.out.print(System.lineSeparator());
if ((TestCasePassStrFlag == true) && (TestCasePassValFlag == true))
;//Do Nothing : Test Case Passed
else {
String Temp = FailedTestCases.get(MaxIndexFail);
String HashVal = "";
if ((Temp != null) && (!Temp.equalsIgnoreCase(""))) {
HashVal = Temp + "," + ":Order=" + (i ) + ":Str=" + TestCasePassStrFlag + ":Val=" + TestCasePassValFlag;
} else {
HashVal = "TestCase=" + TestCase + ":Order=" + (i ) + ":Str=" + TestCasePassStrFlag + ":Val=" + TestCasePassValFlag;
}
FailedTestCases.put(MaxIndexFail, HashVal);
//i=MaxOrder1;
}
}
} catch (Exception MyException) {
System.out.print(System.lineSeparator());
System.out.print(System.lineSeparator());
MyException.printStackTrace();
System.out.println(ConsoleColors.RED + "TestCase " + TestCase + " Failed at Order=" + i + " due to Exception at Stage=" + StageMapping + "." + ConsoleColors.RESET);
System.out.print(System.lineSeparator());
String Temp = FailedTestCases.get(MaxIndexFail);
String HashVal = "";
if ((Temp != null) && (!Temp.equalsIgnoreCase(""))) {
HashVal = Temp + "," + ":Order=" + (i ) + ":Str=" + TestCasePassStrFlag + ":Val=" + TestCasePassValFlag;
} else {
HashVal = "TestCase=" + TestCase + ":Order=" + (i ) + ":Str=" + TestCasePassStrFlag + ":Val=" + TestCasePassValFlag;
}
FailedTestCases.put(MaxIndexFail, HashVal);
String Temp1 = ExceptionTestCases.get(MaxIndexExcept);
String HashVal1 = "";
if ((Temp1 != null) && (!Temp1.equalsIgnoreCase(""))) {
HashVal1 = Temp1 + "," + ":Order=" + (i ) ;
} else {
HashVal1 = "TestCase=" + TestCase + ":Order=" + (i ) ;
}
ExceptionTestCases.put(MaxIndexExcept, HashVal);
MaxIndexExcept++;
i=MaxOrder1;
TestCasePassHighLevelFlag=false;
}
System.out.print(System.lineSeparator());
if (TestCaseLoopTimes == 1) {
break;
} else {
j = RegressionControl(j);
}
if (TestCasePassHighLevelFlag==false) MaxIndexFail++;
}
for(int a=0; a < 10; a++)
System.out.print(System.lineSeparator());
System.out.println(ConsoleColors.RED + "mainIntegrTest: TestCase Summary : Total Failed=" + MaxIndexFail + " Out of Run TestCases=" + TotalTestCases + " Failed Test Cases are:" + ConsoleColors.RESET);
for (int y = 0; y < MaxIndexFail; y++) {
System.out.print(ConsoleColors.RED + " " + FailedTestCases.get(y) + ", " + ConsoleColors.RESET);
if ((y >= 10) && (y % 5 == 0)) {
System.out.print(System.lineSeparator());
}
}
System.out.print(System.lineSeparator());
System.out.println(ConsoleColors.RED + "mainIntegrTest: Exception TestCase Summary : Total Exceptions=" + MaxIndexExcept + " Exception Test Cases are:" + ConsoleColors.RESET);
for (int y = 0; y < MaxIndexExcept; y++) {
System.out.print(ConsoleColors.RED + " " + ExceptionTestCases.get(y) + ", " + ConsoleColors.RESET);
if ((y >= 10) && (y % 5 == 0)) {
System.out.print(System.lineSeparator());
}
}
System.out.print(System.lineSeparator());
}
public static void mainIntegreDiffTest(String Exprn, int MaxOrder, TestHarness TestData) {
Map<String, Double> variables = new HashMap<>();
Map<String, String> variablesDiff = new HashMap<>();
//String Exprn = eatAll(TestCases(), ' ');
//String Exprn = eatAll(HighLevelUnitTestCases(), ' ');
//String Exprn = eatAll(FailingHighLevelUnitTestCases(), ' ');
//String Exprn = eatAll(FailingLowLevelUnitTestCases(), ' ');
//Exprn = eatAll(Exprn, ' ');
SimpleExpression expSimple;
Expression expValue;
DiffExpr exp;
IntegrExpr expIntegr;
MyFuncExpress();
MyFuncDiff();
MyFuncSimple();
String Constant = "C";
//String DiffWithRespTo = "Xn";
variablesDiff.put(DiffWithRespTo, DiffWithRespTo);
String StrexpSimpleExpressMap1 = "";
String StrexpDiffExpress = "";
String StrexpSimpleExpressMap2 = "";
double ExprnexpValue = 0;
double DblexpValueMap1 = 0;
double DblexpDiffValue = 0;
double DblexpValueMap2 = 0;
int j = TestCase;
boolean TestCasePassStrFlag = false;
boolean TestCasePassValFlag = false;
boolean TestCasePassHighLevelFlag = true;
HashMap<Integer, String> FailedTestCases = new HashMap<Integer, String>();
int MaxIndexFail = 0;
int MaxOrder1 = MaxOrder;
int i = 1;
while (j <= TestCaseLoopTimes) {
EqnUnderTest = "";
String TempExprn = "";
TempExprn = FailingTestHarnessDiff("mainIntegreDiffTest",j);
if (MaxOrder == -1) {
MaxOrder1 = MaxDiffOrder; //From Test Case
} else if (MaxOrder > MaxDiffOrder) {
MaxOrder1 = MaxDiffOrder;
} else {
MaxOrder1 = MaxOrder;
}
if ((!EqnUnderTest.equalsIgnoreCase("")) && (TempExprn != null) && (!TempExprn.equalsIgnoreCase(""))) {
Exprn = eatAll(TempExprn, ' ');
} else {
j = RegressionControl(j);
System.out.println(ConsoleColors.RED + "mainDiffTest: j=" + j + " TestCase=" + TestCase);
continue;
}
if ((!EqnUnderTest.equalsIgnoreCase("")) && (TempExprn != null) && (!TempExprn.equalsIgnoreCase(""))) {
Exprn = eatAll(TempExprn, ' ');
} else {
continue;
}
System.out.println(ConsoleColors.BLUE + "Test Case " + TestCase + " Exprn=" + Exprn + ConsoleColors.RESET);
System.out.println(ConsoleColors.BLUE + "Test Case Name=" + TestCaseName + ConsoleColors.RESET);
System.out.println(ConsoleColors.BLUE + "Test Case Name=" + TestCaseMatrixID + ConsoleColors.RESET);
System.out.println(ConsoleColors.BLUE + "Diff Regression Status : Test Case should be " + EqnRegressionDiffStatus + ConsoleColors.RESET);
System.out.println(ConsoleColors.BLUE + "Integral Regression Status : Test Case should be " + EqnRegressionIntegreStatus + ConsoleColors.RESET);
i = 1;
TestCasePassHighLevelFlag=true;
String StageMapping = "";
try {
for (double x = 1, y = 7; i < MaxOrder; y++, x++, i++) {
TestCasePassStrFlag = false;
TestCasePassValFlag = false;
variables.put(DiffWithRespTo, x);
variables.put("y", y);
variables.put(Constant, 5.0);
StageMapping = "Basic Mapping";
System.out.println("main: " + DiffWithRespTo + "=" + x + " Exprn=" + Exprn);
expSimple = parseSimple(Exprn, variables, variablesDiff, DiffWithRespTo);
System.out.println(" main:Result(Expn Value)=" + ExprnexpValue);
expValue = parse(Exprn, variables, DiffWithRespTo);
ExprnexpValue = expValue.eval();
StrexpSimpleExpressMap1 = expSimple.SimpleExpr();
System.out.println("main: " + DiffWithRespTo + "=" + x + " Basic Simple Exprn=" + StrexpSimpleExpressMap1);
expValue = parse(StrexpSimpleExpressMap1, variables, DiffWithRespTo);
DblexpValueMap1 = expValue.eval();
System.out.println("main: " + DiffWithRespTo + "=" + x + " Basic Simple (Exprn Value)=" + DblexpValueMap1);
StageMapping = "Integration";
expIntegr = parseIntegr(StrexpSimpleExpressMap1, variables, variablesDiff, DiffWithRespTo);
StrexpDiffExpress = expIntegr.IntegrExpr();
System.out.println(" main:Result(Diff Equation)(" + i + " th order)=> " + StrexpDiffExpress);
expValue = parse(StrexpDiffExpress, variables, DiffWithRespTo);
DblexpDiffValue = expValue.eval();
System.out.println("main: " + DiffWithRespTo + "=" + x + " Result(Diff Value)=" + DblexpDiffValue);
StageMapping = "Differentiation";
exp = parseDiff(StrexpDiffExpress, variables, variablesDiff, DiffWithRespTo);
StrexpDiffExpress = exp.DiffExpr();
System.out.println(" main:Result(Diff Equation)(" + i + " th order)=> " + StrexpDiffExpress);
expValue = parse(StrexpDiffExpress, variables, DiffWithRespTo);
DblexpDiffValue = expValue.eval();
System.out.println("main: " + DiffWithRespTo + "=" + x + " Result(Diff Value)=" + DblexpDiffValue);
StageMapping = "Differentiation Mapping";
expSimple = parseSimple(StrexpDiffExpress, variables, variablesDiff, DiffWithRespTo);
StrexpSimpleExpressMap2 = expSimple.SimpleExpr();
System.out.println(" main:Result(Simplified Diff Equation)(" + i + " th order)=> " + StrexpSimpleExpressMap2);
expValue = parse(StrexpSimpleExpressMap2, variables, DiffWithRespTo);
DblexpValueMap2 = expValue.eval();
System.out.println("main: " + DiffWithRespTo + "=" + x + " Result(Simplified Diff Value)=" + expValue.eval());
System.out.print(System.lineSeparator());
if (PassFailTestCaseString(TestCase, i, "Diff", Exprn, StrexpSimpleExpressMap1, StrexpDiffExpress, StrexpSimpleExpressMap2, EqnUnderTest, EqnSolArrayMap3[i], EqnSolArrayIntegrAlone[i], EqnSolArrayMap4[i])) {
System.out.println(ConsoleColors.GREEN + " main:Test Case Status=" + "Pass STRING TEST Complete" + ConsoleColors.RESET);
TestCasePassStrFlag = true;