Skip to content

Commit

Permalink
make method improve() return boolean
Browse files Browse the repository at this point in the history
stdout:
6x6
[000011, 000011, 000001],[000011, 000001, 000001]
threshold=27, P=6
#mvseqs=56724
 -1 -1 -1 -1  0  1
 -1 -1 -1 -1  2  3
 -1 -1 -1 -1  4  5
 -1 -1 -1 -1  6  7
  8  9 10 11 12 13
 14 15 16 17 18 19
[0, 2, 4, 6]
ncombos=116280
0:1
1:2
2:6
3:25
4:82
5:254
6:800
7:2356
8:6498
9:15370
10:27218
11:32295
12:22767
13:7720
14:871
15:15
#reached=116280
D=16
total time=268
 -1 -1 -1 -1 -1  0
 -1 -1 -1 -1 -1  1
 -1 -1 -1 -1 -1  2
 -1 -1 -1 -1 -1  3
  4  5  6  7  8  9
 10 11 12 13 14 15
[4, 5, 6, 7, 8]
ncombos=524160
0:1
1:2
2:6
3:21
4:58
5:156
6:441
7:1165
8:2945
9:7508
10:17927
11:38631
12:72472
13:108595
14:123522
15:99620
16:43574
17:7258
18:256
19:2
#reached=524160
D=20
total time=588
solvedscrm=[4, 10, 16, 22, 24, 25, 26, 27, 28]
subarrstart=[0, 4, 9]
total combos to reduce=2821027911
[15, 13]: ncombos=1628925
  elapsed ms     #combos
        5000      679544
       12146     1628925
[14, 14]: ncombos=107587662
  elapsed ms     #combos
        5000     1019522
       13591     2735271
       20566     4123036
       28261     5644705
       36945     7298085
       46782     9000438
       57912    11304848
       70470    13630912
       84594    16210427
      100427    19012339
      118121    22409653
      137835    26117554
      159738    30122982
      184009    34772202
      210839    39226086
      240428    44068262
      272990    49678335
      308753    55110115
      347956    61328822
      390855    68159185
      437717    75589006
      488829    83880617
      544492    93100543
NOT REDUCED:
  .  .  .  . 27 25
  .  .  .  . 17 23
  .  .  .  .  5  .
  .  .  .  .  . 11
  .  .  .  .  .  .
 28  . 26 29  .  .
t=0
 [1, 5, 1] [1, 5, 1] [1, 4, -1] [0, 5, -1] [1, 5, 1] [1, 5, 1] [1, 4, -1] [1, 4, -1] [0, 5, -1] [1, 4, 1] [1, 4, 1] [1, 4, 1] [0, 5, 1] [1, 4, 1]
t=1
 [0, 5, -1] [0, 5, -1] [0, 4, -1] [1, 5, -1] [0, 5, -1] [0, 5, -1] [0, 4, -1] [1, 5, -1] [0, 4, -1] [1, 5, -1] [0, 5, 1] [0, 4, -1] [1, 5, -1] [0, 4, -1]






6x6
[000011, 000011, 000001],[000011, 000001, 000001]
threshold=27, P=7
#mvseqs=304052
 -1 -1 -1 -1  0  1
 -1 -1 -1 -1  2  3
 -1 -1 -1 -1  4  5
 -1 -1 -1 -1  6  7
  8  9 10 11 12 13
 14 15 16 17 18 19
[0, 2, 4, 6]
ncombos=116280
0:1
1:2
2:6
3:25
4:82
5:254
6:800
7:2356
8:6498
9:15370
10:27218
11:32295
12:22767
13:7720
14:871
15:15
#reached=116280
D=16
total time=100
 -1 -1 -1 -1 -1  0
 -1 -1 -1 -1 -1  1
 -1 -1 -1 -1 -1  2
 -1 -1 -1 -1 -1  3
  4  5  6  7  8  9
 10 11 12 13 14 15
