pyfemtet 0.9.4__py3-none-any.whl → 1.0.0a0__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 (272) hide show
  1. pyfemtet/__init__.py +6 -1
  2. pyfemtet/_i18n/1. make_pot_and_update_po.bat +8 -0
  3. pyfemtet/_i18n/2. build_mo.bat +5 -0
  4. pyfemtet/_i18n/__init__.py +4 -0
  5. pyfemtet/_i18n/babel.cfg +2 -0
  6. pyfemtet/_i18n/i18n.py +37 -0
  7. pyfemtet/_i18n/locales/ja/LC_MESSAGES/messages.mo +0 -0
  8. pyfemtet/_i18n/locales/ja/LC_MESSAGES/messages.po +1020 -0
  9. pyfemtet/_i18n/locales/messages.pot +987 -0
  10. pyfemtet/{_message → _i18n}/messages.py +128 -41
  11. pyfemtet/_util/closing.py +19 -0
  12. pyfemtet/_util/dask_util.py +89 -7
  13. pyfemtet/_util/df_util.py +29 -0
  14. pyfemtet/_util/excel_macro_util.py +8 -3
  15. pyfemtet/_util/excel_parse_util.py +43 -23
  16. pyfemtet/_util/femtet_access_inspection.py +120 -0
  17. pyfemtet/{_femtet_config_util/autosave.py → _util/femtet_autosave.py} +7 -0
  18. pyfemtet/_util/femtet_exit.py +105 -0
  19. pyfemtet/_util/femtet_version.py +20 -0
  20. pyfemtet/_util/helper.py +94 -0
  21. pyfemtet/_util/process_util.py +107 -0
  22. pyfemtet/_util/str_enum.py +44 -0
  23. pyfemtet/core.py +15 -47
  24. pyfemtet/dispatch_extensions/__init__.py +8 -11
  25. pyfemtet/dispatch_extensions/_impl.py +42 -198
  26. pyfemtet/logger/__init__.py +8 -1
  27. pyfemtet/logger/_impl.py +5 -6
  28. pyfemtet/opt/__init__.py +3 -19
  29. pyfemtet/opt/exceptions.py +45 -0
  30. pyfemtet/opt/femopt.py +602 -0
  31. pyfemtet/opt/history/__init__.py +11 -0
  32. pyfemtet/opt/history/_history.py +1404 -0
  33. pyfemtet/opt/history/_hypervolume.py +169 -0
  34. pyfemtet/opt/history/_optimality.py +79 -0
  35. pyfemtet/opt/interface/__init__.py +17 -24
  36. pyfemtet/opt/interface/_base_interface.py +222 -0
  37. pyfemtet/opt/interface/_excel_interface/__init__.py +3 -0
  38. pyfemtet/opt/interface/_excel_interface/debug-excel-interface.xlsm +0 -0
  39. pyfemtet/opt/interface/_excel_interface/excel_interface.py +999 -0
  40. pyfemtet/opt/interface/_femtet_interface/__init__.py +3 -0
  41. pyfemtet/opt/interface/{_femtet_parametric.py → _femtet_interface/_femtet_parametric.py} +20 -12
  42. pyfemtet/opt/interface/{_femtet.py → _femtet_interface/femtet_interface.py} +490 -348
  43. pyfemtet/opt/interface/_femtet_with_nx_interface/__init__.py +5 -0
  44. pyfemtet/opt/interface/_femtet_with_nx_interface/femtet_with_nx_interface.py +230 -0
  45. pyfemtet/opt/interface/_femtet_with_nx_interface/model1.prt +0 -0
  46. pyfemtet/opt/interface/_femtet_with_nx_interface/model1.x_t +98 -0
  47. pyfemtet/opt/interface/{_femtet_with_nx → _femtet_with_nx_interface}/update_model.py +1 -3
  48. pyfemtet/opt/interface/_femtet_with_solidworks/__init__.py +5 -0
  49. pyfemtet/opt/interface/_femtet_with_solidworks/femtet_with_solidworks_interface.py +122 -0
  50. pyfemtet/opt/interface/_solidworks_interface/__init__.py +5 -0
  51. pyfemtet/opt/interface/_solidworks_interface/solidworks_interface.py +206 -0
  52. pyfemtet/opt/interface/_surrogate/_base.py +0 -129
  53. pyfemtet/opt/interface/_surrogate_model_interface/__init__.py +8 -0
  54. pyfemtet/opt/interface/_surrogate_model_interface/base_surrogate_interface.py +59 -0
  55. pyfemtet/opt/interface/_surrogate_model_interface/botorch_interface.py +271 -0
  56. pyfemtet/opt/interface/_surrogate_model_interface/debug-pof-botorch.reccsv +18 -0
  57. pyfemtet/opt/interface/_with_excel_settings/__init__.py +61 -0
  58. pyfemtet/opt/interface/_with_excel_settings/with_excel_settings.py +134 -0
  59. pyfemtet/opt/meta_script/YAML_Generator.xlsm +0 -0
  60. pyfemtet/opt/meta_script/__main__.py +58 -36
  61. pyfemtet/opt/optimizer/__init__.py +7 -9
  62. pyfemtet/opt/optimizer/_base_optimizer.py +876 -0
  63. pyfemtet/opt/optimizer/optuna_optimizer/__init__.py +9 -0
  64. pyfemtet/opt/optimizer/optuna_optimizer/_optuna_attribute.py +73 -0
  65. pyfemtet/opt/optimizer/optuna_optimizer/_optuna_optimizer.py +678 -0
  66. pyfemtet/opt/optimizer/optuna_optimizer/_pof_botorch/__init__.py +7 -0
  67. pyfemtet/opt/optimizer/optuna_optimizer/_pof_botorch/debug-pof-botorch.reccsv +18 -0
  68. pyfemtet/opt/optimizer/optuna_optimizer/_pof_botorch/enable_nonlinear_constraint.py +244 -0
  69. pyfemtet/opt/optimizer/optuna_optimizer/_pof_botorch/pof_botorch_sampler.py +1249 -0
  70. pyfemtet/opt/optimizer/optuna_optimizer/wat_ex14_parametric_jp.femprj +0 -0
  71. pyfemtet/opt/optimizer/scipy_optimizer/__init__.py +1 -0
  72. pyfemtet/opt/optimizer/scipy_optimizer/_scipy_optimizer.py +364 -0
  73. pyfemtet/opt/prediction/__init__.py +7 -0
  74. pyfemtet/opt/prediction/_botorch_utils.py +133 -0
  75. pyfemtet/opt/prediction/_gpytorch_modules_extension.py +142 -0
  76. pyfemtet/opt/prediction/_helper.py +155 -0
  77. pyfemtet/opt/prediction/_model.py +118 -0
  78. pyfemtet/opt/problem/problem.py +304 -0
  79. pyfemtet/opt/problem/variable_manager/__init__.py +20 -0
  80. pyfemtet/opt/problem/variable_manager/_string_as_expression.py +115 -0
  81. pyfemtet/opt/problem/variable_manager/_variable_manager.py +295 -0
  82. pyfemtet/opt/visualization/history_viewer/__main__.py +5 -0
  83. pyfemtet/opt/visualization/{_base.py → history_viewer/_base_application.py} +18 -13
  84. pyfemtet/opt/visualization/history_viewer/_common_pages.py +150 -0
  85. pyfemtet/opt/visualization/{_complex_components → history_viewer/_complex_components}/alert_region.py +10 -5
  86. pyfemtet/opt/visualization/{_complex_components → history_viewer/_complex_components}/control_femtet.py +16 -13
  87. pyfemtet/opt/visualization/{_complex_components → history_viewer/_complex_components}/main_graph.py +117 -47
  88. pyfemtet/opt/visualization/{_complex_components → history_viewer/_complex_components}/pm_graph.py +159 -138
  89. pyfemtet/opt/visualization/history_viewer/_process_monitor/_application.py +173 -0
  90. pyfemtet/opt/visualization/history_viewer/_process_monitor/_pages.py +291 -0
  91. pyfemtet/opt/visualization/{_wrapped_components → history_viewer/_wrapped_components}/dbc.py +1 -1
  92. pyfemtet/opt/visualization/{_wrapped_components → history_viewer/_wrapped_components}/dcc.py +1 -1
  93. pyfemtet/opt/visualization/{_wrapped_components → history_viewer/_wrapped_components}/html.py +1 -1
  94. pyfemtet/opt/visualization/history_viewer/result_viewer/__main__.py +5 -0
  95. pyfemtet/opt/visualization/{result_viewer/application.py → history_viewer/result_viewer/_application.py} +6 -6
  96. pyfemtet/opt/visualization/{result_viewer/pages.py → history_viewer/result_viewer/_pages.py} +106 -82
  97. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08.csv +18 -0
  98. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08.db +0 -0
  99. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8.jpg +0 -0
  100. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8.log +45 -0
  101. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8.pdt +0 -0
  102. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_1.jpg +0 -0
  103. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_1.pdt +0 -0
  104. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_10.jpg +0 -0
  105. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_10.pdt +0 -0
  106. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_11.jpg +0 -0
  107. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_11.pdt +0 -0
  108. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_12.jpg +0 -0
  109. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_12.pdt +0 -0
  110. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_13.jpg +0 -0
  111. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_13.pdt +0 -0
  112. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_14.jpg +0 -0
  113. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_14.pdt +0 -0
  114. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_15.jpg +0 -0
  115. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_15.pdt +0 -0
  116. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_16.jpg +0 -0
  117. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_16.pdt +0 -0
  118. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_17.jpg +0 -0
  119. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_17.pdt +0 -0
  120. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_18.jpg +0 -0
  121. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_18.pdt +0 -0
  122. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_19.jpg +0 -0
  123. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_19.pdt +0 -0
  124. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_2.jpg +0 -0
  125. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_2.pdt +0 -0
  126. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_20.jpg +0 -0
  127. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_20.pdt +0 -0
  128. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_3.jpg +0 -0
  129. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_3.pdt +0 -0
  130. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.bgr +0 -0
  131. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.bnd +0 -0
  132. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.btr +0 -0
  133. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.jpg +0 -0
  134. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.mtl +0 -0
  135. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.pdt +0 -0
  136. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.prm +0 -0
  137. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_5.jpg +0 -0
  138. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_5.pdt +0 -0
  139. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_6.jpg +0 -0
  140. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_6.pdt +0 -0
  141. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_7.jpg +0 -0
  142. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_7.pdt +0 -0
  143. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_8.jpg +0 -0
  144. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_8.pdt +0 -0
  145. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_9.jpg +0 -0
  146. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_9.pdt +0 -0
  147. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.femprj +0 -0
  148. pyfemtet/opt/visualization/plotter/main_figure_creator.py +536 -0
  149. pyfemtet/opt/visualization/plotter/pm_graph_creator.py +359 -0
  150. pyfemtet/opt/worker_status.py +120 -0
  151. {pyfemtet-0.9.4.dist-info → pyfemtet-1.0.0a0.dist-info}/METADATA +22 -24
  152. pyfemtet-1.0.0a0.dist-info/RECORD +173 -0
  153. pyfemtet-1.0.0a0.dist-info/entry_points.txt +3 -0
  154. pyfemtet/_femtet_config_util/exit.py +0 -59
  155. pyfemtet/_message/1. make_pot.bat +0 -11
  156. pyfemtet/_message/2. make_mo.bat +0 -6
  157. pyfemtet/_message/__init__.py +0 -5
  158. pyfemtet/_message/babel.cfg +0 -2
  159. pyfemtet/_message/locales/ja/LC_MESSAGES/messages.mo +0 -0
  160. pyfemtet/_message/locales/ja/LC_MESSAGES/messages.po +0 -570
  161. pyfemtet/_message/locales/messages.pot +0 -551
  162. pyfemtet/_warning.py +0 -87
  163. pyfemtet/brep/_impl.py +0 -18
  164. pyfemtet/opt/_femopt.py +0 -1007
  165. pyfemtet/opt/_femopt_core.py +0 -1169
  166. pyfemtet/opt/_test_utils/control_femtet.py +0 -39
  167. pyfemtet/opt/_test_utils/hyper_sphere.py +0 -24
  168. pyfemtet/opt/_test_utils/record_history.py +0 -130
  169. pyfemtet/opt/advanced_samples/excel_ui/(ref) original_project.femprj +0 -0
  170. pyfemtet/opt/advanced_samples/excel_ui/femtet-macro.xlsm +0 -0
  171. pyfemtet/opt/advanced_samples/excel_ui/pyfemtet-core.py +0 -291
  172. pyfemtet/opt/advanced_samples/excel_ui/test-pyfemtet-core.cmd +0 -22
  173. pyfemtet/opt/advanced_samples/restart/gal_ex13_parametric.femprj +0 -0
  174. pyfemtet/opt/advanced_samples/restart/gal_ex13_parametric_restart.py +0 -99
  175. pyfemtet/opt/advanced_samples/restart/gal_ex13_parametric_restart_jp.py +0 -102
  176. pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_create_training_data.py +0 -60
  177. pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_create_training_data_jp.py +0 -57
  178. pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_optimize_with_surrogate.py +0 -100
  179. pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_optimize_with_surrogate_jp.py +0 -90
  180. pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_parametric.femprj +0 -0
  181. pyfemtet/opt/interface/_base.py +0 -101
  182. pyfemtet/opt/interface/_excel_interface.py +0 -984
  183. pyfemtet/opt/interface/_femtet_excel.py +0 -141
  184. pyfemtet/opt/interface/_femtet_with_nx/__init__.py +0 -3
  185. pyfemtet/opt/interface/_femtet_with_nx/_interface.py +0 -178
  186. pyfemtet/opt/interface/_femtet_with_sldworks.py +0 -298
  187. pyfemtet/opt/interface/_surrogate/__init__.py +0 -5
  188. pyfemtet/opt/interface/_surrogate/_chaospy.py +0 -71
  189. pyfemtet/opt/interface/_surrogate/_singletaskgp.py +0 -71
  190. pyfemtet/opt/interface/_surrogate_excel.py +0 -102
  191. pyfemtet/opt/optimizer/_base.py +0 -376
  192. pyfemtet/opt/optimizer/_optuna/_botorch_patch/enable_nonlinear_constraint.py +0 -220
  193. pyfemtet/opt/optimizer/_optuna/_optuna.py +0 -434
  194. pyfemtet/opt/optimizer/_optuna/_pof_botorch.py +0 -1914
  195. pyfemtet/opt/optimizer/_scipy.py +0 -159
  196. pyfemtet/opt/optimizer/_scipy_scalar.py +0 -127
  197. pyfemtet/opt/optimizer/parameter.py +0 -113
  198. pyfemtet/opt/prediction/_base.py +0 -61
  199. pyfemtet/opt/prediction/single_task_gp.py +0 -119
  200. pyfemtet/opt/samples/femprj_sample/ParametricIF.femprj +0 -0
  201. pyfemtet/opt/samples/femprj_sample/ParametricIF.py +0 -29
  202. pyfemtet/opt/samples/femprj_sample/ParametricIF_test_result.reccsv +0 -13
  203. pyfemtet/opt/samples/femprj_sample/cad_ex01_NX.femprj +0 -0
  204. pyfemtet/opt/samples/femprj_sample/cad_ex01_NX.prt +0 -0
  205. pyfemtet/opt/samples/femprj_sample/cad_ex01_NX.py +0 -135
  206. pyfemtet/opt/samples/femprj_sample/cad_ex01_NX_test_result.reccsv +0 -23
  207. pyfemtet/opt/samples/femprj_sample/cad_ex01_SW.SLDPRT +0 -0
  208. pyfemtet/opt/samples/femprj_sample/cad_ex01_SW.femprj +0 -0
  209. pyfemtet/opt/samples/femprj_sample/cad_ex01_SW.py +0 -131
  210. pyfemtet/opt/samples/femprj_sample/cad_ex01_SW_test_result.reccsv +0 -23
  211. pyfemtet/opt/samples/femprj_sample/constrained_pipe.femprj +0 -0
  212. pyfemtet/opt/samples/femprj_sample/constrained_pipe.py +0 -96
  213. pyfemtet/opt/samples/femprj_sample/constrained_pipe_test_result.reccsv +0 -13
  214. pyfemtet/opt/samples/femprj_sample/gal_ex58_parametric.femprj +0 -0
  215. pyfemtet/opt/samples/femprj_sample/gal_ex58_parametric.py +0 -74
  216. pyfemtet/opt/samples/femprj_sample/gal_ex58_parametric_test_result.reccsv +0 -13
  217. pyfemtet/opt/samples/femprj_sample/gau_ex08_parametric.femprj +0 -0
  218. pyfemtet/opt/samples/femprj_sample/gau_ex08_parametric.py +0 -58
  219. pyfemtet/opt/samples/femprj_sample/gau_ex08_parametric_test_result.reccsv +0 -23
  220. pyfemtet/opt/samples/femprj_sample/gau_ex12_parametric.femprj +0 -0
  221. pyfemtet/opt/samples/femprj_sample/gau_ex12_parametric.py +0 -52
  222. pyfemtet/opt/samples/femprj_sample/her_ex40_parametric.femprj +0 -0
  223. pyfemtet/opt/samples/femprj_sample/her_ex40_parametric.py +0 -138
  224. pyfemtet/opt/samples/femprj_sample/her_ex40_parametric_test_result.reccsv +0 -18
  225. pyfemtet/opt/samples/femprj_sample/paswat_ex1_parametric.femprj +0 -0
  226. pyfemtet/opt/samples/femprj_sample/paswat_ex1_parametric.py +0 -60
  227. pyfemtet/opt/samples/femprj_sample/paswat_ex1_parametric_parallel.py +0 -61
  228. pyfemtet/opt/samples/femprj_sample/paswat_ex1_parametric_test_result.reccsv +0 -18
  229. pyfemtet/opt/samples/femprj_sample/wat_ex14_parametric.femprj +0 -0
  230. pyfemtet/opt/samples/femprj_sample/wat_ex14_parametric.py +0 -58
  231. pyfemtet/opt/samples/femprj_sample/wat_ex14_parametric_parallel.py +0 -58
  232. pyfemtet/opt/samples/femprj_sample/wat_ex14_parametric_test_result.reccsv +0 -18
  233. pyfemtet/opt/samples/femprj_sample_jp/ParametricIF_jp.femprj +0 -0
  234. pyfemtet/opt/samples/femprj_sample_jp/ParametricIF_jp.py +0 -29
  235. pyfemtet/opt/samples/femprj_sample_jp/cad_ex01_NX_jp.femprj +0 -0
  236. pyfemtet/opt/samples/femprj_sample_jp/cad_ex01_NX_jp.py +0 -129
  237. pyfemtet/opt/samples/femprj_sample_jp/cad_ex01_SW_jp.femprj +0 -0
  238. pyfemtet/opt/samples/femprj_sample_jp/cad_ex01_SW_jp.py +0 -125
  239. pyfemtet/opt/samples/femprj_sample_jp/constrained_pipe_jp.py +0 -93
  240. pyfemtet/opt/samples/femprj_sample_jp/gal_ex58_parametric_jp.femprj +0 -0
  241. pyfemtet/opt/samples/femprj_sample_jp/gal_ex58_parametric_jp.py +0 -70
  242. pyfemtet/opt/samples/femprj_sample_jp/gau_ex08_parametric_jp.femprj +0 -0
  243. pyfemtet/opt/samples/femprj_sample_jp/gau_ex08_parametric_jp.py +0 -57
  244. pyfemtet/opt/samples/femprj_sample_jp/gau_ex12_parametric_jp.py +0 -52
  245. pyfemtet/opt/samples/femprj_sample_jp/her_ex40_parametric_jp.femprj +0 -0
  246. pyfemtet/opt/samples/femprj_sample_jp/her_ex40_parametric_jp.py +0 -138
  247. pyfemtet/opt/samples/femprj_sample_jp/paswat_ex1_parametric_jp.femprj +0 -0
  248. pyfemtet/opt/samples/femprj_sample_jp/paswat_ex1_parametric_jp.py +0 -58
  249. pyfemtet/opt/samples/femprj_sample_jp/paswat_ex1_parametric_parallel_jp.py +0 -59
  250. pyfemtet/opt/samples/femprj_sample_jp/wat_ex14_parametric_jp.py +0 -56
  251. pyfemtet/opt/samples/femprj_sample_jp/wat_ex14_parametric_parallel_jp.py +0 -56
  252. pyfemtet/opt/visualization/_complex_components/main_figure_creator.py +0 -332
  253. pyfemtet/opt/visualization/_complex_components/pm_graph_creator.py +0 -201
  254. pyfemtet/opt/visualization/_process_monitor/application.py +0 -226
  255. pyfemtet/opt/visualization/_process_monitor/pages.py +0 -406
  256. pyfemtet/opt/visualization/_wrapped_components/__init__.py +0 -0
  257. pyfemtet/opt/visualization/result_viewer/__init__.py +0 -0
  258. pyfemtet-0.9.4.dist-info/RECORD +0 -158
  259. pyfemtet-0.9.4.dist-info/entry_points.txt +0 -3
  260. /pyfemtet/{_femtet_config_util → opt/problem}/__init__.py +0 -0
  261. /pyfemtet/{brep → opt/visualization/history_viewer}/__init__.py +0 -0
  262. /pyfemtet/opt/{_test_utils → visualization/history_viewer/_complex_components}/__init__.py +0 -0
  263. /pyfemtet/opt/{optimizer/_optuna → visualization/history_viewer/_process_monitor}/__init__.py +0 -0
  264. /pyfemtet/opt/{optimizer/_optuna/_botorch_patch → visualization/history_viewer/_wrapped_components}/__init__.py +0 -0
  265. /pyfemtet/opt/visualization/{_wrapped_components → history_viewer/_wrapped_components}/str_enum.py +0 -0
  266. /pyfemtet/opt/visualization/{result_viewer → history_viewer/result_viewer}/.gitignore +0 -0
  267. /pyfemtet/opt/visualization/{_complex_components → history_viewer/result_viewer}/__init__.py +0 -0
  268. /pyfemtet/opt/visualization/{_process_monitor → plotter}/__init__.py +0 -0
  269. /pyfemtet/opt/{samples/femprj_sample_jp/wat_ex14_parametric_jp.femprj → wat_ex14_parametric_jp.femprj} +0 -0
  270. {pyfemtet-0.9.4.dist-info → pyfemtet-1.0.0a0.dist-info}/LICENSE +0 -0
  271. {pyfemtet-0.9.4.dist-info → pyfemtet-1.0.0a0.dist-info}/LICENSE_THIRD_PARTY.txt +0 -0
  272. {pyfemtet-0.9.4.dist-info → pyfemtet-1.0.0a0.dist-info}/WHEEL +0 -0
