Changeset 373 for branches/alta/mystic-0.2a1/test_constraints_tp6.py
- Timestamp:
- 08/04/10 16:07:50 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/alta/mystic-0.2a1/test_constraints_tp6.py
r364 r373 8 8 Mystic Results: 9 9 --------------- 10 Results below are after testing different termination conditions and using 11 ones that worked, if any worked. 12 10 13 Differential Evolution, penalty 11 soln= [ 0.9 3185794 0.86835217]12 f value = 0.0046433404361213 Time elapsed= 3.2249720096614 -7.04931582951e-05?= 0.014 soln= [ 0.99999626 0.99999252] 15 f value = 1.39955330985e-11 16 Time elapsed= 1.82334899902 17 2.74909317532e-08 ?= 0.0 15 18 True 16 19 … … 18 21 soln= [ 0.77856495 0.6061442 ] 19 22 f value = 0.0490334793345 20 Time elapsed= 5.5333449840523 Time elapsed= 2.31935405731 21 24 -0.000191837517554 ?= 0.0 22 25 True … … 25 28 soln= [-0.79924969 0.63882551] 26 29 f value = 3.23729944276 27 Time elapsed= 0. 17318797111530 Time elapsed= 0.0765020847321 28 31 0.000254426113928 ?= 0.0 29 32 True … … 32 35 soln= [-0.54298813 0.29474638] 33 36 f value = 2.3808123589 34 Time elapsed= 0. 69313001632737 Time elapsed= 0.30738401413 35 38 -0.000897233040719 ?= 0.0 36 39 True … … 39 42 soln= [-1.2 1. ] 40 43 f value = 4.84 41 Time elapsed= 0. 34726500511244 Time elapsed= 0.158123016357 42 45 -4.4 ?= 0.0 43 46 False 44 47 45 48 NCG, penalty 46 soln= [-1.0344 0639 1.06999695]47 f value = 4.13 88093601448 Time elapsed= 0. 59188818931649 3.72762859691e-06?= 0.049 soln= [-1.03447871 1.07014734] 50 f value = 4.13910362412 51 Time elapsed= 0.00758099555969 52 1.13919376488e-05 ?= 0.0 50 53 True 51 54 … … 53 56 soln= [ 0.2151731 0.04624554] 54 57 f value = 0.615953267272 55 Time elapsed= 0. 50745415687658 Time elapsed= 0.318397045135 56 59 -0.000539243908523 ?= 0.0 57 60 True 58 61 59 62 DifferentialEvolution, auglag 60 soln= [ 1.0265255 1.05539154] 61 f value = 0.000703602183114 62 Time elapsed= 0.444896936417 63 0.0163693695118 ?= 0.0 63 soln= [ 1.00001488 1.00002945] 64 f value = 2.21482471957e-10 65 Time elapsed= 0.617501974106 66 -3.15108766635e-06 ?= 0.0 67 True 68 69 DifferentialEvolution2, auglag 70 soln= [ 1.00000246 1.00000481] 71 f value = 6.04295189197e-12 72 Time elapsed= 0.828866958618 73 -1.08042532698e-06 ?= 0.0 74 True 75 76 NelderMead, auglag 77 soln= [ 0.99999706 0.99999401] 78 f value = 8.62311013723e-12 79 Time elapsed= 0.106360912323 80 -1.15163547698e-06 ?= 0.0 81 True 82 83 PowellDirectional, auglag 84 soln= [ 1. 1.] 85 f value = 0.0 86 Time elapsed= 0.686278104782 87 0.0 ?= 0.0 88 True 89 90 BFGS, auglag 91 soln= [ 0.99999077 0.99998178] 92 f value = 8.51914601677e-11 93 Time elapsed= 0.0958249568939 94 2.39940897706e-06 ?= 0.0 95 True 96 97 NCG, auglag 98 soln= [-0.23107736 0.05350618] 99 f value = 1.51555147832 100 Time elapsed= 32.7819998264 101 0.00109432112118 ?= 0.0 64 102 False 65 103 66 DifferentialEvolution2, auglag67 soln= [ 0.95122535 0.90491171]68 f value = 0.0023789663101169 Time elapsed= 0.69688105583270 0.000820387523576 ?= 0.071 True72 73 NelderMead, auglag74 soln= [ 0.9665114 0.93380755]75 f value = 0.0011214865345576 Time elapsed= 0.14950513839777 -0.00336728044141 ?= 0.078 False79 80 PowellDirectional, auglag81 soln= [ 0.97953372 0.9594863 ]82 f value = 0.00041886869823883 Time elapsed= 0.57073807716484 -1.11022302463e-15 ?= 0.085 True86 87 BFGS, auglag88 soln= [ 0.95481343 0.91217455]89 f value = 0.0020418258347590 Time elapsed= 0.16470813751291 0.00505859260701 ?= 0.092 False93 94 NCG gets stuck95 96 104 CG, auglag 97 soln= [ 0.9 5841557 0.91844345]98 f value = 0.0017292646143499 Time elapsed= 0. 449685096741100 - 0.0011695707853?= 0.0101 False105 soln= [ 0.99997764 0.99995528] 106 f value = 4.99909986311e-10 107 Time elapsed= 0.253920793533 108 -6.79715139729e-08 ?= 0.0 109 True 102 110 103 111 … … 157 165 from mystic.termination import VTR 158 166 from mystic.termination import CandidateRelativeTolerance as CRT 167 from mystic.termination import ChangeOverGeneration as COG 159 168 solver = DifferentialEvolutionSolver(ndim, npop) 160 169 161 170 solver.SetInitialPoints(x0) 162 171 solver.enable_signal_handler() 163 term = VTR() 164 #term = CRT() 172 #term = VTR() # must specify tol=0 173 #term = CRT() # works well 174 term = COG() # works well 165 175 solver.Solve(costfunc, term, constraints=constraints_string, \ 166 176 constraints_method='penalty') … … 190 200 from mystic.termination import CandidateRelativeTolerance as CRT 191 201 from mystic.termination import ChangeOverGeneration as COG 202 from mystic.termination import NormalizedChangeOverGeneration as NCOG 203 from mystic.strategy import Rand1Bin 204 205 npop = 70 # Won't work unless npop is large 192 206 solver = DifferentialEvolutionSolver2(ndim, npop) 193 207 194 208 solver.SetInitialPoints(x0) 195 209 solver.enable_signal_handler() 196 term = VTR() 197 #term = CRT() 198 #term = COG() 210 #term = VTR() # must specify tol=0 211 #term = CRT() # bad 212 term = COG() # bad 213 #term = NCOG() # bad 199 214 solver.Solve(costfunc, term, constraints=constraints_string, \ 200 215 constraints_method='penalty') … … 224 239 from mystic.termination import ChangeOverGeneration as COG 225 240 from mystic.termination import NormalizedChangeOverGeneration as NCOG 241 from mystic.termination import CandidateRelativeTolerance as CRT 226 242 solver = NelderMeadSimplexSolver(ndim) 227 243 228 244 solver.SetInitialPoints(x0) 229 245 solver.enable_signal_handler() 230 term = VTR() # does not work well246 #term = VTR(0) # must specify tol=0 231 247 #term = COG() # does not work well 232 248 #term = NCOG() # does not work well 249 term = CRT() # bad 233 250 solver.Solve(costfunc, term, constraints=constraints_string, \ 234 251 constraints_method='penalty') … … 257 274 from mystic.termination import VTR 258 275 from mystic.termination import ChangeOverGeneration as COG 276 from mystic.termination import NormalizedChangeOverGeneration as NCOG 259 277 solver = PowellDirectionalSolver(ndim) 260 278 261 279 solver.SetInitialPoints(x0) 262 280 solver.enable_signal_handler() 263 term = VTR() 264 #term = COG() 281 #term = VTR(0) # must specify tol=0 282 #term = COG() # bad 283 term = NCOG() # bad 265 284 solver.Solve(costfunc, term, constraints=constraints_string, \ 266 285 constraints_method='penalty') … … 289 308 from mystic.termination import VTR 290 309 from mystic.termination import GradientTermination 310 from mystic.termination import ChangeOverGeneration as COG 291 311 solver = BFGSSolver(ndim) 292 312 293 313 solver.SetInitialPoints(x0) 294 314 solver.enable_signal_handler() 295 term = VTR() 296 #term = GradientTermination() 315 #term = VTR(0) # must specify tol=0 316 term = GradientTermination() # doesn't iterate 317 #term = COG() # doesn't iterate 297 318 solver.Solve(costfunc, term, constraints=constraints_string, \ 298 319 constraints_method='penalty')#, penalty=1e3) … … 320 341 from scipy_ncg import NCGSolver 321 342 from mystic.termination import VTR 343 from mystic.termination import ChangeOverGeneration as COG 344 from mystic.termination import SolutionImprovement 322 345 solver = NCGSolver(ndim) 323 346 324 347 solver.SetInitialPoints(x0) 325 348 solver.enable_signal_handler() 326 term = VTR() 349 #term = VTR(0) # must specify tol=0 350 #term = COG() # bad 351 term = SolutionImprovement() # local min 327 352 solver.Solve(costfunc, term, constraints=constraints_string, \ 328 353 constraints_method='penalty') … … 352 377 from mystic.termination import GradientTermination 353 378 from mystic.termination import ChangeOverGeneration as COG 379 from mystic.termination import NormalizedChangeOverGeneration as NCOG 354 380 solver = CGSolver(ndim) 355 381 356 382 solver.SetInitialPoints(x0) 357 383 solver.enable_signal_handler() 358 term = VTR() # doesn't work359 #term = GradientTermination() # doesn't help384 #term = VTR(0) # must specify tol=0 385 term = GradientTermination() # doesn't help 360 386 #term = COG() # doesn't work either 361 solver.Solve(costfunc, term, constraints=constraints_string, \ 362 constraints_method='penalty')#, penalty=1e3) 387 #term = NCOG() # bad 388 solver.Solve(costfunc, term, constraints=constraints_string, \ 389 constraints_method='penalty')#, penalty=1e7) 363 390 soln = solver.Solution() 364 391 … … 391 418 solver.SetInitialPoints(x0) 392 419 solver.enable_signal_handler() 393 term = VTR()394 #term = CRT()420 #term = VTR(0) # must specify tol=0 421 term = CRT() # works well 395 422 solver.Solve(costfunc, term, constraints=constraints_string, \ 396 423 constraints_method='auglag') … … 423 450 solver.SetInitialPoints(x0) 424 451 solver.enable_signal_handler() 425 term = VTR()426 #term = CRT()452 #term = VTR(0) # must specify tol=0 453 term = CRT() # works well 427 454 solver.Solve(costfunc, term, constraints=constraints_string, \ 428 455 constraints_method='auglag') … … 456 483 solver.SetInitialPoints(x0) 457 484 solver.enable_signal_handler() 458 term = VTR() # gives answer that is a bit off459 #term = COG() # works well485 #term = VTR(0) # must specify tol=0 486 term = COG() # works well 460 487 solver.Solve(costfunc, term, constraints=constraints_string, \ 461 488 constraints_method='auglag') … … 488 515 solver.SetInitialPoints(x0) 489 516 solver.enable_signal_handler() 490 term = VTR() # gives answer that is a bit off491 #term = COG() # works well517 #term = VTR(0) # must specify tol=0 518 term = COG() # works well 492 519 solver.Solve(costfunc, term, constraints=constraints_string, \ 493 520 constraints_method='auglag') … … 519 546 solver.SetInitialPoints(x0) 520 547 solver.enable_signal_handler() 521 term = VTR() # gives answer that is quite off522 #term = GradientTermination() # works well548 #term = VTR(0) # must specify tol=0 549 term = GradientTermination() # works well 523 550 solver.Solve(costfunc, term, constraints=constraints_string, \ 524 551 constraints_method='auglag') … … 547 574 from mystic.termination import VTR 548 575 from mystic.termination import SolutionImprovement 576 from mystic.termination import ChangeOverGeneration as COG 549 577 solver = NCGSolver(ndim) 550 578 551 579 solver.SetInitialPoints(x0) 552 580 solver.enable_signal_handler() 553 term = VTR() # doesn't work581 #term = VTR(0) # must specify tol=0 554 582 #term = SolutionImprovement() # doesn't help 583 term = COG() # works well 555 584 solver.Solve(costfunc, term, constraints=constraints_string, \ 556 585 constraints_method='auglag') … … 582 611 solver.SetInitialPoints(x0) 583 612 solver.enable_signal_handler() 584 term = VTR() # gives answer that is a bit off585 #term = COG() # much better613 #term = VTR(0) # must specify tol=0 614 term = COG() # much better 586 615 solver.Solve(costfunc, term, constraints=constraints_string, \ 587 616 constraints_method='auglag') … … 598 627 599 628 if __name__ == '__main__': 600 # All tests do poorly with defaults. 601 test_diffev_penalty() # good with CRT 602 test_diffev2_penalty() # really won't work 603 test_neldermead_penalty() # off 604 test_powelldirectional_penalty() # off 605 test_bfgs_penalty() # needs penalty=1e3 and GradientTermination 606 test_ncg_penalty() # off 607 test_cg_penalty() # off 608 609 test_diffev_auglag() # good with CRT 610 test_diffev2_auglag() # good with CRT 611 test_neldermead_auglag() # good with COG 612 test_powelldirectional_auglag() # good with COG 613 test_bfgs_auglag() # good with GradientTermination 614 test_ncg_auglag() # stuck 615 test_cg_auglag() # good with COG 629 # All tests do poorly with defaults because VTR has a default tol of 0.005, 630 # and f(minimum) here is 0. 631 test_diffev_penalty() 632 test_diffev2_penalty() # need to increase npop 633 test_neldermead_penalty() # bad answer; higher penalty -> local min 634 test_powelldirectional_penalty() # bad answer; higher penalty -> local min 635 test_bfgs_penalty() # needs lower penalty 636 test_ncg_penalty() # local min 637 test_cg_penalty() # quite bad; higher penalty -> local min 638 639 test_diffev_auglag() 640 test_diffev2_auglag() 641 test_neldermead_auglag() 642 test_powelldirectional_auglag() 643 test_bfgs_auglag() 644 test_ncg_auglag() # takes a very long time, and bad answer 645 test_cg_auglag() 616 646 print "expected: [1., 1.]" 617 647
Note: See TracChangeset
for help on using the changeset viewer.