001package org.clafer.choco.constraint.propagator; 002 003import java.io.File; 004import org.clafer.ast.AstModel; 005import org.clafer.collection.Triple; 006import org.clafer.compiler.ClaferCompiler; 007import org.clafer.compiler.ClaferSolver; 008import org.clafer.javascript.Javascript; 009import org.clafer.objective.Objective; 010import org.clafer.scope.Scope; 011 012/** 013 * 014 * @author jimmy 015 */ 016public class Main { 017 018 public static void main(String[] args) throws Exception { 019 File dir = new File("/home/jimmy/Programming/chocosolver/src/test/resources/positive/"); 020 021 long nodeCount = 0; 022 long backtrackCount = 0; 023 long failCount = 0; 024 long restartCount = 0; 025 long eventCount = 0; 026 long propagationCount = 0; 027 long maxDepth = 0; 028 long variables = 0; 029 long constraints = 0; 030 031 for (File test : dir.listFiles()) { 032 //c204_flowElements@Ref16 033// if (!test.getName().equals("AADL_with_acc_first_try.js")) { 034// continue; 035// } 036 Triple<AstModel, Scope, Objective[]> p = Javascript.readModel(test); 037 ClaferSolver s = ClaferCompiler.compile(p.getFst(), p.getSnd()); 038// s.getInternalSolver().set(new SevenQueuesPropagatorEngine(s.getInternalSolver())); 039// SevenQueuesPropagatorEngine q = (SevenQueuesPropagatorEngine) s.getInternalSolver().getEngine(); 040// s.getInternalSolver().set(PropagationEngineFactory.PROPAGATORDRIVEN.make(s.getInternalSolver())); 041 if (!s.find()) { 042 throw new Error(test + " failed"); 043 } 044 int c = 0; 045 do { 046 } while (s.find() && c++ < 10); 047 nodeCount += s.getInternalSolver().getMeasures().getNodeCount(); 048 backtrackCount += s.getInternalSolver().getMeasures().getBackTrackCount(); 049 failCount += s.getInternalSolver().getMeasures().getFailCount(); 050 restartCount += s.getInternalSolver().getMeasures().getRestartCount(); 051 eventCount += s.getInternalSolver().getMeasures().getEventsCount(); 052 propagationCount += s.getInternalSolver().getMeasures().getPropagationsCount(); 053 maxDepth += s.getInternalSolver().getMeasures().getMaxDepth(); 054 variables += s.getInternalSolver().getNbVars(); 055 constraints += s.getInternalSolver().getNbCstrs(); 056 } 057 058 //Node: 311 059 //Backtrack: 52 060 //Fail: 36 061 //Restart: 0 062 //Event: 233822 063 //Propagation: 86335 064 //Max depth: 245 065 //Variable: 46527 066 //Constraints: 30455 067 // 068 //Node: 311 069 //Backtrack: 52 070 //Fail: 36 071 //Restart: 0 072 //Event: 233785 073 //Propagation: 86328 074 //Max depth: 245 075 //Variable: 46508 076 //Constraints: 30421 077 // 078 //Node: 311 079 //Backtrack: 52 080 //Fail: 36 081 //Restart: 0 082 //Event: 233713 083 //Propagation: 86255 084 //Max depth: 245 085 //Variable: 46502 086 //Constraints: 30368 087 // 088 //Node: 311 089 //Backtrack: 52 090 //Fail: 36 091 //Restart: 0 092 //Event: 235616 093 //Propagation: 86144 094 //Max depth: 245 095 //Variable: 47165 096 //Constraints: 31866 097 // 098 //Node: 311 099 //Backtrack: 52 100 //Fail: 36 101 //Restart: 0 102 //Event: 235612 103 //Propagation: 86142 104 //Max depth: 245 105 //Variable: 44851 106 //Constraints: 31866 107 // 108 //Node: 311 109 //Backtrack: 52 110 //Fail: 36 111 //Restart: 0 112 //Event: 235587 113 //Propagation: 86141 114 //Max depth: 245 115 //Variable: 44846 116 //Constraints: 31858 117 // 118 //Node: 311 119 //Backtrack: 52 120 //Fail: 36 121 //Restart: 0 122 //Event: 236156 123 //Propagation: 86828 124 //Max depth: 245 125 //Variable: 44831 126 //Constraints: 31839 127 // 128 //Node: 311 129 //Backtrack: 52 130 //Fail: 36 131 //Restart: 0 132 //Event: 236147 133 //Propagation: 86858 134 //Max depth: 245 135 //Variable: 44808 136 //Constraints: 31813 137 // 138 //Node: 310 139 //Backtrack: 52 140 //Fail: 36 141 //Restart: 0 142 //Event: 236064 143 //Propagation: 86960 144 //Max depth: 244 145 //Variable: 44808 146 //Constraints: 31825 147 // 148 //sort set op 149 //Node: 370 150 //Backtrack: 112 151 //Fail: 91 152 //Restart: 0 153 //Event: 249986 154 //Propagation: 93002 155 //Max depth: 299 156 //Variable: 44508 157 //Constraints: 31597 158 // 159 //Node: 370 160 //Backtrack: 112 161 //Fail: 91 162 //Restart: 0 163 //Event: 249965 164 //Propagation: 92988 165 //Max depth: 299 166 //Variable: 44488 167 //Constraints: 31584 168 // 169 //Node: 370 170 //Backtrack: 112 171 //Fail: 91 172 //Restart: 0 173 //Event: 249491 174 //Propagation: 93041 175 //Max depth: 299 176 //Variable: 44484 177 //Constraints: 31532 178 // 179 //Node: 370 180 //Backtrack: 112 181 //Fail: 91 182 //Restart: 0 183 //Event: 245537 184 //Propagation: 93039 185 //Max depth: 299 186 //Variable: 44484 187 //Constraints: 31532 188 // 189 //Node: 370 190 //Backtrack: 112 191 //Fail: 91 192 //Restart: 0 193 //Event: 245532 194 //Propagation: 93039 195 //Max depth: 299 196 //Variable: 44476 197 //Constraints: 31526 198 // 199 //Node: 310 200 //Backtrack: 52 201 //Fail: 36 202 //Restart: 0 203 //Event: 231442 204 //Propagation: 86720 205 //Max depth: 244 206 //Variable: 44403 207 //Constraints: 31453 208 // 209 //Node: 310 210 //Backtrack: 52 211 //Fail: 36 212 //Restart: 0 213 //Event: 231076 214 //Propagation: 86390 215 //Max depth: 244 216 //Variable: 44375 217 //Constraints: 31425 218 // 219 //Node: 310 220 //Backtrack: 52 221 //Fail: 36 222 //Restart: 0 223 //Event: 231085 224 //Propagation: 86390 225 //Max depth: 244 226 //Variable: 44370 227 //Constraints: 31423 228 // 229 //Node: 310 230 //Backtrack: 52 231 //Fail: 36 232 //Restart: 0 233 //Event: 230637 234 //Propagation: 86295 235 //Max depth: 244 236 //Variable: 44154 237 //Constraints: 31194 238 // 239 //Node: 310 240 //Backtrack: 52 241 //Fail: 36 242 //Restart: 0 243 //Event: 230597 244 //Propagation: 86295 245 //Max depth: 244 246 //Variable: 44140 247 //Constraints: 31168 248 // 249 //Node: 310 250 //Backtrack: 52 251 //Fail: 36 252 //Restart: 0 253 //Event: 217483 254 //Propagation: 80513 255 //Max depth: 244 256 //Variable: 40202 257 //Constraints: 28634 258 // 259 //Node: 310 260 //Backtrack: 52 261 //Fail: 36 262 //Restart: 0 263 //Event: 206472 264 //Propagation: 75838 265 //Max depth: 244 266 //Variable: 35914 267 //Constraints: 25862 268 // 269 //Node: 309 270 //Backtrack: 52 271 //Fail: 36 272 //Restart: 0 273 //Event: 206121 274 //Propagation: 75667 275 //Max depth: 243 276 //Variable: 35308 277 //Constraints: 25290 278 // 279 //Node: 309 280 //Backtrack: 52 281 //Fail: 36 282 //Restart: 0 283 //Event: 204860 284 //Propagation: 74312 285 //Max depth: 243 286 //Variable: 34650 287 //Constraints: 24880 288 // 289 //Node: 310 290 //Backtrack: 52 291 //Fail: 36 292 //Restart: 0 293 //Event: 203358 294 //Propagation: 73859 295 //Max depth: 244 296 //Variable: 34212 297 //Constraints: 24754 298 // 299 //Node: 309 300 //Backtrack: 52 301 //Fail: 36 302 //Restart: 0 303 //Event: 202945 304 //Propagation: 73634 305 //Max depth: 243 306 //Variable: 33603 307 //Constraints: 24178 308 // 309 //Node: 309 310 //Backtrack: 52 311 //Fail: 36 312 //Restart: 0 313 //Event: 202309 314 //Propagation: 73443 315 //Max depth: 243 316 //Variable: 33454 317 //Constraints: 24061 318 // 319 //Node: 309 320 //Backtrack: 52 321 //Fail: 36 322 //Restart: 0 323 //Event: 198230 324 //Propagation: 72507 325 //Max depth: 243 326 //Variable: 31762 327 //Constraints: 22844 328 // 329 //Node: 309 330 //Backtrack: 52 331 //Fail: 36 332 //Restart: 0 333 //Event: 194633 334 //Propagation: 72129 335 //Max depth: 243 336 //Variable: 31743 337 //Constraints: 22826 338 // 339 //Node: 309 340 //Backtrack: 52 341 //Fail: 36 342 //Restart: 0 343 //Event: 178262 344 //Propagation: 71093 345 //Max depth: 243 346 //Variable: 30171 347 //Constraints: 21495 348 // 349 //Node: 309 350 //Backtrack: 52 351 //Fail: 36 352 //Restart: 0 353 //Event: 175986 354 //Propagation: 70760 355 //Max depth: 243 356 //Variable: 29098 357 //Constraints: 20558 358 // 359 //Node: 309 360 //Backtrack: 52 361 //Fail: 36 362 //Restart: 0 363 //Event: 175921 364 //Propagation: 70852 365 //Max depth: 243 366 //Variable: 29049 367 //Constraints: 20174 368 // 369 //Node: 309 370 //Backtrack: 52 371 //Fail: 36 372 //Restart: 0 373 //Event: 173997 374 //Propagation: 70141 375 //Max depth: 243 376 //Variable: 29049 377 //Constraints: 20174 378 // 379 //Node: 309 380 //Backtrack: 52 381 //Fail: 36 382 //Restart: 0 383 //Event: 207397 384 //Propagation: 72451 385 //Max depth: 243 386 //Variable: 28995 387 //Constraints: 20173 388 // 389 //Node: 309 390 //Backtrack: 52 391 //Fail: 36 392 //Restart: 0 393 //Event: 205055 394 //Propagation: 71838 395 //Max depth: 243 396 //Variable: 28078 397 //Constraints: 19377 398 // 399 //Node: 309 400 //Backtrack: 52 401 //Fail: 36 402 //Restart: 0 403 //Event: 200318 404 //Propagation: 66675 405 //Max depth: 243 406 //Variable: 27619 407 //Constraints: 18981 408 // 409 //Node: 309 410 //Backtrack: 52 411 //Fail: 36 412 //Restart: 0 413 //Event: 200314 414 //Propagation: 66671 415 //Max depth: 243 416 //Variable: 27506 417 //Constraints: 18980 418 // 419 //Node: 309 420 //Backtrack: 52 421 //Fail: 36 422 //Restart: 0 423 //Event: 200917 424 //Propagation: 66610 425 //Max depth: 243 426 //Variable: 27507 427 //Constraints: 18983 428 // 429 //Node: 307 430 //Backtrack: 50 431 //Fail: 34 432 //Restart: 0 433 //Event: 114589 434 //Propagation: 45471 435 //Max depth: 241 436 //Variable: 20090 437 //Constraints: 14242 438 // 439 //Node: 307 440 //Backtrack: 50 441 //Fail: 34 442 //Restart: 0 443 //Event: 103006 444 //Propagation: 42360 445 //Max depth: 241 446 //Variable: 19244 447 //Constraints: 14242 448 // 449 //Node: 306 450 //Backtrack: 49 451 //Fail: 33 452 //Restart: 0 453 //Event: 98842 454 //Propagation: 41593 455 //Max depth: 240 456 //Variable: 19312 457 //Constraints: 14259 458 // 459 //Node: 306 460 //Backtrack: 49 461 //Fail: 33 462 //Restart: 0 463 //Event: 99307 464 //Propagation: 42161 465 //Max depth: 240 466 //Variable: 19312 467 //Constraints: 14259 468 // 469 //Node: 306 470 //Backtrack: 49 471 //Fail: 33 472 //Restart: 0 473 //Event: 103000 474 //Propagation: 43532 475 //Max depth: 240 476 //Variable: 18791 477 //Constraints: 14185 478 // 479 //Node: 306 480 //Backtrack: 49 481 //Fail: 33 482 //Restart: 0 483 //Event: 102979 484 //Propagation: 43534 485 //Max depth: 240 486 //Variable: 18791 487 //Constraints: 14159 488 // 489 //Node: 306 490 //Backtrack: 49 491 //Fail: 33 492 //Restart: 0 493 //Event: 102971 494 //Propagation: 43534 495 //Max depth: 240 496 //Variable: 18791 497 //Constraints: 14151 498 // 499 //Node: 306 500 //Backtrack: 49 501 //Fail: 33 502 //Restart: 0 503 //Event: 102948 504 //Propagation: 43534 505 //Max depth: 240 506 //Variable: 18776 507 //Constraints: 14136 508 // 509 //Node: 306 510 //Backtrack: 49 511 //Fail: 33 512 //Restart: 0 513 //Event: 79515 514 //Propagation: 31240 515 //Max depth: 240 516 //Variable: 14693 517 //Constraints: 11206 518 // 519 //Node: 306 520 //Backtrack: 49 521 //Fail: 33 522 //Restart: 0 523 //Event: 79139 524 //Propagation: 31244 525 //Max depth: 240 526 //Variable: 14681 527 //Constraints: 10926 528 // 529 //Node: 306 530 //Backtrack: 49 531 //Fail: 33 532 //Restart: 0 533 //Event: 79139 534 //Propagation: 31244 535 //Max depth: 240 536 //Variable: 14404 537 //Constraints: 10926 538 // 539 //Node: 306 540 //Backtrack: 49 541 //Fail: 33 542 //Restart: 0 543 //Event: 108596 544 //Propagation: 31246 545 //Max depth: 240 546 //Variable: 21422 547 //Constraints: 18907 548 // 549 //Node: 306 550 //Backtrack: 49 551 //Fail: 33 552 //Restart: 0 553 //Event: 75662 554 //Propagation: 31238 555 //Max depth: 240 556 //Variable: 13626 557 //Constraints: 10082 558 // 559 //Node: 306 560 //Backtrack: 49 561 //Fail: 33 562 //Restart: 0 563 //Event: 74208 564 //Propagation: 29993 565 //Max depth: 240 566 //Variable: 13366 567 //Constraints: 9875 568 // 569 //Node: 306 570 //Backtrack: 49 571 //Fail: 33 572 //Restart: 0 573 //Event: 74206 574 //Propagation: 29993 575 //Max depth: 240 576 //Variable: 13359 577 //Constraints: 9873 578 // 579 //Node: 306 580 //Backtrack: 49 581 //Fail: 33 582 //Restart: 0 583 //Event: 74199 584 //Propagation: 29993 585 //Max depth: 240 586 //Variable: 13359 587 //Constraints: 9873 588 // 589 //Node: 306 590 //Backtrack: 49 591 //Fail: 33 592 //Restart: 0 593 //Event: 74192 594 //Propagation: 29999 595 //Max depth: 240 596 //Variable: 12207 597 //Constraints: 9873 598 // 599 //Node: 306 600 //Backtrack: 49 601 //Fail: 33 602 //Restart: 0 603 //Event: 73915 604 //Propagation: 29791 605 //Max depth: 240 606 //Variable: 12199 607 //Constraints: 9869 608 // 609 //Node: 306 610 //Backtrack: 49 611 //Fail: 33 612 //Restart: 0 613 //Event: 66243 614 //Propagation: 29294 615 //Max depth: 240 616 //Variable: 12204 617 //Constraints: 9874 618 // 619 //Node: 306 620 //Backtrack: 49 621 //Fail: 33 622 //Restart: 0 623 //Event: 65607 624 //Propagation: 28665 625 //Max depth: 240 626 //Variable: 12204 627 //Constraints: 9874 628 // 629 //Node: 306 630 //Backtrack: 49 631 //Fail: 33 632 //Restart: 0 633 //Event: 66757 634 //Propagation: 29012 635 //Max depth: 240 636 //Variable: 12204 637 //Constraints: 9874 638 // 639 //Node: 306 640 //Backtrack: 49 641 //Fail: 33 642 //Restart: 0 643 //Event: 66299 644 //Propagation: 28993 645 //Max depth: 240 646 //Variable: 12204 647 //Constraints: 9874 648 // 649 //Node: 341 650 //Backtrack: 50 651 //Fail: 34 652 //Restart: 0 653 //Event: 50829 654 //Propagation: 24886 655 //Max depth: 275 656 //Variable: 10605 657 //Constraints: 8594 658 // 659 //Node: 739 660 //Backtrack: 473 661 //Fail: 93 662 //Restart: 0 663 //Event: 63431 664 //Propagation: 29513 665 //Max depth: 405 666 //Variable: 10605 667 //Constraints: 8594 668 // 669 //Node: 739 670 //Backtrack: 473 671 //Fail: 93 672 //Restart: 0 673 //Event: 61865 674 //Propagation: 29527 675 //Max depth: 405 676 //Variable: 9789 677 //Constraints: 7887 678 // 679 //Node: 739 680 //Backtrack: 473 681 //Fail: 93 682 //Restart: 0 683 //Event: 61489 684 //Propagation: 29339 685 //Max depth: 405 686 //Variable: 9623 687 //Constraints: 7829 688 // 689 //Node: 739 690 //Backtrack: 473 691 //Fail: 93 692 //Restart: 0 693 //Event: 61394 694 //Propagation: 29329 695 //Max depth: 405 696 //Variable: 9623 697 //Constraints: 7829 698 // 699 //Node: 739 700 //Backtrack: 473 701 //Fail: 93 702 //Restart: 0 703 //Event: 59990 704 //Propagation: 28051 705 //Max depth: 405 706 //Variable: 9623 707 //Constraints: 7829 708 // 709 //Node: 739 710 //Backtrack: 473 711 //Fail: 93 712 //Restart: 0 713 //Event: 59924 714 //Propagation: 28039 715 //Max depth: 405 716 //Variable: 9596 717 //Constraints: 7800 718 // 719 //Node: 739 720 //Backtrack: 473 721 //Fail: 93 722 //Restart: 0 723 //Event: 58546 724 //Propagation: 27946 725 //Max depth: 405 726 //Variable: 9340 727 //Constraints: 7658 728 // 729 //Node: 739 730 //Backtrack: 473 731 //Fail: 93 732 //Restart: 0 733 //Event: 57961 734 //Propagation: 27920 735 //Max depth: 405 736 //Variable: 9344 737 //Constraints: 7661 738 System.out.println("Node: " + nodeCount + "\nBacktrack: " + backtrackCount 739 + "\nFail: " + failCount + "\nRestart: " + restartCount + "\nEvent: " + eventCount 740 + "\nPropagation: " + propagationCount + "\nMax depth: " + maxDepth 741 + "\nVariable: " + variables + "\nConstraints: " + constraints); 742 } 743}