pyfemtet 0.4.25__py3-none-any.whl → 0.5.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pyfemtet might be problematic. Click here for more details.

Files changed (117) hide show
  1. pyfemtet/__init__.py +1 -1
  2. pyfemtet/message/locales/ja/LC_MESSAGES/messages.mo +0 -0
  3. pyfemtet/message/locales/ja/LC_MESSAGES/messages.po +114 -62
  4. pyfemtet/message/locales/messages.pot +114 -62
  5. pyfemtet/message/messages.py +6 -2
  6. pyfemtet/opt/__init__.py +2 -2
  7. pyfemtet/opt/_femopt.py +27 -46
  8. pyfemtet/opt/_femopt_core.py +50 -33
  9. pyfemtet/opt/_test_utils/__init__.py +0 -0
  10. pyfemtet/opt/_test_utils/control_femtet.py +45 -0
  11. pyfemtet/opt/_test_utils/hyper_sphere.py +24 -0
  12. pyfemtet/opt/_test_utils/record_history.py +72 -0
  13. pyfemtet/opt/interface/_femtet.py +39 -1
  14. pyfemtet/opt/optimizer/__init__.py +12 -0
  15. pyfemtet/opt/{opt → optimizer}/_base.py +30 -9
  16. pyfemtet/opt/{opt → optimizer}/_optuna.py +14 -33
  17. pyfemtet/opt/optimizer/_optuna_botorchsampler_parameter_constraint_helper.py +325 -0
  18. pyfemtet/opt/{opt → optimizer}/_scipy.py +10 -6
  19. pyfemtet/opt/{opt → optimizer}/_scipy_scalar.py +24 -12
  20. pyfemtet/opt/samples/femprj_sample/constrained_pipe.femprj +0 -0
  21. pyfemtet/opt/samples/femprj_sample/constrained_pipe.py +97 -0
  22. pyfemtet/opt/samples/femprj_sample/constrained_pipe_test_result.reccsv +13 -0
  23. pyfemtet/opt/{femprj_sample → samples/femprj_sample}/gal_ex58_parametric_test_result.reccsv +1 -1
  24. pyfemtet/opt/{femprj_sample → samples/femprj_sample}/her_ex40_parametric.py +10 -8
  25. pyfemtet/opt/samples/femprj_sample/her_ex40_parametric_test_result.reccsv +18 -0
  26. pyfemtet/opt/samples/femprj_sample_jp/constrained_pipe_jp.py +93 -0
  27. pyfemtet/opt/{femprj_sample_jp → samples/femprj_sample_jp}/her_ex40_parametric_jp.py +10 -8
  28. pyfemtet/opt/visualization/complex_components/main_figure_creator.py +69 -0
  29. pyfemtet/opt/visualization/complex_components/main_graph.py +299 -14
  30. pyfemtet/opt/visualization/process_monitor/pages.py +1 -1
  31. pyfemtet/opt/visualization/result_viewer/application.py +1 -1
  32. pyfemtet/opt/visualization/result_viewer/pages.py +9 -9
  33. {pyfemtet-0.4.25.dist-info → pyfemtet-0.5.1.dist-info}/METADATA +1 -1
  34. pyfemtet-0.5.1.dist-info/RECORD +115 -0
  35. pyfemtet/_test_util.py +0 -135
  36. pyfemtet/opt/femprj_sample/ParametricIF - True.femprj +0 -0
  37. pyfemtet/opt/femprj_sample/her_ex40_parametric_test_result.reccsv +0 -18
  38. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14.pdt +0 -0
  39. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial1.jpg +0 -0
  40. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial1.pdt +0 -0
  41. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial10.jpg +0 -0
  42. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial10.pdt +0 -0
  43. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial11.jpg +0 -0
  44. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial11.pdt +0 -0
  45. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial12.jpg +0 -0
  46. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial12.pdt +0 -0
  47. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial13.jpg +0 -0
  48. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial13.pdt +0 -0
  49. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial14.jpg +0 -0
  50. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial14.pdt +0 -0
  51. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial15.jpg +0 -0
  52. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial15.pdt +0 -0
  53. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial2.jpg +0 -0
  54. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial2.pdt +0 -0
  55. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial3.jpg +0 -0
  56. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial3.pdt +0 -0
  57. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial4.jpg +0 -0
  58. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial4.pdt +0 -0
  59. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial5.jpg +0 -0
  60. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial5.pdt +0 -0
  61. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial6.jpg +0 -0
  62. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial6.pdt +0 -0
  63. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial7.jpg +0 -0
  64. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial7.pdt +0 -0
  65. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial8.jpg +0 -0
  66. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial8.pdt +0 -0
  67. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial9.jpg +0 -0
  68. pyfemtet/opt/femprj_sample/wat_ex14_parametric.Results/Ex14_trial9.pdt +0 -0
  69. pyfemtet/opt/opt/__init__.py +0 -12
  70. pyfemtet/opt/opt/_optuna_botorch_helper.py +0 -209
  71. pyfemtet-0.4.25.dist-info/RECORD +0 -140
  72. /pyfemtet/opt/{femprj_sample → samples/femprj_sample}/.gitignore +0 -0
  73. /pyfemtet/opt/{femprj_sample → samples/femprj_sample}/ParametricIF.femprj +0 -0
  74. /pyfemtet/opt/{femprj_sample → samples/femprj_sample}/ParametricIF.py +0 -0
  75. /pyfemtet/opt/{femprj_sample → samples/femprj_sample}/ParametricIF_test_result.reccsv +0 -0
  76. /pyfemtet/opt/{femprj_sample → samples/femprj_sample}/cad_ex01_NX.femprj +0 -0
  77. /pyfemtet/opt/{femprj_sample → samples/femprj_sample}/cad_ex01_NX.prt +0 -0
  78. /pyfemtet/opt/{femprj_sample → samples/femprj_sample}/cad_ex01_NX.py +0 -0
  79. /pyfemtet/opt/{femprj_sample → samples/femprj_sample}/cad_ex01_NX_test_result.reccsv +0 -0
  80. /pyfemtet/opt/{femprj_sample → samples/femprj_sample}/cad_ex01_SW.SLDPRT +0 -0
  81. /pyfemtet/opt/{femprj_sample → samples/femprj_sample}/cad_ex01_SW.femprj +0 -0
  82. /pyfemtet/opt/{femprj_sample → samples/femprj_sample}/cad_ex01_SW.py +0 -0
  83. /pyfemtet/opt/{femprj_sample → samples/femprj_sample}/cad_ex01_SW_test_result.reccsv +0 -0
  84. /pyfemtet/opt/{femprj_sample → samples/femprj_sample}/gal_ex58_parametric.femprj +0 -0
  85. /pyfemtet/opt/{femprj_sample → samples/femprj_sample}/gal_ex58_parametric.py +0 -0
  86. /pyfemtet/opt/{femprj_sample → samples/femprj_sample}/gau_ex08_parametric.femprj +0 -0
  87. /pyfemtet/opt/{femprj_sample → samples/femprj_sample}/gau_ex08_parametric.py +0 -0
  88. /pyfemtet/opt/{femprj_sample → samples/femprj_sample}/gau_ex08_parametric_test_result.reccsv +0 -0
  89. /pyfemtet/opt/{femprj_sample → samples/femprj_sample}/her_ex40_parametric.femprj +0 -0
  90. /pyfemtet/opt/{femprj_sample → samples/femprj_sample}/paswat_ex1_parametric.femprj +0 -0
  91. /pyfemtet/opt/{femprj_sample → samples/femprj_sample}/paswat_ex1_parametric.py +0 -0
  92. /pyfemtet/opt/{femprj_sample → samples/femprj_sample}/paswat_ex1_parametric_parallel.py +0 -0
  93. /pyfemtet/opt/{femprj_sample → samples/femprj_sample}/paswat_ex1_parametric_test_result.reccsv +0 -0
  94. /pyfemtet/opt/{femprj_sample → samples/femprj_sample}/wat_ex14_parametric.femprj +0 -0
  95. /pyfemtet/opt/{femprj_sample → samples/femprj_sample}/wat_ex14_parametric.py +0 -0
  96. /pyfemtet/opt/{femprj_sample → samples/femprj_sample}/wat_ex14_parametric_parallel.py +0 -0
  97. /pyfemtet/opt/{femprj_sample → samples/femprj_sample}/wat_ex14_parametric_test_result.reccsv +0 -0
  98. /pyfemtet/opt/{femprj_sample_jp → samples/femprj_sample_jp}/ParametricIF_jp.femprj +0 -0
  99. /pyfemtet/opt/{femprj_sample_jp → samples/femprj_sample_jp}/ParametricIF_jp.py +0 -0
  100. /pyfemtet/opt/{femprj_sample_jp → samples/femprj_sample_jp}/cad_ex01_NX_jp.femprj +0 -0
  101. /pyfemtet/opt/{femprj_sample_jp → samples/femprj_sample_jp}/cad_ex01_NX_jp.py +0 -0
  102. /pyfemtet/opt/{femprj_sample_jp → samples/femprj_sample_jp}/cad_ex01_SW_jp.femprj +0 -0
  103. /pyfemtet/opt/{femprj_sample_jp → samples/femprj_sample_jp}/cad_ex01_SW_jp.py +0 -0
  104. /pyfemtet/opt/{femprj_sample_jp → samples/femprj_sample_jp}/gal_ex58_parametric_jp.femprj +0 -0
  105. /pyfemtet/opt/{femprj_sample_jp → samples/femprj_sample_jp}/gal_ex58_parametric_jp.py +0 -0
  106. /pyfemtet/opt/{femprj_sample_jp → samples/femprj_sample_jp}/gau_ex08_parametric_jp.femprj +0 -0
  107. /pyfemtet/opt/{femprj_sample_jp → samples/femprj_sample_jp}/gau_ex08_parametric_jp.py +0 -0
  108. /pyfemtet/opt/{femprj_sample_jp → samples/femprj_sample_jp}/her_ex40_parametric_jp.femprj +0 -0
  109. /pyfemtet/opt/{femprj_sample_jp → samples/femprj_sample_jp}/paswat_ex1_parametric_jp.femprj +0 -0
  110. /pyfemtet/opt/{femprj_sample_jp → samples/femprj_sample_jp}/paswat_ex1_parametric_jp.py +0 -0
  111. /pyfemtet/opt/{femprj_sample_jp → samples/femprj_sample_jp}/paswat_ex1_parametric_parallel_jp.py +0 -0
  112. /pyfemtet/opt/{femprj_sample_jp → samples/femprj_sample_jp}/wat_ex14_parametric_jp.femprj +0 -0
  113. /pyfemtet/opt/{femprj_sample_jp → samples/femprj_sample_jp}/wat_ex14_parametric_jp.py +0 -0
  114. /pyfemtet/opt/{femprj_sample_jp → samples/femprj_sample_jp}/wat_ex14_parametric_parallel_jp.py +0 -0
  115. {pyfemtet-0.4.25.dist-info → pyfemtet-0.5.1.dist-info}/LICENSE +0 -0
  116. {pyfemtet-0.4.25.dist-info → pyfemtet-0.5.1.dist-info}/WHEEL +0 -0
  117. {pyfemtet-0.4.25.dist-info → pyfemtet-0.5.1.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,115 @@
1
+ pyfemtet/__init__.py,sha256=PQu9BZ4UZrI--6Rc-s0RhFPPEWVTqddrgsWkwYl87dI,21
2
+ pyfemtet/core.py,sha256=3lqfBGJ5IuKz2Nqj5pRo7YQqKwx_0ZDL72u95Ur_1p0,1386
3
+ pyfemtet/dispatch_extensions.py,sha256=XVZajbjh7mb6NG4Hq8qff2TJWab75r4Hd59cIvCRsVg,16213
4
+ pyfemtet/logger.py,sha256=JYD0FvzijMS2NvZN7VT7vZA5hqtHEkvS93AHlIMDePw,2507
5
+ pyfemtet/message/1. make_pot.bat,sha256=oS38xYsaUnQAuKwUR8hZJFgt3AKBU993fWFDSg2ROz4,570
6
+ pyfemtet/message/2. make_mo.bat,sha256=nqUi3Cze7JGKkYItlch8ZG2gSbRNZiS2ltuCS7DbmG8,154
7
+ pyfemtet/message/__init__.py,sha256=gE1-XX_PzHj9BbhqPaK5VcIHuv6_Tec5qlPMC3IRiBg,100
8
+ pyfemtet/message/babel.cfg,sha256=rlvsm_EjDU2ki-OLVPG3toWspVuVA0JFAFvFp2U-By4,72
9
+ pyfemtet/message/locales/ja/LC_MESSAGES/messages.mo,sha256=hbW3KO524_lFYIhU-QGMhHMW4LHnxyecnptFD55ECMo,18332
10
+ pyfemtet/message/locales/ja/LC_MESSAGES/messages.po,sha256=f8rimJEqmLdlrE7JBwETm-Gq2-USOZcSEpnzMqBqk88,23617
11
+ pyfemtet/message/locales/messages.pot,sha256=_gVMy6qaSU7Qu6zIY8KQizb1XpTZ0ijLKbnnk4lAAdg,13635
12
+ pyfemtet/message/messages.py,sha256=i0cOOV8NnBeT1gG-tqgnu_3dIym1hZG8Hzg38sh_Qeo,13187
13
+ pyfemtet/opt/__init__.py,sha256=MPrUWeLZLrJ-ApVckn8dsn3QmRH13aPzit5JgaoshG8,696
14
+ pyfemtet/opt/_femopt.py,sha256=V1D0n8WgzDRE6NbvRzJdhxXiqHh7GGRAmvS7jyQDGfA,26611
15
+ pyfemtet/opt/_femopt_core.py,sha256=ocn7qOMCDRXuS-3DRXgGIo1hGnewUYSUxE7BuvqCXMY,27858
16
+ pyfemtet/opt/_test_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
+ pyfemtet/opt/_test_utils/control_femtet.py,sha256=Oy2MmNS-LhUXF9rKLa8AXAfJhppIQI8Nha8LmEZflmk,1169
18
+ pyfemtet/opt/_test_utils/hyper_sphere.py,sha256=nQhw8EIY0DwvcTqrbKhkxiITLZifr4-nG77E-_6ggmA,700
19
+ pyfemtet/opt/_test_utils/record_history.py,sha256=qg5kNURiFHr40YN4f4s9Q6JNed-1y5ysQFXwIbYpKZw,2512
20
+ pyfemtet/opt/interface/__init__.py,sha256=qz5BszPuU3jZIoDnPjkPDAgvgHLlx1sYhuqh5ID798k,480
21
+ pyfemtet/opt/interface/_base.py,sha256=I4pJttLeRW-6WWMuCNynwxWPwriiGZk20vHLVcfixZY,2332
22
+ pyfemtet/opt/interface/_femtet.py,sha256=PjmwRpkY99i4Tstva6ahlG8beqQytkJsAbT9nU_d64A,35956
23
+ pyfemtet/opt/interface/_femtet_parametric.py,sha256=KDG8SB43AgwuhpCStjvx10G0RzyHhga6k4dfvp0gvYU,2175
24
+ pyfemtet/opt/interface/_femtet_with_nx/__init__.py,sha256=-6W2g2FDEcKzGHmI5KAKQe-4U5jDpMj0CXuma-GZca0,83
25
+ pyfemtet/opt/interface/_femtet_with_nx/_interface.py,sha256=cibPOhsUAvTDJa1xdEhVClZjwPkEx2kBmi61vyTJHUs,5514
26
+ pyfemtet/opt/interface/_femtet_with_nx/update_model.py,sha256=P7VH0i_o-X9OUe6AGaLF1fACPeHNrMjcrOBCA3MMrI4,3092
27
+ pyfemtet/opt/interface/_femtet_with_sldworks.py,sha256=Ldr8Esa5xZ-D_E5uIXBTF2DHslXVMFDYOsqTd8FhY1M,6242
28
+ pyfemtet/opt/optimizer/__init__.py,sha256=wdz7PXkcSJ9Z2OHoegfGvYrnj_OAyU39BvDyiy3QnVw,407
29
+ pyfemtet/opt/optimizer/_base.py,sha256=lKCDGoAtOLwqNaP7qfqYJ69AHxq9YZVivTP14VHYxZU,12136
30
+ pyfemtet/opt/optimizer/_optuna.py,sha256=MojfB0oQCjSzS-hJNiD_Wn-vPDJbsMUydMq2ht6Ww9g,11570
31
+ pyfemtet/opt/optimizer/_optuna_botorchsampler_parameter_constraint_helper.py,sha256=6um5tdhpMirzwAPmp_K_YluguP0W9dWPwHJIqWICeOM,11908
32
+ pyfemtet/opt/optimizer/_scipy.py,sha256=M3q25VuRazDzXUWC25z7hGbNq2Qg9158NjTSNBvi2pk,4347
33
+ pyfemtet/opt/optimizer/_scipy_scalar.py,sha256=YmErX4s_ywVIn861-D06d-TvDWi0rp843Jit3x80qtU,3202
34
+ pyfemtet/opt/parameter.py,sha256=YLE9lmYRaZA8isnTPJnbYXpUn6zsJFW4xg03QaSWey8,3950
35
+ pyfemtet/opt/prediction/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
+ pyfemtet/opt/prediction/base.py,sha256=q4lDqrOtAkiWG-OblQEddnEVj29Q-EJE3-O5QTOb3Q4,1761
37
+ pyfemtet/opt/prediction/single_task_gp.py,sha256=VbsVllzXzCGqkM1fC61Ouqwuv3ddS5INbFwDG8v-d6g,3303
38
+ pyfemtet/opt/samples/femprj_sample/.gitignore,sha256=hx-5Hhaf7kpHe1wvWWfJqjPfObg-zf9CTI4joNh2Hk4,28
39
+ pyfemtet/opt/samples/femprj_sample/ParametricIF.femprj,sha256=9BtDHmc3cdom0Zq33DTdZ0mDAsIUY6i8SRkkg-n7GO0,442090
40
+ pyfemtet/opt/samples/femprj_sample/ParametricIF.py,sha256=oXzchBZEbH69xacDht5HDnbZzKwapXsn6bp9qihY17Y,707
41
+ pyfemtet/opt/samples/femprj_sample/ParametricIF_test_result.reccsv,sha256=TiOAqEDMub6SCGYClBv1JvQxphDOY3iIdr_pMmGgJ9M,2859
42
+ pyfemtet/opt/samples/femprj_sample/cad_ex01_NX.femprj,sha256=KC8JlHqHzqgyKriK911QSnQByQpRlw-SX5OSQ_GNe5M,149193
43
+ pyfemtet/opt/samples/femprj_sample/cad_ex01_NX.prt,sha256=3okHLeMdslrRA_wkhppZtxIe-2-ZPMfNqWCdQwUV31o,226626
44
+ pyfemtet/opt/samples/femprj_sample/cad_ex01_NX.py,sha256=_wrpHQ6NlNJ9js0PwR3tfuxXt5fxORTa9h8BvjiWOcg,4621
45
+ pyfemtet/opt/samples/femprj_sample/cad_ex01_NX_test_result.reccsv,sha256=hFxjat32G71F3XE_UtC9zzi5HZxu0Q0MXjU9e1xVIDM,4710
46
+ pyfemtet/opt/samples/femprj_sample/cad_ex01_SW.SLDPRT,sha256=jjBi4aRRwZPK-4-YRKDC4eO_Ch2jwd7M7chvJlnBbZU,97158
47
+ pyfemtet/opt/samples/femprj_sample/cad_ex01_SW.femprj,sha256=knN0bBTHm5CqExLdmxdJvPldJ6ahnQesKt974qRjWh4,126837
48
+ pyfemtet/opt/samples/femprj_sample/cad_ex01_SW.py,sha256=JoGQSwH3yJnABxyd-WJfrwMkhd1UV0yYF2L2RvMFXmc,4559
49
+ pyfemtet/opt/samples/femprj_sample/cad_ex01_SW_test_result.reccsv,sha256=NS0Zik2c1mbMdGa0hGJaRQdCD08Bltx84n9QzP5CjPo,4736
50
+ pyfemtet/opt/samples/femprj_sample/constrained_pipe.femprj,sha256=MAl-VQfethwYvl49RkuW7FQlFCQ9_mYvc03SsqBCad0,57414
51
+ pyfemtet/opt/samples/femprj_sample/constrained_pipe.py,sha256=-9LYdLQ4MEsdt9FAzaqhtRPwBQN5mnsXcOMyNqsv5Iw,3217
52
+ pyfemtet/opt/samples/femprj_sample/constrained_pipe_test_result.reccsv,sha256=AbAMXLtxrEBHLjdM0HnGQ7j3uJtVHZpxOZxOqNmO1CA,1796
53
+ pyfemtet/opt/samples/femprj_sample/gal_ex58_parametric.femprj,sha256=dbanN3W2eX_ciZ0wZGqK60mc4edSVh5G2OqbbMKyFng,74898
54
+ pyfemtet/opt/samples/femprj_sample/gal_ex58_parametric.py,sha256=RxLSXFs0SqUjlug_JZAKlkJhqJdQCY3Y3F-DtSQRtVM,2458
55
+ pyfemtet/opt/samples/femprj_sample/gal_ex58_parametric_test_result.reccsv,sha256=NOaYmpmrhn9WMbIaLWFlR0IvRheGqcqu0J9Nf3JQnfo,1131
56
+ pyfemtet/opt/samples/femprj_sample/gau_ex08_parametric.femprj,sha256=Yb9ILeTEKx5xfJGk8IZH_DVlgkpGB33Vy9-LGIEQboY,279251
57
+ pyfemtet/opt/samples/femprj_sample/gau_ex08_parametric.py,sha256=5KazqJ5wRbGs0dBMJslZ1eRCUWq8j3k1mqlhyB8M0g8,1929
58
+ pyfemtet/opt/samples/femprj_sample/gau_ex08_parametric_test_result.reccsv,sha256=yZ9aHthiKIBY_NMOz94Jl2dyHIH-GWMvukgHk4ZeT_o,3474
59
+ pyfemtet/opt/samples/femprj_sample/her_ex40_parametric.femprj,sha256=LLAUDlUo1dIpRzlKPs1lvACzJQxjnWW3xAGAodYEqRM,117221
60
+ pyfemtet/opt/samples/femprj_sample/her_ex40_parametric.py,sha256=47Lqul9LDlbMB2Bvcn_B6wzrdNvQp1ksYSDRUZfR76Q,4846
61
+ pyfemtet/opt/samples/femprj_sample/her_ex40_parametric_test_result.reccsv,sha256=0yWqTpmpAtFvYRRyk2zneAVnl_5qJDeVwG4aeIWxXv8,3679
62
+ pyfemtet/opt/samples/femprj_sample/paswat_ex1_parametric.femprj,sha256=z2NHFJWiuiLv_zhxjFpLpmRbYVvQ43bAMj_NLioQGsk,262283
63
+ pyfemtet/opt/samples/femprj_sample/paswat_ex1_parametric.py,sha256=2oUBg2MvKuewO5Acs5FO3dkXX0QIZGRR5RRvKAb4CMk,2361
64
+ pyfemtet/opt/samples/femprj_sample/paswat_ex1_parametric_parallel.py,sha256=V6XYS3RblruTi8T43lEnNl_3pgdsobknspsD_K2iEpU,2472
65
+ pyfemtet/opt/samples/femprj_sample/paswat_ex1_parametric_test_result.reccsv,sha256=6PjbmLfwDx01Z0pywDL9eT5lfRKgZDU3r_H2SfZYaT4,3885
66
+ pyfemtet/opt/samples/femprj_sample/wat_ex14_parametric.femprj,sha256=F-yu2dGrsbrIA1Lhizu2aHTjQFTohyBmOuJv-Iyl8jk,179596
67
+ pyfemtet/opt/samples/femprj_sample/wat_ex14_parametric.py,sha256=K9ZlIkmD05NOF2dXnv4AmYsvM7klhm8Ss7irAr74MVQ,2213
68
+ pyfemtet/opt/samples/femprj_sample/wat_ex14_parametric_parallel.py,sha256=UjPMpoZY99rJY9mqudsK7MOGURhzwOulwDkrRiclZzI,2289
69
+ pyfemtet/opt/samples/femprj_sample/wat_ex14_parametric_test_result.reccsv,sha256=bvHgcuFZ1iS8sb_FT5W7MuquODxmv3IcFkiNOdSMiK8,3450
70
+ pyfemtet/opt/samples/femprj_sample_jp/ParametricIF_jp.femprj,sha256=9BtDHmc3cdom0Zq33DTdZ0mDAsIUY6i8SRkkg-n7GO0,442090
71
+ pyfemtet/opt/samples/femprj_sample_jp/ParametricIF_jp.py,sha256=oXzchBZEbH69xacDht5HDnbZzKwapXsn6bp9qihY17Y,707
72
+ pyfemtet/opt/samples/femprj_sample_jp/cad_ex01_NX_jp.femprj,sha256=0RBhOGhtiFAp0QSCTBYEaDY9EZymn9hJYchAOJ6PaBA,143533
73
+ pyfemtet/opt/samples/femprj_sample_jp/cad_ex01_NX_jp.py,sha256=B7wVemkiVzh0NJXDzG3fdigWBOb58ZxrJZUT4NRvW9Q,4899
74
+ pyfemtet/opt/samples/femprj_sample_jp/cad_ex01_SW_jp.femprj,sha256=ZZhT9XjB9Xu9YwHWv4gbvKBiUWlOFKEoHjAcGWb3vvQ,128026
75
+ pyfemtet/opt/samples/femprj_sample_jp/cad_ex01_SW_jp.py,sha256=e-XaHBZ8syWlG9pObcDDkHGLC5t338zAt_NyRXty338,4837
76
+ pyfemtet/opt/samples/femprj_sample_jp/constrained_pipe_jp.py,sha256=QhAwJOFEknf6Yk3mMgr1gdqB_Db8akjJGZNBepsrdgA,3654
77
+ pyfemtet/opt/samples/femprj_sample_jp/gal_ex58_parametric_jp.femprj,sha256=PzqtNVde6VnMHFpedRBsOq9JVhCY0ymQPVs54EKsNLw,75668
78
+ pyfemtet/opt/samples/femprj_sample_jp/gal_ex58_parametric_jp.py,sha256=97np4uH-UQqpv4UDwJS0doFYA7TOkXnbhLdkZExdNek,2461
79
+ pyfemtet/opt/samples/femprj_sample_jp/gau_ex08_parametric_jp.femprj,sha256=TTXw_8YT8pzHQlu4ufGzTq1IFYSwcWWt4GA6sIY1YPM,295600
80
+ pyfemtet/opt/samples/femprj_sample_jp/gau_ex08_parametric_jp.py,sha256=8Op_zwz9SD0NfGg4TFlcNvs-ZlU0bxgs5oaaI9UtlRU,2087
81
+ pyfemtet/opt/samples/femprj_sample_jp/her_ex40_parametric_jp.femprj,sha256=OJ7f8iw0z1BZqanuNn71uEaoM2Kgb93ptUU8iYwYON0,129783
82
+ pyfemtet/opt/samples/femprj_sample_jp/her_ex40_parametric_jp.py,sha256=MlFk6KRCQeCX1J0DNOjph75qjCUHg5UQPNTcHxIEnoo,5279
83
+ pyfemtet/opt/samples/femprj_sample_jp/paswat_ex1_parametric_jp.femprj,sha256=y7eURFBdqh6PmD4zbelGuB458HmfihVht0K4wVI-mik,265368
84
+ pyfemtet/opt/samples/femprj_sample_jp/paswat_ex1_parametric_jp.py,sha256=ibXVhya5JV7CfCD2srQceXOj1sYjH3kWtaIEfyu98u4,2489
85
+ pyfemtet/opt/samples/femprj_sample_jp/paswat_ex1_parametric_parallel_jp.py,sha256=cY9RhoAFEnVUkfGhbXpn3LavT_NRp_OwVxGbL7jSbBQ,2605
86
+ pyfemtet/opt/samples/femprj_sample_jp/wat_ex14_parametric_jp.femprj,sha256=dMwQMt6yok_PbZLyxPYdmg5wJQwgQDZ4RhS76zdGLGk,177944
87
+ pyfemtet/opt/samples/femprj_sample_jp/wat_ex14_parametric_jp.py,sha256=vMy-KUP1wEMV9Rt6yXjkE40Fcs1t1cpQK-nQJK8hHao,2284
88
+ pyfemtet/opt/samples/femprj_sample_jp/wat_ex14_parametric_parallel_jp.py,sha256=4X0cl3YWpYarcNBCH79mrlyFuKUYSqvnGzokEbv9ILk,2335
89
+ pyfemtet/opt/visualization/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
90
+ pyfemtet/opt/visualization/_create_wrapped_components.py,sha256=XpOv_iEEB3lFT3vYuCnCCbwUwRFbCYgvsZDpaiSzmZY,2511
91
+ pyfemtet/opt/visualization/base.py,sha256=XhZodLEr5PPHmtNai6uZcPJobKurENepuGCUaqDOI7I,7588
92
+ pyfemtet/opt/visualization/complex_components/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
93
+ pyfemtet/opt/visualization/complex_components/alert_region.py,sha256=IIsfw4Dwlag7ked94X7MF2UxEODJCBeYruDOUQsKzGQ,2104
94
+ pyfemtet/opt/visualization/complex_components/control_femtet.py,sha256=b4gn_pQMXe3NL3aqfEgsPTvhmdWmg-tRBvaHG659lZg,6240
95
+ pyfemtet/opt/visualization/complex_components/main_figure_creator.py,sha256=ueVyDFnY_KPIXuLM585bRToAGDCUXmd-cy_ZNMSFWs4,6949
96
+ pyfemtet/opt/visualization/complex_components/main_graph.py,sha256=iPxH7XdE0vWByzZfVka_93mLM70svv20OTpFMwAB-UE,21528
97
+ pyfemtet/opt/visualization/complex_components/pm_graph.py,sha256=n1p-yruqo9NW93UOUIdxPF2QdO4qDSuH37h6l8C68BQ,24921
98
+ pyfemtet/opt/visualization/complex_components/pm_graph_creator.py,sha256=ukv9XqW_Mzdsw9Oxc3JXLwKJTyXPSrt9DiB3dvKv4uk,7302
99
+ pyfemtet/opt/visualization/process_monitor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
100
+ pyfemtet/opt/visualization/process_monitor/application.py,sha256=ir0xVTsbqFWq2FlPw75XNcMpFEUQNUQr5OcAW0r-FuY,7922
101
+ pyfemtet/opt/visualization/process_monitor/pages.py,sha256=HSjBeZLnVEgm-VP_NJIpjRUsGhphNuV4eMqK7xC77es,15110
102
+ pyfemtet/opt/visualization/result_viewer/.gitignore,sha256=ryvb4aqbbsHireHWlPQfxxqDHQJo6YkVYhE9imKt0b8,6
103
+ pyfemtet/opt/visualization/result_viewer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
104
+ pyfemtet/opt/visualization/result_viewer/application.py,sha256=99Zn-i2mJLIN0DeKjewCBW9UCa78YpyRoMLXzbMd4Qg,1687
105
+ pyfemtet/opt/visualization/result_viewer/pages.py,sha256=wzTbd-3XHDZ0rK98sE55tXQ90nb1IbUhav3sIVFfjOY,32147
106
+ pyfemtet/opt/visualization/wrapped_components/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
107
+ pyfemtet/opt/visualization/wrapped_components/dbc.py,sha256=wzR1ZMOb4uwPNTMFn5upLJ9tXeuJ22mLGynyJlA2cho,42161
108
+ pyfemtet/opt/visualization/wrapped_components/dcc.py,sha256=hcW7SR6VIMn4S4-JMyohvOzdc0Aw8A4chIeHqQEUbFU,17499
109
+ pyfemtet/opt/visualization/wrapped_components/html.py,sha256=sE2XHTDY1GvA1NW7y6SKWf-WglVXFKKvXhU9h3z53_g,95652
110
+ pyfemtet/opt/visualization/wrapped_components/str_enum.py,sha256=NZqbh2jNEAckvJyZv__MWeRs2F2Q-dkJCWo30rU2rrM,1383
111
+ pyfemtet-0.5.1.dist-info/LICENSE,sha256=sVQBhyoglGJUu65-BP3iR6ujORI6YgEU2Qm-V4fGlOA,1485
112
+ pyfemtet-0.5.1.dist-info/METADATA,sha256=PLu9EtBr3EFxUh2vMonVk6klrI_tyaS_h9hfXO9qfRE,3287
113
+ pyfemtet-0.5.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
114
+ pyfemtet-0.5.1.dist-info/entry_points.txt,sha256=ZfYqRaoiPtuWqFi2_msccyrVF0LurMn-IHlYamAegZo,104
115
+ pyfemtet-0.5.1.dist-info/RECORD,,
pyfemtet/_test_util.py DELETED
@@ -1,135 +0,0 @@
1
- import os
2
- import csv
3
- from shutil import copy
4
- from time import sleep
5
- from subprocess import run
6
- from multiprocessing import Process
7
- from glob import glob
8
-
9
- import numpy as np
10
- import pandas as pd
11
- from tqdm import tqdm
12
- from win32com.client import Dispatch
13
- from femtetutils import util
14
-
15
- from pyfemtet.opt import FEMOpt
16
-
17
-
18
- class SuperSphere:
19
- def __init__(self, n):
20
- self.n = n
21
-
22
- def x(self, radius, *angles):
23
- assert len(angles) == self.n - 1, 'invalid angles length'
24
-
25
- out = []
26
-
27
- for i in range(self.n):
28
- if i == 0:
29
- out.append(radius * np.cos(angles[0]))
30
- elif i < self.n - 1:
31
- product = radius
32
- for j in range(i):
33
- product *= np.sin(angles[j])
34
- product *= np.cos(angles[i])
35
- out.append(product)
36
- else:
37
- product = radius
38
- for j in range(i):
39
- product *= np.sin(angles[j])
40
- out.append(product)
41
- return out
42
-
43
-
44
- def _open_femprj(femprj_path):
45
- Femtet = Dispatch('FemtetMacro.Femtet')
46
- for _ in tqdm(range(5), 'wait for dispatch Femtet'):
47
- sleep(1)
48
- Femtet.LoadProject(femprj_path, True)
49
-
50
-
51
- def launch_femtet(femprj_path):
52
- # launch Femtet externally
53
- print('Launching Femtet...')
54
- util.execute_femtet()
55
- pid = util.get_last_executed_femtet_process_id()
56
- for _ in tqdm(range(8), 'Wait for launch Femtet.'):
57
- sleep(1)
58
-
59
- # open femprj in a different process
60
- # to release Femtet for sample program
61
- print('Opening femprj...')
62
- if femprj_path:
63
- p = Process(
64
- target=_open_femprj,
65
- args=(femprj_path,),
66
- )
67
- p.start()
68
- p.join()
69
-
70
-
71
- def taskkill_femtet():
72
- for _ in tqdm(range(3), 'wait before taskkill Femtet'):
73
- sleep(1)
74
- run(['taskkill', '/f', '/im', 'Femtet.exe'])
75
- for _ in tqdm(range(3), 'wait after taskkill Femtet'):
76
- sleep(1)
77
-
78
-
79
- def find_latest_csv(dir_path=None):
80
- if dir_path is None: dir_path = '.'
81
- target = os.path.join(dir_path, '*.csv')
82
- files = [(f, os.path.getmtime(f)) for f in glob(target)]
83
- out = sorted(files, key=lambda files: files[1])[-1]
84
- return os.path.abspath(out[0])
85
-
86
-
87
- def py_to_reccsv(py_path, suffix=''):
88
- dst_csv_path = py_path + suffix
89
- dst_csv_path = dst_csv_path.replace(f'.py{suffix}', f'{suffix}.reccsv')
90
- return dst_csv_path
91
-
92
-
93
- def record_result(src: FEMOpt or str, py_path, suffix=''):
94
- """Record the result csv for `is_equal_result`."""
95
-
96
- if isinstance(src, FEMOpt): # get df directory
97
- src_csv_path = src.history_path
98
- else:
99
- src_csv_path = os.path.abspath(src)
100
-
101
- dst_csv_path = py_to_reccsv(py_path, suffix)
102
- copy(src_csv_path, dst_csv_path)
103
-
104
-
105
- def _get_obj_from_csv(csv_path, encoding='cp932'):
106
- df = pd.read_csv(csv_path, encoding=encoding, header=2)
107
- columns = df.columns
108
- with open(csv_path, mode='r', encoding=encoding, newline='\n') as f:
109
- reader = csv.reader(f, delimiter=',')
110
- meta = reader.__next__()
111
- obj_indices = np.where(np.array(meta) == 'obj')[0]
112
- out = df.iloc[:, obj_indices]
113
- return out, columns
114
-
115
-
116
- def is_equal_result(ref_path, dif_path, log_path):
117
- """Check the equality of two result csv files."""
118
- ref_df, ref_columns = _get_obj_from_csv(ref_path)
119
- dif_df, dif_columns = _get_obj_from_csv(dif_path)
120
-
121
- with open(log_path, 'a', newline='\n') as f:
122
- f.write('\n\n===== 結果の分析 =====\n\n')
123
- f.write(f' \tref\tdif\n')
124
- f.write(f'---------------------\n')
125
- f.write(f'len(col)\t{len(ref_columns)}\t{len(dif_columns)}\n')
126
- f.write(f'len(df) \t{len(ref_df)}\t{len(dif_df)}\n')
127
- try:
128
- difference = (np.abs(ref_df.values - dif_df.values) / np.abs(dif_df.values)).mean()
129
- f.write(f'diff \t{int(difference*100)}%\n')
130
- except Exception:
131
- f.write(f'diff \tcannot calc\n')
132
-
133
- assert len(ref_columns) == len(dif_columns), '結果 csv の column 数が異なります。'
134
- assert len(ref_df) == len(dif_df), '結果 csv の row 数が異なります。'
135
- assert difference <= 0.05, '前回の結果との平均差異が 5% を超えています。'
@@ -1,18 +0,0 @@
1
- "{""femprj_path"": null, ""model_name"": ""Harm""}",prm,prm_lb,prm_ub,prm,prm_lb,prm_ub,prm,prm_lb,prm_ub,obj,obj_direction,,cns,cns_lb,cns_ub,cns,cns_lb,cns_ub,,,,
2
- ,,,,,,,,,,,,,,,,,,,,,,
3
- trial,antenna_radius,antenna_radius_lower_bound,antenna_radius_upper_bound,substrate_w,substrate_w_lower_bound,substrate_w_upper_bound,port_x,port_x_lower_bound,port_x_upper_bound,first resonant frequency(Hz),first resonant frequency(Hz)_direction,non_domi,antenna and substrate clearance,antenna and substrate clearance_lower_bound,antenna and substrate clearance_upper_bound,antenna and port clearance,antenna and port clearance_lower_bound,antenna and port clearance_upper_bound,feasible,hypervolume,message,time
4
- 1,10.0,5.0,20.0,50.0,40.0,60.0,5.0,1.0,20.0,4289000000.0,3000000000.0,False,15.0,1,,5.0,1,,True,-1.0,initial,2024-07-24 10:30:06.939869
5
- 2,13.979877262955549,5.0,20.0,43.12037280884873,40.0,60.0,3.96389588638785,1.0,20.0,3050000000.0,3000000000.0,False,7.580309099999999,1,,10.01598141,1,,True,-1.0,,2024-07-24 10:30:19.275568
6
- 3,17.48663961200633,5.0,20.0,44.246782213565524,40.0,60.0,4.4546743769349115,1.0,20.0,2460000000.0,3000000000.0,False,4.636751499999999,1,,13.03196522,1,,True,-1.0,,2024-07-24 10:30:35.798531
7
- 4,11.841049763255539,5.0,20.0,55.70351922786027,40.0,60.0,4.793801861008835,1.0,20.0,3581000000.0,3000000000.0,False,16.0107098,1,,7.04724794,1,,True,-1.0,,2024-07-24 10:30:51.243382
8
- 5,12.713516576204174,5.0,20.0,51.84829137724085,40.0,60.0,1.8825578416799567,1.0,20.0,2932000000.0,3000000000.0,False,13.2106291,1,,10.83095876,1,,True,-1.0,,2024-07-24 10:31:01.335664
9
- 6,14.113172778521575,5.0,20.0,43.41048247374583,40.0,60.0,2.235980266720311,1.0,20.0,2991000000.0,3000000000.0,True,7.592068450000001,1,,11.877192529999999,1,,True,-1.0,,2024-07-24 10:31:14.045279
10
- 7,19.233283058799998,5.0,20.0,59.31264066149119,40.0,60.0,16.35954961421276,1.0,20.0,2283000000.0,3000000000.0,False,10.42303725,1,,2.8737335,1,,True,-1.0,,2024-07-24 10:31:40.560920
11
- 8,11.60228740609402,5.0,20.0,42.44076469689558,40.0,60.0,10.408361292114133,1.0,20.0,3758000000.0,3000000000.0,False,9.618094950000001,1,,1.1939261000000005,1,,True,-1.0,,2024-07-24 10:31:57.496815
12
- 9,14.93783426530973,5.0,20.0,46.23422152178822,40.0,60.0,10.881292402378406,1.0,20.0,2932000000.0,3000000000.0,False,8.179276449999998,1,,4.056541900000001,1,,True,-1.0,,2024-07-24 10:32:18.322964
13
- 10,13.968499682166277,5.0,20.0,58.437484700462335,40.0,60.0,2.6813575389864703,1.0,20.0,2991000000.0,3000000000.0,True,15.250242649999999,1,,11.28714216,1,,True,-1.0,,2024-07-24 10:32:32.049325
14
- 11,14.058429837987106,5.0,20.0,51.01029232478569,40.0,60.0,1.738898798219626,1.0,20.0,2814000000.0,3000000000.0,False,11.44671635,1,,12.319531000000001,1,,True,-1.0,,2024-07-24 10:32:44.208324
15
- 12,14.260807151712159,5.0,20.0,57.66392990209854,40.0,60.0,8.792627280104398,1.0,20.0,3050000000.0,3000000000.0,False,14.57115775,1,,5.468179920000001,1,,True,-1.0,,2024-07-24 10:33:18.982843
16
- 13,13.508818923150182,5.0,20.0,59.99999999999999,40.0,60.0,4.887635502556277,1.0,20.0,3109000000.0,3000000000.0,False,16.4911811,1,,8.6211834,1,,True,-1.0,,2024-07-24 10:33:35.259275
17
- 14,14.885966644225132,5.0,20.0,40.0,40.0,60.0,4.993357418116345,1.0,20.0,2814000000.0,3000000000.0,False,5.1140334,1,,9.892609180000001,1,,True,-1.0,,2024-07-24 10:34:06.248951
18
- 15,19.999999999999996,5.0,20.0,59.99999999999999,40.0,60.0,1.0,1.0,20.0,4525000000.0,3000000000.0,False,10.0,1,,19.0,1,,True,-1.0,,2024-07-24 10:34:37.774576
@@ -1,12 +0,0 @@
1
- from pyfemtet.opt.opt._base import AbstractOptimizer, logger, OptimizationMethodChecker
2
- from pyfemtet.opt.opt._optuna import OptunaOptimizer
3
- from pyfemtet.opt.opt._scipy import ScipyOptimizer
4
- from pyfemtet.opt.opt._scipy_scalar import ScipyScalarOptimizer
5
-
6
- __all__ = [
7
- 'ScipyScalarOptimizer',
8
- 'ScipyOptimizer',
9
- 'OptunaOptimizer',
10
- 'AbstractOptimizer',
11
- 'logger',
12
- ]
@@ -1,209 +0,0 @@
1
- from typing import Optional, List, Tuple, Callable
2
- from functools import partial
3
- import inspect
4
-
5
- import numpy as np
6
- import optuna.study
7
- import torch
8
- from torch import Tensor
9
- from botorch.optim.initializers import gen_batch_initial_conditions
10
- from botorch.utils.transforms import unnormalize
11
- from optuna.study import Study
12
- from botorch.acquisition import AcquisitionFunction
13
-
14
- from pyfemtet.opt.opt import AbstractOptimizer
15
- from pyfemtet.opt.parameter import ExpressionEvaluator
16
-
17
- # module to monkey patch
18
- import optuna_integration
19
-
20
-
21
- # モンキーパッチを実行するため、optimize_acqf の引数を MonkyPatch クラスで定義し optuna に上書きされないようにするためのクラス
22
- class NonOverwritablePartial(partial):
23
- def __call__(self, /, *args, **keywords):
24
- stored_kwargs = self.keywords
25
- keywords.update(stored_kwargs)
26
- return self.func(*self.args, *args, **keywords)
27
-
28
-
29
- # prm_name を引数に取る関数を optimize_acqf の nonlinear_inequality_constraints に入れられる形に変換する関数
30
- class ConvertedConstraintFunction:
31
- def __init__(self, fun, prm_args, kwargs, variables: ExpressionEvaluator, study: optuna.study.Study):
32
- self.fun = fun
33
- self.prm_args = prm_args
34
- self.kwargs = kwargs
35
- self.variables = variables
36
- self.study = study
37
-
38
- self.bounds = None
39
- self.prm_name_seq = None
40
-
41
- # fun の prm として使う引数が指定されていなければ fun の引数を取得
42
- if self.prm_args is None:
43
- signature = inspect.signature(fun)
44
- prm_inputs = set([a.name for a in signature.parameters.values()])
45
- else:
46
- prm_inputs = set(self.prm_args)
47
-
48
- # 引数の set から kwargs の key を削除
49
- self.prm_arg_names = prm_inputs - set(kwargs.keys())
50
-
51
- # 変な引数が残っていないか確認
52
- assert all([(arg in variables.get_parameter_names()) for arg in self.prm_arg_names])
53
-
54
- def __call__(self, x: Tensor or np.ndarray):
55
- # x: all of normalized parameters whose sequence is sorted by optuna
56
-
57
- if not isinstance(x, Tensor):
58
- x = torch.tensor(np.array(x)).double()
59
-
60
- x = unnormalize(x, self.bounds)
61
-
62
- # fun で使うパラメータのみ value を取得
63
- kwargs = self.kwargs
64
- kwargs.update(
65
- {k: v for k, v in zip(self.prm_name_seq, x) if k in self.prm_arg_names}
66
- )
67
-
68
- return self.fun(**kwargs)
69
-
70
-
71
- # 与えられた獲得関数に拘束を満たさない場合 0 を返すよう加工された獲得関数
72
- class AcqWithConstraint(AcquisitionFunction):
73
-
74
- # noinspection PyAttributeOutsideInit
75
- def set(self, _org_acq_function: AcquisitionFunction, nonlinear_constraints):
76
- self._org_acq_function = _org_acq_function
77
- self._nonlinear_constraints = nonlinear_constraints
78
-
79
- def forward(self, X: Tensor) -> Tensor:
80
- base = self._org_acq_function.forward(X)
81
-
82
- is_feasible = all([cons(X[0][0]) > 0 for cons, _ in self._nonlinear_constraints])
83
- if is_feasible:
84
- return base
85
- else:
86
- # penalty = torch.Tensor(size=base.shape)
87
- # penalty = torch.fill(penalty, -1e10)
88
- # return base * penalty
89
- return base * 0.
90
-
91
-
92
- def remove_infeasible(_ic_batch, nonlinear_constraints):
93
- # infeasible なものを削除
94
- remove_indices = []
95
- for i, ic in enumerate(_ic_batch): # ic: 1 x len(params) tensor
96
- # cons: Callable[["Tensor"], "Tensor"]
97
- is_feasible = all([cons(ic[0]) > 0 for cons, _ in nonlinear_constraints])
98
- if not is_feasible:
99
- # ic_batch[i] = torch.nan # これで無視にならない
100
- remove_indices.append(i)
101
- for i in remove_indices[::-1]:
102
- _ic_batch = torch.cat((_ic_batch[:i], _ic_batch[i + 1:]))
103
- return _ic_batch
104
-
105
-
106
- class OptunaBotorchWithParameterConstraintMonkeyPatch:
107
-
108
- def __init__(self, study: Study, opt: AbstractOptimizer):
109
- self.num_restarts: int = 20
110
- self.raw_samples_additional: int = 512
111
- self.eta: float = 2.0
112
- self.study = study
113
- self.opt = opt
114
- self.nonlinear_inequality_constraints = []
115
- self.additional_kwargs = dict()
116
- self.bounds = None
117
- self.prm_name_seq = None
118
-
119
- def add_nonlinear_constraint(self, fun, prm_args, kwargs):
120
- f = ConvertedConstraintFunction(
121
- fun,
122
- prm_args,
123
- kwargs,
124
- self.opt.variables,
125
- self.study,
126
- )
127
-
128
- # 初期化
129
- self.nonlinear_inequality_constraints = self.nonlinear_inequality_constraints or []
130
-
131
- # 自身に追加
132
- self.nonlinear_inequality_constraints.append((f, True))
133
-
134
- # optimize_acqf() に渡す引数に追加
135
- self.additional_kwargs.update(
136
- nonlinear_inequality_constraints=self.nonlinear_inequality_constraints
137
- )
138
-
139
- def _detect_prm_seq_if_needed(self):
140
- # study から distribution の情報を復元する。
141
- if self.bounds is None or self.prm_name_seq is None:
142
- from optuna._transform import _transform_search_space
143
- # sample_relative の後に呼ばれているから最後の trial は search_space を持つはず
144
- search_space: dict = self.study.sampler.infer_relative_search_space(self.study, self.study.trials[-1])
145
- self.bounds = _transform_search_space(search_space, False, False)[0].T
146
- self.prm_name_seq = list(search_space.keys())
147
-
148
- for cns in self.nonlinear_inequality_constraints:
149
- cns[0].bounds = torch.tensor(self.bounds)
150
- cns[0].prm_name_seq = self.prm_name_seq
151
-
152
- def generate_initial_conditions(self, *args, **kwargs):
153
- self._detect_prm_seq_if_needed()
154
-
155
- # acqf_function を 上書きし、拘束を満たさないならば 0 を返すようにする
156
- org_acq_function = kwargs['acq_function']
157
- new_acqf = AcqWithConstraint(None)
158
- new_acqf.set(org_acq_function, self.nonlinear_inequality_constraints)
159
- kwargs['acq_function'] = new_acqf
160
-
161
- # initial condition の提案 batch を作成
162
- # ic: `num_restarts x q x d` tensor of initial conditions.
163
- # q = 1, d = len(params)
164
- ic_batch = gen_batch_initial_conditions(*args, **kwargs)
165
-
166
- # 拘束を満たさないものを削除
167
- ic_batch = remove_infeasible(ic_batch, self.nonlinear_inequality_constraints)
168
-
169
- # 全部なくなっているならばランダムに生成
170
- if len(ic_batch) == 0:
171
- print('拘束を満たす組み合わせがなかったのでランダムサンプリングします')
172
- while len(ic_batch) == 0:
173
- size = ic_batch.shape
174
- ic_batch = torch.rand(size=[100, *size[1:]]) # 正規化された変数の組合せ
175
- ic_batch = remove_infeasible(ic_batch, self.nonlinear_inequality_constraints)
176
-
177
- return ic_batch
178
-
179
- def do_monkey_patch(self):
180
- """optuna_integration.botorch には optimize_acqf に constraints を渡す方法が用意されていないので、モンキーパッチして渡す
181
-
182
- モンキーパッチ自体は最適化実行前のどの時点で呼んでも機能するが、additional_kwargs の更新後に
183
- モンキーパッチを呼ぶ必要があるのでコンストラクタにこの処理は入れない。
184
- 各 add_constraint に入れるのはいいかも。
185
-
186
- """
187
-
188
- # === reconstruct argument ``options`` for optimize_acqf ===
189
- options = dict() # initialize
190
-
191
- # for nonlinear-constraint
192
- options.update(dict(batch_limit=1))
193
-
194
- # for gen_candidates_scipy()
195
- # use COBYLA or SLSQP only.
196
- options.update(dict(method='SLSQP'))
197
-
198
- # make partial of optimize_acqf used in optuna_integration.botorch and replace to it.
199
- original_fun = optuna_integration.botorch.optimize_acqf
200
- overwritten_fun = NonOverwritablePartial(
201
- original_fun,
202
- q=1, # for nonlinear constraints
203
- options=options,
204
- num_restarts=20, # gen_batch_initial_conditions に渡すべきで、self.generate_initial_conditions に渡される変数。
205
- raw_samples=512, # gen_batch_initial_conditions に渡すべきで、self.generate_initial_conditions に渡される変数。
206
- nonlinear_inequality_constraints=self.nonlinear_inequality_constraints,
207
- ic_generator=self.generate_initial_conditions,
208
- )
209
- optuna_integration.botorch.optimize_acqf = overwritten_fun