@@ -1,159 +0,0 @@
1
- # typing
2
- import logging
3
- from typing import Iterable
4
-
5
- # built-in
6
- import os
7
-
8
- # 3rd-party
9
- import numpy as np
10
- import pandas as pd
11
- import scipy.optimize
12
- from scipy.optimize import minimize, OptimizeResult
13
-
14
- # pyfemtet relative
15
- from pyfemtet.opt._femopt_core import OptimizationStatus, generate_lhs
16
- from pyfemtet.opt.optimizer import AbstractOptimizer, logger, OptimizationMethodChecker
17
- from pyfemtet.core import MeshError, ModelError, SolveError
18
- from pyfemtet._message import Msg
19
-
20
-
21
- class StopIteration2(Exception):
22
- pass
23
-
24
-
25
- class StopIterationCallback:
26
- def __init__(self, opt):
27
- self.opt: ScipyOptimizer = opt
28
- self.res: OptimizeResult = None
29
-
30
- def stop_iteration(self):
31
- # stop iteration gimmick
32
- # https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html
33
- if self.opt.minimize_kwargs['method'] == "trust-constr":
34
- raise StopIteration2 # supports nothing
35
- elif (
36
- self.opt.minimize_kwargs['method'] == 'TNC'
37
- or self.opt.minimize_kwargs['method'] == 'SLSQP'
38
- or self.opt.minimize_kwargs['method'] == 'COBYLA'
39
- ):
40
- raise StopIteration2 # supports xk
41
- else:
42
- raise StopIteration # supports xk , intermediate_result and StopIteration
43
-
44
-
45
- def __call__(self, xk=None, intermediate_result=None):
46
- self.res = intermediate_result
47
- if self.opt.entire_status.get() == OptimizationStatus.INTERRUPTING:
48
- self.opt.worker_status.set(OptimizationStatus.INTERRUPTING)
49
- self.stop_iteration()
50
-
51
-
52
- class ScipyMethodChecker(OptimizationMethodChecker):
53
- def check_incomplete_bounds(self, raise_error=True): return True
54
- def check_seed(self, raise_error=True):
55
- logger.warning(Msg.WARN_SCIPY_DOESNT_NEED_SEED)
56
- return True
57
-
58
-
59
- class ScipyOptimizer(AbstractOptimizer):
60
- """Optimizer using ```scipy```.
61
-
62
- This class provides an interface for the optimization
63
- engine using Scipy. For more details, please refer to
64
- the Scipy documentation.
65
-
66
- See Also:
67
- https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html
68
-
69
- Args:
70
- **minimize_kwargs:
71
- The keyword arguments of
72
- ```scipy.optimize.minimize```.
73
-
74
- Attributes:
75
- res (OptimizeResult):
76
- The return value of ```scipy.optimize.minimize```.
77
-
78
- """
79
-
80
- def __init__(
81
- self,
82
- **minimize_kwargs,
83
- ):
84
- super().__init__()
85
-
86
- # define members
87
- self.minimize_kwargs: dict = dict(
88
- method='L-BFGS-B',
89
- )
90
- self.minimize_kwargs.update(minimize_kwargs)
91
- self.res: OptimizeResult = None
92
- self.method_checker: OptimizationMethodChecker = ScipyMethodChecker(self)
93
- self.stop_iteration_callback = StopIterationCallback(self)
94
-
95
- def _objective(self, x: np.ndarray): # x: candidate parameter
96
- # update parameter
97
- df = self.get_parameter('df')
98
- df['value'] = x
99
- self.fem.update_parameter(df)
100
-
101
- # strict constraints
102
- ...
103
-
104
- # fem
105
- try:
106
- _, obj_values, cns_values = self.f(x)
107
- except (ModelError, MeshError, SolveError) as e:
108
- # 現在の技術的にエラーが起きたらスキップできない
109
- logger.error(Msg.ERR_FEM_FAILED_AND_CANNOT_CONTINUE)
110
- raise StopIteration2
111
-
112
- # constraints
113
- ...
114
-
115
- # # check interruption command
116
- # if self.entire_status.get() == OptimizationStatus.INTERRUPTING:
117
- # self.worker_status.set(OptimizationStatus.INTERRUPTING)
118
- # raise StopOptimize
119
-
120
- # objectives to objective
121
-
122
- return obj_values[0]
123
-
124
- def _setup_before_parallel(self):
125
- pass
126
-
127
- def run(self):
128
-
129
- # create init
130
- x0 = self.get_parameter('values')
131
-
132
- # create bounds
133
- if 'bounds' not in self.minimize_kwargs.keys():
134
- bounds = []
135
- for i, row in self.get_parameter('df').iterrows():
136
- lb, ub = row['lower_bound'], row['upper_bound']
137
- if lb is None: lb = -np.inf
138
- if ub is None: ub = np.inf
139
- bounds.append([lb, ub])
140
- self.minimize_kwargs.update(
141
- {'bounds': bounds}
142
- )
143
-
144
- # run optimize
145
- try:
146
- res = minimize(
147
- fun=self._objective,
148
- x0=x0,
149
- **self.minimize_kwargs,
150
- callback=self.stop_iteration_callback,
151
- )
152
- except StopIteration2:
153
- res = None
154
- logger.warn(Msg.WARN_INTERRUPTED_IN_SCIPY)
155
-
156
- if res is None:
157
- self.res = self.stop_iteration_callback.res
158
- else:
159
- self.res = res
@@ -1,127 +0,0 @@
1
- # typing
2
- import logging
3
- from typing import Iterable
4
-
5
- # built-in
6
- import os
7
-
8
- # 3rd-party
9
- import numpy as np
10
- import pandas as pd
11
- import scipy.optimize
12
- from scipy.optimize import minimize_scalar, OptimizeResult
13
-
14
- # pyfemtet relative
15
- from pyfemtet.opt._femopt_core import OptimizationStatus, generate_lhs
16
- from pyfemtet.opt.optimizer import AbstractOptimizer, logger, OptimizationMethodChecker
17
- from pyfemtet.core import MeshError, ModelError, SolveError
18
- from pyfemtet._message import Msg
19
-
20
-
21
- class ScipyScalarMethodChecker(OptimizationMethodChecker):
22
- def check_incomplete_bounds(self, raise_error=True): return True
23
- def check_seed(self, raise_error=True):
24
- logger.warning(Msg.WARN_SCIPY_DOESNT_NEED_SEED)
25
- return True
26
-
27
-
28
- class ScipyScalarOptimizer(AbstractOptimizer):
29
- """Optimizer using ```scipy```.
30
-
31
- This class provides an interface for the optimization
32
- engine using Scipy. For more details, please refer to
33
- the Scipy documentation.
34
-
35
- See Also:
36
- https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize_scalar.html
37
-
38
- Args:
39
- **minimize_kwargs:
40
- The keyword arguments of
41
- ```scipy.optimize.minimize_scalar```.
42
-
43
- Attributes:
44
- res (OptimizeResult):
45
- The return value of ```scipy.optimize.minimize_scalar```.
46
-
47
- """
48
-
49
- def __init__(
50
- self,
51
- **minimize_kwargs,
52
- ):
53
- super().__init__()
54
-
55
- # define members
56
- self.minimize_kwargs: dict = dict()
57
- self.minimize_kwargs.update(minimize_kwargs)
58
- self.res: OptimizeResult = None
59
- self.method_checker: OptimizationMethodChecker = ScipyScalarMethodChecker(self)
60
-
61
- def _objective(self, x: float): # x: candidate parameter
62
- # update parameter
63
-
64
- df = self.get_parameter('df')
65
- df['value'] = x
66
- self.fem.update_parameter(df)
67
-
68
- # strict constraints
69
- ...
70
-
71
- # fem
72
- try:
73
- _, obj_values, cns_values = self.f(x)
74
- except (ModelError, MeshError, SolveError) as e:
75
- # 現状、エラーが起きたらスキップできない
76
- raise StopIteration
77
-
78
- # constraints
79
- ...
80
-
81
- # check interruption command
82
- if self.entire_status.get() == OptimizationStatus.INTERRUPTING:
83
- self.worker_status.set(OptimizationStatus.INTERRUPTING)
84
- raise StopIteration
85
-
86
- # objectives to objective
87
-
88
- return obj_values[0]
89
-
90
- def _setup_before_parallel(self):
91
- pass
92
-
93
- def run(self):
94
-
95
- # create init
96
- params = self.get_parameter()
97
- assert len(params) == 1, print(f'{params} parameter(s) are passed.')
98
-
99
- # create bounds
100
- if 'bounds' not in self.minimize_kwargs.keys():
101
- bounds = []
102
-
103
- row = self.get_parameter('df')
104
- lb, ub = row['lower_bound'].iloc[0], row['upper_bound'].iloc[0]
105
-
106
- if lb is None and ub is None:
107
- pass
108
- elif lb is None or ub is None:
109
- raise ValueError('Both lower and upper bounds must be set.')
110
- else:
111
- bounds = [lb, ub]
112
- self.minimize_kwargs.update(
113
- {'bounds': bounds}
114
- )
115
-
116
- # run optimize
117
- try:
118
- res = minimize_scalar(
119
- fun=self._objective,
120
- **self.minimize_kwargs,
121
- )
122
- except StopIteration:
123
- res = None
124
- logger.warn('Optimization has been interrupted. '
125
- 'Note that you cannot acquire the OptimizationResult.')
126
-
127
- self.res = res
@@ -1,113 +0,0 @@
1
- from graphlib import TopologicalSorter
2
- from dataclasses import dataclass
3
- import inspect
4
- from typing import Optional, Callable, Any, Tuple, Dict
5
-
6
- import numpy as np
7
- import pandas as pd
8
-
9
-
10
- @dataclass
11
- class Variable:
12
- name: str
13
- value: float
14
- pass_to_fem: Optional[bool] = True
15
- properties: Optional[dict[Any]] = None
16
-
17
-
18
- @dataclass
19
- class Parameter(Variable):
20
- lower_bound: Optional[float] = None
21
- upper_bound: Optional[float] = None
22
- step: Optional[float] = None
23
-
24
-
25
- @dataclass
26
- class Expression(Variable):
27
- # fun に params を自動で代入するので positional args は実装しない
28
- fun: Optional[Callable] = None
29
- kwargs: Optional[Dict] = None
30
-
31
-
32
- class ExpressionEvaluator:
33
- def __init__(self):
34
- self.variables = {} # Parameter 又は計算された Expression が入る
35
- self.parameters = {}
36
- self.expressions = {}
37
- self.dependencies = {}
38
- self.evaluation_order = []
39
-
40
- def add_parameter(self, prm: Parameter):
41
- self.variables[prm.name] = prm
42
- self.parameters[prm.name] = prm
43
- self.dependencies[prm.name] = set()
44
-
45
- def add_expression(self, exp: Expression):
46
- self.expressions[exp.name] = exp
47
-
48
- # params は Python 変数として使える文字のみからなる文字列のリスト
49
- params = inspect.signature(exp.fun).parameters
50
- self.dependencies[exp.name] = set(params) - set(exp.kwargs.keys())
51
-
52
- def resolve(self):
53
- ts = TopologicalSorter(self.dependencies)
54
- self.evaluation_order = list(ts.static_order())
55
-
56
- def evaluate(self):
57
- # order 順に見ていき、expression なら計算して variables を更新する
58
- for var_name in self.evaluation_order:
59
- if var_name in self.expressions.keys():
60
- # 現在の expression に関して parameter 部分の引数 kwargs を作成
61
- kwargs = {param: self.variables[param].value for param in self.dependencies[var_name]}
62
-
63
- # fun に すべての kwargs を入れて expression の value を更新
64
- exp: Expression = self.expressions[var_name]
65
- kwargs.update(exp.kwargs)
66
- exp.value = exp.fun(**kwargs)
67
-
68
- # 計算済み variables に追加
69
- self.variables[var_name] = exp
70
-
71
- def get_variables(self, format='dict', filter_pass_to_fem=False, filter_parameter=False):
72
- """format: dict, values, df, raw(list of Variable object)"""
73
-
74
- # リストを作成
75
- vars = [self.variables[name] for name in self.evaluation_order if name in self.variables]
76
-
77
- # 必要なら FEM に直接使うもののみ取り出し
78
- if filter_pass_to_fem:
79
- vars = [var for var in vars if var.pass_to_fem]
80
-
81
- # 必要なら parameter のみ取り出し
82
- if filter_parameter:
83
- vars = [var for var in vars if isinstance(var, Parameter)]
84
-
85
- if format == 'raw':
86
- return vars
87
-
88
- elif format == 'dict':
89
- return {var.name: var.value for var in vars}
90
-
91
- elif format == 'values':
92
- return np.array([var.value for var in vars]).astype(float)
93
-
94
- elif format == 'df':
95
- data = dict(
96
- name=[var.name for var in vars],
97
- value=[var.value for var in vars],
98
- properties=[var.properties for var in vars],
99
- )
100
- if filter_parameter:
101
- data.update(
102
- dict(
103
- lower_bound=[var.lower_bound for var in vars],
104
- upper_bound=[var.upper_bound for var in vars],
105
- )
106
- )
107
- return pd.DataFrame(data)
108
-
109
- else:
110
- raise NotImplementedError(f'invalid format: {format}. Valid formats are `dict`, `values`, `df` and `raw`(= list of Variables).')
111
-
112
- def get_parameter_names(self):
113
- return list(self.parameters.keys())
@@ -1,61 +0,0 @@
1
- from abc import ABC, abstractmethod
2
-
3
- import numpy as np
4
- import pandas as pd
5
-
6
- from pyfemtet.opt._femopt_core import History
7
-
8
-
9
- class PredictionModelBase(ABC):
10
- """Simple Abstract surrogate model class."""
11
-
12
- @abstractmethod
13
- def fit(self, x: np.ndarray, y: np.ndarray):
14
- """
15
- Args:
16
- x (np.ndarray): Input. (Point number) rows and (variable number) columns.
17
- y (np.ndarray): Output. (Point number) rows and (objective number) columns.
18
- """
19
-
20
- @abstractmethod
21
- def predict(self, x: np.ndarray) -> tuple[np.ndarray, np.ndarray]:
22
- """
23
- Args:
24
- x (np.ndarray): Input. (Point number) rows and (variable number) columns.
25
- Returns:
26
- np.ndarray: (Point number) rows and (objective number) columns. Index 0 is mean and index 1 is std.
27
- """
28
-
29
-
30
- class PyFemtetPredictionModel:
31
-
32
- def __init__(self, history: History, df: pd.DataFrame, MetaModel: type):
33
- assert issubclass(MetaModel, PredictionModelBase)
34
- self.meta_model: PredictionModelBase = MetaModel()
35
-
36
- from pyfemtet.opt.prediction.single_task_gp import SingleTaskGPModel
37
- if isinstance(self.meta_model, SingleTaskGPModel):
38
- self.meta_model.set_bounds_from_history(
39
- history,
40
- df,
41
- )
42
-
43
- self.obj_names = history.obj_names
44
- self.prm_names = history.prm_names
45
- self.df = df
46
- self.x: np.ndarray = df[self.prm_names].values
47
- self.y: np.ndarray = df[self.obj_names].values
48
-
49
- def get_prm_index(self, prm_name):
50
- return self.prm_names.index(prm_name) if prm_name in self.prm_names else None
51
-
52
- def get_obj_index(self, obj_name):
53
- return self.obj_names.index(obj_name) if obj_name in self.obj_names else None
54
-
55
- def fit(self) -> None:
56
- self.meta_model.fit(self.x, self.y)
57
-
58
- def predict(self, x: np.ndarray) -> tuple[np.ndarray, np.ndarray]:
59
- assert len(x.shape) == 2
60
- assert x.shape[1] == len(self.prm_names)
61
- return self.meta_model.predict(x)
@@ -1,119 +0,0 @@
1
- import numpy as np
2
- import torch
3
- import gpytorch
4
-
5
- from botorch.models import SingleTaskGP
6
- from botorch.models.transforms.input import Normalize
7
- from botorch.models.transforms.outcome import Standardize
8
- from botorch.fit import fit_gpytorch_mll
9
- from gpytorch.mlls import ExactMarginalLogLikelihood
10
-
11
- from pyfemtet.opt.prediction._base import PredictionModelBase
12
-
13
-
14
- DEVICE = 'cpu'
15
- DTYPE = torch.float64
16
-
17
-
18
- def tensor(x_):
19
- return torch.tensor(x_, dtype=DTYPE, device=DEVICE)
20
-
21
-
22
- class SingleTaskGPModel(PredictionModelBase):
23
- """Simple interface surrogate model using ```SingleTaskGP```.
24
-
25
- See Also:
26
- https://botorch.org/api/models.html#botorch.models.gp_regression.SingleTaskGP
27
- """
28
-
29
- def __init__(self, bounds=None, is_noise_free=True):
30
- if bounds is not None:
31
- if isinstance(bounds, np.ndarray):
32
- self.bounds = tensor(bounds).T
33
- elif isinstance(bounds, list) or isinstance(bounds, tuple):
34
- self.bounds = tensor(np.array(bounds)).T
35
- else:
36
- raise NotImplementedError('Bounds must be a np.ndarray or list or tuple.')
37
- else:
38
- self.bounds = None
39
- self.is_noise_free = is_noise_free
40
- self._standardizer: Standardize = None
41
-
42
- def set_bounds_from_history(self, history, df=None):
43
- from pyfemtet.opt._femopt_core import History
44
- history: History
45
- meta_column: str
46
-
47
- if df is None:
48
- df = history.get_df()
49
-
50
- columns = df.columns
51
-
52
- target_columns = [
53
- col for col, meta_column in zip(columns, history.meta_columns)
54
- if meta_column == 'prm_lb' or meta_column == 'prm_ub'
55
- ]
56
-
57
- bounds_buff = df.iloc[0][target_columns].values # 2*len(prm_names) array
58
- bounds = bounds_buff.reshape(-1, 2).astype(float)
59
- self.bounds = tensor(bounds).T
60
-
61
- # noinspection PyAttributeOutsideInit
62
- def fit(self, x: np.ndarray, y: np.ndarray):
63
- X = tensor(x)
64
- Y = tensor(y)
65
-
66
- # Standardize を SingleTaskGP に任せると
67
- # 小さい Variance を勝手に 1e-10 に丸めるので
68
- # 外で Standardize してから渡す
69
- standardizer = Standardize(m=Y.shape[-1],)
70
- std_Y, _ = standardizer.forward(Y)
71
- YVar = torch.full_like(Y, 1e-6)
72
- self._standardizer = standardizer
73
-
74
- # Fit a Gaussian Process model using the extracted data
75
- self.gp = SingleTaskGP(
76
- train_X=X,
77
- train_Y=std_Y,
78
- train_Yvar=YVar if self.is_noise_free else None,
79
- input_transform=Normalize(d=X.shape[-1], bounds=self.bounds),
80
- # BoTorch 0.13 前後で None を渡すと
81
- # Standardize しない挙動は変わらないので None を渡せばよい
82
- outcome_transform=None,
83
- )
84
- mll = ExactMarginalLogLikelihood(self.gp.likelihood, self.gp)
85
- fit_gpytorch_mll(mll)
86
-
87
- def predict(self, x: np.ndarray) -> tuple[np.ndarray, np.ndarray]:
88
- assert len(x.shape) >= 2
89
-
90
- X = tensor(x)
91
-
92
- post = self.gp.posterior(X)
93
-
94
- # fit() で Standardize してから SingleTaskGP に渡したので
95
- # posterior は手動で un-standardize する必要がある
96
- M, V = self._standardizer.untransform(post.mean, post.variance)
97
-
98
- mean = M.detach().numpy()
99
- var = V.detach().numpy()
100
- std = np.sqrt(var)
101
-
102
- return mean, std
103
-
104
-
105
- if __name__ == '__main__':
106
- dim = 3
107
- N = 20
108
- bounds = (np.arange(dim*2)**2).reshape((-1, 2))
109
- x = np.random.rand(N, dim)
110
- x = x * (bounds[:, 1] - bounds[:, 0]) + bounds[:, 0]
111
- y = (x ** 2).sum(axis=1, keepdims=True) * 1e-7
112
-
113
- model = SingleTaskGPModel()
114
- model.fit(x, y)
115
- print(model.predict(np.array([[(b[1] + b[0])/2 for b in bounds]])))
116
-
117
- # 外挿
118
- print(model.predict(np.array([[b[1] for b in bounds]])))
119
- print(model.predict(np.array([[b[1] * 2 for b in bounds]])))
@@ -1,29 +0,0 @@
1
- from pyfemtet.opt import FemtetInterface, FEMOpt, AbstractOptimizer
2
-
3
-
4
- def ex_in(_, opt: AbstractOptimizer):
5
- ex_r, in_r = opt.get_parameter('values')
6
- return ex_r - in_r
7
-
8
-
9
-
10
- if __name__ == '__main__':
11
-
12
- fem = FemtetInterface(
13
- parametric_output_indexes_use_as_objective={
14
- 0: "minimize",
15
- 1: "minimize",
16
- 2: "minimize",
17
- },
18
- )
19
-
20
- femopt = FEMOpt(fem=fem)
21
-
22
- femopt.add_parameter("external_radius", 10, 1, 10)
23
- femopt.add_parameter("internal_radius", 5, 1, 10)
24
- femopt.add_constraint(ex_in, lower_bound=1, strict=True, args=(femopt.opt,))
25
- femopt.set_random_seed(42)
26
- femopt.optimize(
27
- n_trials=10,
28
- n_parallel=1,
29
- )
@@ -1,13 +0,0 @@
1
- "{""femprj_path"": null, ""model_name"": ""test_5""}",prm,prm_lb,prm_ub,prm,prm_lb,prm_ub,obj,obj_direction,obj,obj_direction,obj,obj_direction,,cns,cns_lb,cns_ub,,,,
2
- ,,,,,,,,,,,,,,,,,,,,
3
- trial,external_radius,external_radius_lower_bound,external_radius_upper_bound,internal_radius,internal_radius_lower_bound,internal_radius_upper_bound,����[Kg] / Cylinder,����[Kg] / Cylinder_direction,����[Pa] / �~�[�[�X�̑������� / �ő�l / Cylinder,����[Pa] / �~�[�[�X�̑������� / �ő�l / Cylinder_direction,�ψ�[m] / �傫�� / �ő�l / Cylinder,�ψ�[m] / �傫�� / �ő�l / Cylinder_direction,non_domi,cns_0,cns_0_lower_bound,cns_0_upper_bound,feasible,hypervolume,message,time
4
- 1,10.0,1.0,10.0,5.0,1.0,10.0,0.08025126265847096,minimize,699391.2949775695,minimize,3.5987515450106034e-07,minimize,True,5.0,1,,True,0.0,initial,2024-07-24 12:03:18.218300
5
- 2,7.587945476302646,1.0,10.0,6.387926357773329,1.0,10.0,0.018829523087730202,minimize,2819410.021640385,minimize,1.9633635574428563e-06,minimize,True,1.2000191185293163,1,,True,0.0072609644545304644,,2024-07-24 12:03:21.608587
6
- 3,8.491983767203795,1.0,10.0,2.9110519961044856,1.0,10.0,0.06578893373109447,minimize,1058372.1746301493,minimize,6.396966778509452e-07,minimize,True,5.580931771099309,1,,True,0.13523816247173967,,2024-07-24 12:03:25.454547
7
- 4,9.488999089406718,1.0,10.0,1.053974646602355,1.0,10.0,0.09344346108490897,minimize,738819.4364388706,minimize,3.9190983806535766e-07,minimize,False,8.435024442804362,1,,True,0.13523816247173967,,2024-07-24 12:03:28.900803
8
- 5,9.838880436025262,1.0,10.0,4.121658022659597,1.0,10.0,0.08482642054771264,minimize,701388.5216985068,minimize,3.6449255450534674e-07,minimize,False,5.717222413365665,1,,True,0.13523816247173967,,2024-07-24 12:03:32.453681
9
- 6,8.455917394686129,1.0,10.0,4.306340483879064,1.0,10.0,0.055191055245607905,minimize,1170551.5363429904,minimize,7.0142545377377e-07,minimize,True,4.149576910807064,1,,True,0.23270321585070972,,2024-07-24 12:03:35.355075
10
- 7,7.5733020568630876,1.0,10.0,4.532076028923693,1.0,10.0,0.038663363226300325,minimize,1680507.878460014,minimize,1.151410183947273e-06,minimize,True,3.041226027939395,1,,True,0.29888894485611545,,2024-07-24 12:03:38.348642
11
- 8,6.64195280415911,1.0,10.0,4.3268559224164935,1.0,10.0,0.02513863374590192,minimize,2992920.10569469,minimize,2.210659794963239e-06,minimize,False,2.3150968817426163,1,,True,0.29888894485611545,,2024-07-24 12:03:41.305751
12
- 9,5.457560349207987,1.0,10.0,3.6301461895178777,1.0,10.0,0.016440094818037845,minimize,5824574.81469252,minimize,4.804776216529427e-06,minimize,False,1.8274141596901092,1,,True,0.29888894485611545,,2024-07-24 12:03:44.694410
13
- 10,7.075956010136126,1.0,10.0,6.0727177168143935,1.0,10.0,0.013058674177275532,minimize,4421271.288534293,minimize,3.2060909560154104e-06,minimize,True,1.0032382933217328,1,,True,0.3600968150317699,,2024-07-24 12:03:47.854562