[4, 5, 6, 7, 8]
ncombos=524160
0:1
1:2
2:6
3:21
4:58
5:156
6:441
7:1165
8:2945
9:7508
10:17927
11:38631
12:72472
13:108595
14:123522
15:99620
16:43574
17:7258
18:256
19:2
#reached=524160
D=20
total time=592
solvedscrm=[4, 10, 16, 22, 24, 25, 26, 27, 28]
subarrstart=[0, 4, 9]
total combos to reduce=2821027911
[15, 13]: ncombos=1628925
  elapsed ms     #combos
        5000      723230
       11991     1628925
[14, 14]: ncombos=107587662
  elapsed ms     #combos
        5000     1005201
       13591     2647168
       20566     4010345
       28261     5616775
       36945     7536254
       46782     9660122
       57912    12104256
       70470    14520880
       84594    17125877
      100427    20087097
      118121    23643212
      137835    27070088
      159738    31294187
      184009    35882293
      210839    41143436
      240428    46714218
      272990    52208064
      308753    58226561
      347956    64666618
      390855    72525464
      437717    81033242
      488829    90377978
      544492    99294082
      605024   107561623
      605286   107587662
[15, 14]: ncombos=1852830
  elapsed ms     #combos
        5000      524439
       13591     1485147
       20566     1848097
       20715     1852830
[13, 15]: ncombos=769066400
  elapsed ms     #combos
        5002      810627
       13593     2403861
       20566     3793187
       28261     5220513
       36946     6467972
       46782     8120255
       57912    10510515
       70470    13400481
       84594    15661024
      100427    19131467
      118121    23195533
      137835    27653930
      159738    31293054
      184009    35450406
      210839    40259146
      240428    45609393
      272990    52395352
      308753    58975843
      347956    66096255
      390855    74706834
      437718    84193492
      488829    93816505
      544492   104473945
      605024   115247574
      670764   127293159
      742065   139459172
      819305   152643818
      902880   168364744
      993208   184901849
     1090730   201985947
     1195910   220661669
     1309240   242025251
     1431233   263112981
     1562434   284257778
     1703414   309535669
     1854773   342318064
     2017143   376575049
     2191190   407214135
     2377612   442984491
     2577140   481402537
     2790547   524748950
     3018641   571751480
     3262270   623789881
     3522324   675446178
     3799738   729164288
     4016590   769066400
[14, 15]: ncombos=86769020
  elapsed ms     #combos
        5000      881700
       13591     2210244
       20566     3418879
       28261     4694229
       36945     6245804
       46782     7765052
       57912     9755099
       70470    11733309
       84594    13716634
      100427    16056633
      118134    18730335
      137835    21845328
      159738    25063016
      184009    28882614
      210839    32384817
      240428    36800073
      272990    41465692
      308753    45784517
      347956    50753008
      390855    55987200
      437717    62746436
      488829    70001762
      544492    77406431
      605024    84689847
      623352    86769020
[15, 15]: ncombos=1494300
  elapsed ms     #combos
        5000      498616
       13591     1231161
       16871     1494300
[12, 16]: ncombos=992049258
  elapsed ms     #combos
        5000     1311469
       13591     3544162
       20566     5342580
       28261     7349329
       36945     9577867
       46782    12051528
       57912    14936617
       70470    18150098
       84594    21553666
      100427    25393278
      118121    29793345
      137835    34581534
      159738    39900409
      184009    46088174
      210839    52826023
      240428    60264963
      272990    68319394
      308753    77259817
      347956    87578324
      390855    97973261
      437717   109476521
      488829   122347857
      544492   136097232
      605024   150785493
      670764   166126117
      742065   182537367
      819305   200756760
      902880   219739121
      993208   240026750
     1090730   263716346
     1195910   286456381
     1309240   309880185
     1431233   334517996
     1562434   361496273
     1703414   390179290
     1854773   420733304
     2017143   450127568
     2191190   487530602
     2377612   527518954
     2577140   568408574
     2790547   604050358
     3018641   643424755
     3262270   690065169
     3522324   740086632
     3799738   789964497
     4095490   846586206
     4410608   900993394
     4746166   961951534
     4922793   992049258
[13, 16]: ncombos=336391280
  elapsed ms     #combos
        5000      820378
       13591     2208810
       20566     3371500
       28261     4562505
       36945     5959959
       46782     7447303
       57912     8992040
       70470    11092441
       84594    13477586
      100427    16069812
      118121    19229076
      137835    22574081
      159738    26877029
      184009    31737955
      210839    35981505
      240428    41155715
      272990    46406432
      308753    53122523
      347956    58462667
      390855    63680773
      437717    69416842
      488829    77221245
      544492    86043012
      605024    97183271
      670764   105738363
      742065   115783855
      819305   126813181
      902880   137210243
      993208   149738541
     1090730   163829203
     1195910   179697952
     1309240   194878146
     1431233   208970794
     1562434   226218899
     1703414   243390482
     1854773   266508592
     2017143   290650013
     2191190   314248947
     2367275   336391280
[14, 16]: ncombos=37952954
  elapsed ms     #combos
        5000      691166
       13591     1723641
       20566     2574654
       28261     3585315
       36945     4679815
       46782     5847499
       57912     7058444
       70470     8432612
       84594    10043943
      100427    11602853
      118121    13143592
      137835    15049461
      159738    17036125
      184009    19503669
      210839    21903530
      240428    24260773
      272990    27342783
      308753    30618793
      347956    34146947
      390855    37364676
      398631    37952954
[15, 16]: ncombos=653610
  elapsed ms     #combos
        5000      382112
        8948      653610
[11, 17]: ncombos=234397110
  elapsed ms     #combos
        5000     1309310
       13591     3442458
       20566     4983228
       28261     6731297
       36945     8611606
       46782    10707639
       57912    13080462
       70470    15863092
       84594    19060549
      100427    22528981
      118121    26510252
      137835    30931251
      159738    36466669
      184009    41629239
      210839    46437037
      240428    51965630
      272990    58584049
      308753    65608133
      347956    73190529
      390855    81786631
      437717    91546972
      488829   101545684
      544492   112185491
      605024   123005491
      670764   135201927
      742065   147923204
      819305   161606928
      902880   177781839
      993213   193245603
     1090730   212329596
     1195910   231898008
     1210656   234397110
[12, 17]: ncombos=165242886
  elapsed ms     #combos
        5000      930289
       13591     2485168
       20566     3744866
       28261     5144783
       36945     6875021
       46782     8853745
       57912    10991545
       70470    13778353
       84594    16425587
      100427    19829954
      118121    23226484
      137835    27286159
      159738    31696151
      184009    35540562
      210839    40423993
      240428    45839148
      272990    52081730
      308753    58542157
      347956    65430972
      390856    72969571
      437717    81276661
      488829    90738013
      544492   101810086
      605024   111905757
      670764   122623440
      742065   134046896
      819305   147225785
      902880   161131791
      929423   165242886
[13, 17]: ncombos=56031760
  elapsed ms     #combos
        5000      864687
       13591     2194252
       20566     3241187
       28261     4500927
       36945     5841844
       46782     7328146
       57912     9066237
       70470    10840485
       84594    12554057
      100427    14633168
      118121    16744586
      137835    19727337
      159738    22297751
      184009    25293882
      210839    28143998
      240428    31655651
      272990    35560532
      308753    39212872
      347956    43112851
      390855    46709394
      437717    51635162
      480873    56031760
[14, 17]: ncombos=6321718
  elapsed ms     #combos
        5000      533012
       13591     1333420
       20566     1742594
       28261     2356654
       36945     2912283
       46782     3563985
       57914     4259469
       70470     5007964
       84594     5907747
       92516     6321718
[15, 17]: ncombos=108870
  elapsed ms     #combos
        2071      108870
[10, 18]: ncombos=6967808
  elapsed ms     #combos
        5000     1045021
       13591     2759487
       20566     4151041
       28262     5663451
       34854     6967808
[11, 18]: ncombos=8267520
  elapsed ms     #combos
        5000     1086213
       13591     2833513
       20566     4183233
       28261     5641316
       36945     7323307
       42092     8267520
[12, 18]: ncombos=5828352
  elapsed ms     #combos
        5000      838844
       13591     2043347
       20566     2839466
       28261     3793795
       36945     4846141
       45673     5828352
[13, 18]: ncombos=1976320
  elapsed ms     #combos
        5000      507962
       13591     1210385
       20568     1605357
       27530     1976320
[14, 18]: ncombos=222976
  elapsed ms     #combos
        5000      197230
        5723      222976
[15, 18]: ncombos=3840
  elapsed ms     #combos
         124        3840
[9, 19]: ncombos=30740
  elapsed ms     #combos
         212       30740
[10, 19]: ncombos=54436
  elapsed ms     #combos
         375       54436
[11, 19]: ncombos=64590
  elapsed ms     #combos
         583       64590
[12, 19]: ncombos=45534
  elapsed ms     #combos
         661       45534
[13, 19]: ncombos=15440
  elapsed ms     #combos
         452       15440
[14, 19]: ncombos=1742
  elapsed ms     #combos
          67        1742
[15, 19]: ncombos=30
  elapsed ms     #combos
           3          30
time=16478048

Process finished with exit code 0
  • Loading branch information
coolcomputery committed Jun 28, 2021
1 parent 2eb67e2 commit 10b3f81
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions LoopoverBFSImprove.java
@@ -1,6 +1,6 @@
import java.util.*;
/**
* given a chain of Loopover states:
* given a length-3 chain of Loopover states:
* ex. (5,5,{},{})-->(5,5,{0,1,2},{0,1})-->(5,5,{0,1,2,3},{0,1,2})
* make the BFS trees of every adjacent pair of states;
* then find the upper bound on the total state transformation
Expand Down Expand Up @@ -37,7 +37,7 @@ private static int[] scrambleAction(int R, int C, int[] mvseq, int[][] mvactions
for (int mvi:mvseq) out=prodperm(out,mvactions[mvi]);
return out;
}
private static void improve(int R, int C, String[] Rfrees, String[] Cfrees, int threshold, int P, boolean[] allActions) {
private static boolean improve(int R, int C, String[] Rfrees, String[] Cfrees, int threshold, int P, boolean[] allActions) {
System.out.println(R+"x"+C+"\n"+Arrays.toString(Rfrees)+","+Arrays.toString(Cfrees)+"\nthreshold="+threshold+", P="+P);
int M=0;
for (int mr=0; mr<R; mr++) if (Rfrees[0].charAt(mr)=='1') M+=2;
Expand Down Expand Up @@ -188,7 +188,7 @@ private static void improve(int R, int C, String[] Rfrees, String[] Cfrees, int
for (int[] mv:tmp) System.out.print(" "+Arrays.toString(mv));
System.out.println();
}
return;
return false;
}
/*if (Math.random()<0.000001) {
System.out.print(boardStr(solvedscrm,scrm,R,C));
Expand All @@ -212,26 +212,23 @@ private static void improve(int R, int C, String[] Rfrees, String[] Cfrees, int
}
System.out.printf(form,System.currentTimeMillis()-st,reps);
}
return true;
}
public static void main(String[] args) {
long st=System.currentTimeMillis();
improve(6,6,
if (!improve(6,6,
new String[] {"000011","000011","000001"},
new String[] {"000011","000001","000001"},
28,6,
27,6,
new boolean[] {true,true}
);
/*improve(6,6,
new String[] {"111111","001111","000111"},
new String[] {"111111","001111","000111"},
//27,1
//26,>5
);*/
)) {
improve(6,6,
new String[] {"000011","000011","000001"},
new String[] {"000011","000001","000001"},
27,7,
new boolean[] {true,true}
);
}
System.out.println("time="+(System.currentTimeMillis()-st));
//TODO: REVERT BACK TO 2-WAY BFS OPT?
//TODO: 6x6:4x5-5x5-6x6: 38,5; 6x6:4x4-4x5-5x5:27,X
//TODO: 6x6:0x0-2x2-3x3: <27?
//TODO: 3-WAY 6x6:4x4-4x5-5x5-6x6
//TODO: 4-WAY 5x5:0x0-2x2-3x3-4x4-5x5
}
}

0 comments on commit 10b3f81

Please sign in to comment.