pyfemtet 0.9.5__py3-none-any.whl → 1.0.0b0__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 -17
  29. pyfemtet/opt/exceptions.py +45 -0
  30. pyfemtet/opt/femopt.py +608 -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} +505 -349
  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_model_interface/__init__.py +8 -0
  53. pyfemtet/opt/interface/_surrogate_model_interface/base_surrogate_interface.py +150 -0
  54. pyfemtet/opt/interface/_surrogate_model_interface/botorch_interface.py +298 -0
  55. pyfemtet/opt/interface/_surrogate_model_interface/debug-pof-botorch.reccsv +18 -0
  56. pyfemtet/opt/interface/_with_excel_settings/__init__.py +61 -0
  57. pyfemtet/opt/interface/_with_excel_settings/with_excel_settings.py +134 -0
  58. pyfemtet/opt/meta_script/YAML_Generator.xlsm +0 -0
  59. pyfemtet/opt/meta_script/__main__.py +58 -36
  60. pyfemtet/opt/optimizer/__init__.py +7 -9
  61. pyfemtet/opt/optimizer/_base_optimizer.py +885 -0
  62. pyfemtet/opt/optimizer/optuna_optimizer/__init__.py +9 -0
  63. pyfemtet/opt/optimizer/optuna_optimizer/_optuna_attribute.py +73 -0
  64. pyfemtet/opt/optimizer/optuna_optimizer/_optuna_optimizer.py +678 -0
  65. pyfemtet/opt/optimizer/optuna_optimizer/_pof_botorch/__init__.py +7 -0
  66. pyfemtet/opt/optimizer/optuna_optimizer/_pof_botorch/debug-pof-botorch.reccsv +18 -0
  67. pyfemtet/opt/optimizer/optuna_optimizer/_pof_botorch/enable_nonlinear_constraint.py +244 -0
  68. pyfemtet/opt/optimizer/optuna_optimizer/_pof_botorch/pof_botorch_sampler.py +1249 -0
  69. pyfemtet/opt/optimizer/optuna_optimizer/wat_ex14_parametric_jp.femprj +0 -0
  70. pyfemtet/opt/optimizer/scipy_optimizer/__init__.py +1 -0
  71. pyfemtet/opt/optimizer/scipy_optimizer/_scipy_optimizer.py +364 -0
  72. pyfemtet/opt/prediction/__init__.py +7 -0
  73. pyfemtet/opt/prediction/_botorch_utils.py +133 -0
  74. pyfemtet/opt/prediction/_gpytorch_modules_extension.py +142 -0
  75. pyfemtet/opt/prediction/_helper.py +155 -0
  76. pyfemtet/opt/prediction/_model.py +118 -0
  77. pyfemtet/opt/problem/problem.py +304 -0
  78. pyfemtet/opt/problem/variable_manager/__init__.py +20 -0
  79. pyfemtet/opt/problem/variable_manager/_string_as_expression.py +115 -0
  80. pyfemtet/opt/problem/variable_manager/_variable_manager.py +295 -0
  81. pyfemtet/opt/visualization/history_viewer/__main__.py +5 -0
  82. pyfemtet/opt/visualization/{_base.py → history_viewer/_base_application.py} +18 -13
  83. pyfemtet/opt/visualization/history_viewer/_common_pages.py +150 -0
  84. pyfemtet/opt/visualization/{_complex_components → history_viewer/_complex_components}/alert_region.py +10 -5
  85. pyfemtet/opt/visualization/{_complex_components → history_viewer/_complex_components}/control_femtet.py +16 -13
  86. pyfemtet/opt/visualization/{_complex_components → history_viewer/_complex_components}/main_graph.py +117 -47
  87. pyfemtet/opt/visualization/{_complex_components → history_viewer/_complex_components}/pm_graph.py +159 -138
  88. pyfemtet/opt/visualization/history_viewer/_process_monitor/_application.py +173 -0
  89. pyfemtet/opt/visualization/history_viewer/_process_monitor/_pages.py +291 -0
  90. pyfemtet/opt/visualization/{_wrapped_components → history_viewer/_wrapped_components}/dbc.py +1 -1
  91. pyfemtet/opt/visualization/{_wrapped_components → history_viewer/_wrapped_components}/dcc.py +1 -1
  92. pyfemtet/opt/visualization/{_wrapped_components → history_viewer/_wrapped_components}/html.py +1 -1
  93. pyfemtet/opt/visualization/history_viewer/result_viewer/__main__.py +5 -0
  94. pyfemtet/opt/visualization/{result_viewer/application.py → history_viewer/result_viewer/_application.py} +6 -6
  95. pyfemtet/opt/visualization/{result_viewer/pages.py → history_viewer/result_viewer/_pages.py} +106 -82
  96. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08.csv +18 -0
  97. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08.db +0 -0
  98. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8.jpg +0 -0
  99. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8.log +45 -0
  100. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8.pdt +0 -0
  101. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_1.jpg +0 -0
  102. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_1.pdt +0 -0
  103. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_10.jpg +0 -0
  104. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_10.pdt +0 -0
  105. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_11.jpg +0 -0
  106. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_11.pdt +0 -0
  107. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_12.jpg +0 -0
  108. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_12.pdt +0 -0
  109. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_13.jpg +0 -0
  110. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_13.pdt +0 -0
  111. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_14.jpg +0 -0
  112. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_14.pdt +0 -0
  113. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_15.jpg +0 -0
  114. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_15.pdt +0 -0
  115. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_16.jpg +0 -0
  116. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_16.pdt +0 -0
  117. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_17.jpg +0 -0
  118. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_17.pdt +0 -0
  119. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_18.jpg +0 -0
  120. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_18.pdt +0 -0
  121. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_19.jpg +0 -0
  122. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_19.pdt +0 -0
  123. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_2.jpg +0 -0
  124. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_2.pdt +0 -0
  125. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_20.jpg +0 -0
  126. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_20.pdt +0 -0
  127. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_3.jpg +0 -0
  128. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_3.pdt +0 -0
  129. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.bgr +0 -0
  130. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.bnd +0 -0
  131. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.btr +0 -0
  132. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.jpg +0 -0
  133. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.mtl +0 -0
  134. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.pdt +0 -0
  135. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.prm +0 -0
  136. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_5.jpg +0 -0
  137. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_5.pdt +0 -0
  138. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_6.jpg +0 -0
  139. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_6.pdt +0 -0
  140. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_7.jpg +0 -0
  141. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_7.pdt +0 -0
  142. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_8.jpg +0 -0
  143. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_8.pdt +0 -0
  144. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_9.jpg +0 -0
  145. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_9.pdt +0 -0
  146. pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.femprj +0 -0
  147. pyfemtet/opt/visualization/plotter/main_figure_creator.py +536 -0
  148. pyfemtet/opt/visualization/plotter/pm_graph_creator.py +359 -0
  149. pyfemtet/opt/worker_status.py +120 -0
  150. {pyfemtet-0.9.5.dist-info → pyfemtet-1.0.0b0.dist-info}/METADATA +23 -24
  151. pyfemtet-1.0.0b0.dist-info/RECORD +172 -0
  152. pyfemtet-1.0.0b0.dist-info/entry_points.txt +3 -0
  153. pyfemtet/_femtet_config_util/exit.py +0 -59
  154. pyfemtet/_message/1. make_pot.bat +0 -11
  155. pyfemtet/_message/2. make_mo.bat +0 -6
  156. pyfemtet/_message/__init__.py +0 -5
  157. pyfemtet/_message/babel.cfg +0 -2
  158. pyfemtet/_message/locales/ja/LC_MESSAGES/messages.mo +0 -0
  159. pyfemtet/_message/locales/ja/LC_MESSAGES/messages.po +0 -570
  160. pyfemtet/_message/locales/messages.pot +0 -551
  161. pyfemtet/_warning.py +0 -87
  162. pyfemtet/brep/_impl.py +0 -18
  163. pyfemtet/opt/_femopt.py +0 -1007
  164. pyfemtet/opt/_femopt_core.py +0 -1169
  165. pyfemtet/opt/_test_utils/control_femtet.py +0 -39
  166. pyfemtet/opt/_test_utils/hyper_sphere.py +0 -24
  167. pyfemtet/opt/_test_utils/record_history.py +0 -130
  168. pyfemtet/opt/advanced_samples/excel_ui/(ref) original_project.femprj +0 -0
  169. pyfemtet/opt/advanced_samples/excel_ui/femtet-macro.xlsm +0 -0
  170. pyfemtet/opt/advanced_samples/excel_ui/pyfemtet-core.py +0 -291
  171. pyfemtet/opt/advanced_samples/excel_ui/test-pyfemtet-core.cmd +0 -22
  172. pyfemtet/opt/advanced_samples/restart/gal_ex13_parametric.femprj +0 -0
  173. pyfemtet/opt/advanced_samples/restart/gal_ex13_parametric_restart.py +0 -99
  174. pyfemtet/opt/advanced_samples/restart/gal_ex13_parametric_restart_jp.py +0 -102
  175. pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_create_training_data.py +0 -60
  176. pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_create_training_data_jp.py +0 -57
  177. pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_optimize_with_surrogate.py +0 -100
  178. pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_optimize_with_surrogate_jp.py +0 -90
  179. pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_parametric.femprj +0 -0
  180. pyfemtet/opt/interface/_base.py +0 -101
  181. pyfemtet/opt/interface/_excel_interface.py +0 -984
  182. pyfemtet/opt/interface/_femtet_excel.py +0 -141
  183. pyfemtet/opt/interface/_femtet_with_nx/__init__.py +0 -3
  184. pyfemtet/opt/interface/_femtet_with_nx/_interface.py +0 -178
  185. pyfemtet/opt/interface/_femtet_with_sldworks.py +0 -298
  186. pyfemtet/opt/interface/_surrogate/__init__.py +0 -5
  187. pyfemtet/opt/interface/_surrogate/_base.py +0 -129
  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.5.dist-info/RECORD +0 -158
  259. pyfemtet-0.9.5.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.5.dist-info → pyfemtet-1.0.0b0.dist-info}/LICENSE +0 -0
  271. {pyfemtet-0.9.5.dist-info → pyfemtet-1.0.0b0.dist-info}/LICENSE_THIRD_PARTY.txt +0 -0
  272. {pyfemtet-0.9.5.dist-info → pyfemtet-1.0.0b0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,169 @@
1
+ # import
2
+ from packaging import version
3
+
4
+ import numpy as np
5
+ import optuna
6
+ if version.parse(optuna.version.__version__) < version.parse('4.0.0'):
7
+ # noinspection PyUnresolvedReferences
8
+ from optuna._hypervolume import WFG
9
+ wfg = WFG()
10
+ compute_hypervolume = wfg.compute
11
+ else:
12
+ from optuna._hypervolume import wfg
13
+ compute_hypervolume = wfg.compute_hypervolume
14
+
15
+ from ._optimality import *
16
+
17
+
18
+ __all__ = [
19
+ 'calc_hypervolume',
20
+ ]
21
+
22
+
23
+ def calc_hypervolume(
24
+ y_internal: np.ndarray,
25
+ feasibility: np.ndarray,
26
+ ref_point: str | np.ndarray = 'nadir-up-to-the-point'
27
+ ) -> np.ndarray:
28
+ """
29
+
30
+ Args:
31
+ y_internal: n x m shaped 2d-array. float. Can contain nan.
32
+ feasibility: n shaped 1d-array. bool.
33
+ ref_point:
34
+ 'nadir-up-to-the-point',
35
+ 'worst-up-to-the-point',
36
+ 'nadir',
37
+ 'worst',
38
+ or the fixed reference point of y_internal.
39
+
40
+ Returns: n shaped 1d-array. float.
41
+
42
+ """
43
+
44
+ # single objective
45
+ if y_internal.shape[-1] == 1:
46
+ return np.full_like(np.empty(len(y_internal)), np.nan, dtype=float)
47
+
48
+ # multi objective
49
+ if isinstance(ref_point, str):
50
+ if ref_point.lower() == 'nadir-up-to-the-point':
51
+ hv_values = calc_hypervolume_nadir_up_to_the_point(y_internal, feasibility)
52
+ elif ref_point.lower() == 'worst-up-to-the-point':
53
+ hv_values = calc_hypervolume_worst_up_to_the_point(y_internal, feasibility)
54
+ elif ref_point.lower() == 'nadir':
55
+ hv = calc_hypervolume_nadir(y_internal, feasibility)
56
+ hv_values = hv * np.ones(len(y_internal)).astype(float)
57
+ elif ref_point.lower() == 'worst':
58
+ hv = calc_hypervolume_worst(y_internal, feasibility)
59
+ hv_values = hv * np.ones(len(y_internal)).astype(float)
60
+ else:
61
+ raise NotImplementedError
62
+
63
+ elif isinstance(ref_point, np.ndarray):
64
+ hv = calc_hypervolume_fixed_point(y_internal, feasibility, ref_point)
65
+ hv_values = hv * np.ones(len(y_internal)).astype(float)
66
+
67
+ else:
68
+ raise NotImplementedError
69
+
70
+ return hv_values
71
+
72
+
73
+ def get_pareto_set(
74
+ y: np.ndarray,
75
+ feasibility: np.ndarray,
76
+ ) -> np.ndarray:
77
+ optimality = calc_optimality(y, feasibility)
78
+ non_dominated_solutions = y[optimality]
79
+ assert not np.any(np.isnan(non_dominated_solutions))
80
+ return non_dominated_solutions
81
+
82
+
83
+ def calc_hypervolume_nadir(y, feasibility) -> float:
84
+ """Use Nadir point as the ref_point.
85
+
86
+ Args:
87
+ y: (n, m) shaped 2d-array. float.
88
+ feasibility (np.ndarray): n shaped 1d-array. bool.
89
+
90
+ Returns: float.
91
+
92
+ """
93
+
94
+ pareto_set = get_pareto_set(y, feasibility)
95
+ if len(pareto_set) == 0:
96
+ return 0.
97
+
98
+ nadir_point = pareto_set.max(axis=0)
99
+ ref_point = nadir_point + 1e-8
100
+ hv = compute_hypervolume(pareto_set, ref_point)
101
+
102
+ return hv
103
+
104
+
105
+ def calc_hypervolume_nadir_up_to_the_point(y, feasibility) -> np.ndarray:
106
+ """Use Nadir point up_to_the_point as the ref_point.
107
+
108
+ Args:
109
+ y: (n, m) shaped 2d-array. float.
110
+ feasibility (np.ndarray): n shaped 1d-array. bool.
111
+
112
+ Returns: (n) shaped 1d-array. float.
113
+
114
+ """
115
+
116
+ out = []
117
+
118
+ assert len(y) == len(feasibility)
119
+ for n in range(len(y)):
120
+ y_up = y[:n]
121
+ f_up = feasibility[:n]
122
+ out.append(calc_hypervolume_nadir(y_up, f_up))
123
+
124
+ return np.array(out).astype(float)
125
+
126
+
127
+ def calc_hypervolume_worst(y, feasibility) -> float:
128
+ """Use Worst point as the ref_point.
129
+
130
+ Args:
131
+ y: (n, m) shaped 2d-array. float.
132
+ feasibility (np.ndarray): n shaped 1d-array. bool.
133
+
134
+ Returns: float.
135
+
136
+ """
137
+
138
+ feasible_solutions = y[feasibility]
139
+ if len(feasible_solutions) == 0:
140
+ return 0.
141
+
142
+ worst_point = feasible_solutions.max(axis=0)
143
+ ref_point = worst_point + 1e-8
144
+ hv = compute_hypervolume(feasible_solutions, ref_point)
145
+
146
+ return hv
147
+
148
+
149
+ def calc_hypervolume_worst_up_to_the_point(y, feasibility) -> np.ndarray:
150
+ out = []
151
+
152
+ assert len(y) == len(feasibility)
153
+ for n in range(len(y)):
154
+ y_up = y[:n]
155
+ f_up = feasibility[:n]
156
+ out.append(calc_hypervolume_worst(y_up, f_up))
157
+
158
+ return np.array(out).astype(float)
159
+
160
+
161
+ def calc_hypervolume_fixed_point(y, feasibility, ref_point) -> float:
162
+
163
+ feasible_solutions = y[feasibility]
164
+ if len(feasible_solutions) == 0:
165
+ return 0.
166
+
167
+ hv = compute_hypervolume(feasible_solutions, ref_point)
168
+
169
+ return hv
@@ -0,0 +1,79 @@
1
+ import numpy as np
2
+
3
+
4
+ __all__ = ['calc_optimality']
5
+
6
+
7
+ def calc_optimality(y_internal: np.ndarray, feasibility: np.ndarray) -> np.ndarray:
8
+ """
9
+
10
+ Args:
11
+ y_internal (np.ndarray): n x m shaped 2d-array. Can contain np.nan. Minimum value is optimal.
12
+ feasibility (np.ndarray): n shaped 1d-array. bool.
13
+
14
+ Returns:
15
+ np.ndarray: Array if not optimal, dominated or Nan False, else True
16
+
17
+ """
18
+
19
+ # 「全ての項目において
20
+ # 重複する解を除いて
21
+ # より優れているか又は同等である
22
+ # 他の解が存在しない解」であるかどうかを判定
23
+ y_values: np.ndarray
24
+ another_y_values: np.ndarray
25
+ optimality = []
26
+ assert len(y_internal) == len(feasibility)
27
+ for i, (y_values, feas) in enumerate(zip(y_internal, feasibility)):
28
+ for j, (another_y_values, another_feas) in enumerate(zip(y_internal, feasibility)):
29
+
30
+ # 自身が infeasible なら
31
+ # 比較を終了して False
32
+ if not feas:
33
+ optimality.append(False)
34
+ break
35
+
36
+ # 比較相手が infeasible なら
37
+ # 比較しない
38
+ elif not another_feas:
39
+ continue
40
+
41
+ # 自身との比較はしない
42
+ elif i == j:
43
+ continue
44
+
45
+ # 重複した解なら比較しない
46
+ elif np.allclose(y_values, another_y_values, atol=0, rtol=0.01):
47
+ assert np.all(~np.isnan(y_values))
48
+ assert np.all(~np.isnan(another_y_values))
49
+ continue
50
+
51
+ # 全項目について another のほうが
52
+ # 優れているか又は同等であるなら
53
+ # 比較を終了して False
54
+ elif all(another_y_values <= y_values):
55
+ optimality.append(False)
56
+ break
57
+
58
+ # その他の場合、比較を続行
59
+ else:
60
+ pass
61
+
62
+ # 自身以外のすべての解と比較して
63
+ # optimality が False になるような
64
+ # ことがなかったので True
65
+ else:
66
+ optimality.append(True)
67
+
68
+ return np.array(optimality).astype(bool)
69
+
70
+
71
+ if __name__ == '__main__':
72
+ _optimality = calc_optimality(
73
+ (_y := np.random.rand(10, 2)),
74
+ (_feas := (np.random.rand(10) > 0.25).astype(bool))
75
+ )
76
+
77
+ print(_y)
78
+ print(_feas)
79
+ print(_optimality)
@@ -1,37 +1,30 @@
1
1
  import platform
2
- from typing import TYPE_CHECKING
3
2
 
4
- from pyfemtet.opt.interface._base import FEMInterface
5
- from pyfemtet.opt.interface._base import NoFEM
3
+ from ._base_interface import AbstractFEMInterface, NoFEM
6
4
 
7
- if (platform.system() == 'Windows') or TYPE_CHECKING:
8
- from pyfemtet.opt.interface._femtet import FemtetInterface
9
- from pyfemtet.opt.interface._femtet_with_sldworks import FemtetWithSolidworksInterface
10
- from pyfemtet.opt.interface._femtet_with_nx import FemtetWithNXInterface
11
- from pyfemtet.opt.interface._excel_interface import ExcelInterface
5
+ if platform.system() == 'Windows':
6
+ from ._femtet_interface import FemtetInterface
7
+ from ._femtet_with_nx_interface import FemtetWithNXInterface
8
+ from ._femtet_with_solidworks import FemtetWithSolidworksInterface
9
+ from ._excel_interface import ExcelInterface
10
+ from ._with_excel_settings import *
11
+ from ._with_excel_settings import __all__ as _with_excel_settings__all__
12
12
 
13
- else:
14
- class NotAvailableForWindows:
15
- def __init__(self, *args, **kwargs):
16
- raise NotImplementedError
17
-
18
-
19
- FemtetInterface = type('FemtetInterface', (NotAvailableForWindows,), {})
20
- FemtetWithSolidworksInterface = type('FemtetWithSolidworksInterface', (FemtetInterface,), {})
21
- FemtetWithNXInterface = type('FemtetWithNXInterface', (FemtetInterface,), {})
22
- ExcelInterface = type('ExcelInterface', (NotAvailableForWindows,), {})
23
-
24
- from pyfemtet.opt.interface._surrogate._base import SurrogateModelInterfaceBase
25
- from pyfemtet.opt.interface._surrogate._singletaskgp import PoFBoTorchInterface
13
+ from ._surrogate_model_interface import AbstractSurrogateModelInterfaceBase
14
+ from ._surrogate_model_interface import BoTorchInterface
15
+ from ._surrogate_model_interface import PoFBoTorchInterface
26
16
 
27
17
 
28
18
  __all__ = [
29
- 'FEMInterface',
19
+ 'AbstractFEMInterface',
30
20
  'NoFEM',
31
21
  'FemtetInterface',
32
- 'FemtetWithSolidworksInterface',
33
22
  'FemtetWithNXInterface',
23
+ 'FemtetWithSolidworksInterface',
34
24
  'ExcelInterface',
35
- 'SurrogateModelInterfaceBase',
25
+ 'AbstractSurrogateModelInterfaceBase',
26
+ 'BoTorchInterface',
36
27
  'PoFBoTorchInterface',
37
28
  ]
29
+
30
+ __all__.extend(_with_excel_settings__all__)
@@ -0,0 +1,222 @@
1
+ from __future__ import annotations
2
+ from typing import TYPE_CHECKING
3
+
4
+ import os
5
+ import tempfile
6
+
7
+ import shutil
8
+ import pandas as pd
9
+
10
+ try:
11
+ # noinspection PyUnresolvedReferences
12
+ from pythoncom import CoInitialize, CoUninitialize
13
+ from win32com.client import Dispatch, Constants, constants
14
+ except ModuleNotFoundError:
15
+ # noinspection PyPep8Naming
16
+ def CoInitialize(): ...
17
+ # noinspection PyPep8Naming
18
+ def CoUninitialize(): ...
19
+ Dispatch = type('NoDispatch', (object,), {})
20
+ Constants = type('NoConstants', (object,), {})
21
+ constants = Constants()
22
+
23
+ from pyfemtet._util.dask_util import *
24
+ from pyfemtet.logger import get_module_logger
25
+ from pyfemtet.opt.problem.variable_manager import SupportedVariableTypes
26
+
27
+ logger = get_module_logger('opt.interface', False)
28
+
29
+ if TYPE_CHECKING:
30
+ from pyfemtet.opt.optimizer import AbstractOptimizer
31
+
32
+ __all__ = [
33
+ 'AbstractFEMInterface',
34
+ 'NoFEM',
35
+ ]
36
+
37
+
38
+ class AbstractFEMInterface:
39
+
40
+ kwargs: dict = {}
41
+ _load_problem_from_fem: bool = False
42
+ current_prm_values: dict[str, SupportedVariableTypes]
43
+ _tmp_dir: tempfile.TemporaryDirectory
44
+
45
+ # ===== update =====
46
+
47
+ def update_parameter(self, x: dict[str, SupportedVariableTypes]) -> None:
48
+ # FEM オブジェクトに与えられた変数を設定する。
49
+ # 目的は Function 内でユーザーが FEM オブジェクト経由で
50
+ # 変数を取得できるようにするためなので、各具象クラスでは
51
+ # FEM オブジェクトから新しい変数を取得できるように
52
+ # することが望ましい
53
+ self.current_prm_values = x
54
+
55
+ def update(self) -> None:
56
+ # 現在の設計変数に基づいて solve を行い、
57
+ # Objective が正しく値を計算できるようにする
58
+ raise NotImplementedError
59
+
60
+ # ===== Function =====
61
+
62
+ @property
63
+ def object_pass_to_fun(self):
64
+ """The object pass to the first argument of user-defined objective functions.
65
+
66
+ Returns:
67
+ self (AbstractFEMInterface)
68
+ """
69
+ return self
70
+
71
+ # ===== dask util =====
72
+
73
+ @staticmethod
74
+ def _get_worker_index_from_optimizer(opt: AbstractOptimizer | None) -> str:
75
+ if opt is None:
76
+ worker_index = 'copy'
77
+ else:
78
+ worker_index = f'copy_{opt._worker_index}' if opt._worker_index is not None else 'copy'
79
+ return worker_index
80
+
81
+ def _rename_and_get_path_on_worker_space(self, orig_path, suffix, ignore_no_exist=False) -> str:
82
+ # 与えられた path と同名のファイルを
83
+ # worker_space から探し
84
+ # suffix を付与して rename し
85
+ # その renamed path を返す関数
86
+
87
+ worker_space = self._get_worker_space()
88
+
89
+ src_path = os.path.join(worker_space, os.path.basename(orig_path))
90
+ p1_, p2_ = os.path.splitext(src_path)
91
+ dst_path_ = p1_ + '_' + suffix + p2_
92
+
93
+ if os.path.isfile(src_path):
94
+ os.rename(src_path, dst_path_)
95
+
96
+ elif not ignore_no_exist:
97
+ raise FileNotFoundError(f'{src_path} is not found.')
98
+
99
+ return dst_path_
100
+
101
+ def _get_worker_space(self) -> str | None:
102
+ worker = get_worker()
103
+ if worker is None:
104
+ assert hasattr(self, '_tmp_dir'), 'Internal Error! Run _distribute_files() first!'
105
+ return self._tmp_dir.name
106
+ else:
107
+ return worker.local_directory
108
+
109
+ def _distribute_files(self, paths: list[str]) -> None:
110
+
111
+ # executor 向け
112
+ self._copy_to_temp_space(paths)
113
+
114
+ # dask worker 向け
115
+ client = get_client()
116
+ if client is not None:
117
+ for path in paths:
118
+ if not os.path.exists(path):
119
+ raise FileNotFoundError
120
+ client.upload_file(path, load=False)
121
+
122
+ def _verify_tmp_dir(self):
123
+ should_process = False
124
+
125
+ if not hasattr(self, '_tmp_dir'):
126
+ should_process = True
127
+
128
+ elif self._tmp_dir is None:
129
+ should_process = True
130
+
131
+ if not should_process:
132
+ return
133
+
134
+ # dask worker space のように使える一時フォルダを作成する
135
+ # Python プロセス終了時に(使用中のプロセスがなければ)
136
+ # 削除されるので、重大なものでなければ後処理は不要
137
+ tmp_dir = tempfile.TemporaryDirectory(prefix='pyfemtet-')
138
+ self._tmp_dir = tmp_dir
139
+
140
+ def _copy_to_temp_space(self, paths: list[str]) -> None:
141
+
142
+ self._verify_tmp_dir()
143
+
144
+ # client.upload_file 相当の処理を行う
145
+ for path in paths:
146
+ shutil.copy(path, self._tmp_dir.name)
147
+
148
+ # ===== setup =====
149
+
150
+ def _setup_before_parallel(self) -> None:
151
+ pass
152
+
153
+ def _setup_after_parallel(self, opt: AbstractOptimizer) -> None:
154
+ pass
155
+
156
+ def _check_param_and_raise(self, prm_name) -> None:
157
+ pass
158
+
159
+ def load_variables(self, opt: AbstractOptimizer):
160
+ pass
161
+
162
+ def load_objectives(self, opt: AbstractOptimizer):
163
+ pass
164
+
165
+ def load_constraints(self, opt: AbstractOptimizer):
166
+ pass
167
+
168
+ def close(self, *args, **kwargs): # context manager による予約語
169
+ pass
170
+
171
+ # noinspection PyMethodMayBeStatic,PyUnusedLocal
172
+ def _check_using_fem(self, fun: callable) -> bool:
173
+ return False
174
+
175
+ # ===== postprocessing after recording =====
176
+
177
+ def _create_postprocess_args(self) -> dict[str, ...]:
178
+ return {}
179
+
180
+ @staticmethod
181
+ def _postprocess_after_recording(
182
+ dask_scheduler,
183
+ trial_name: str,
184
+ df: pd.DataFrame,
185
+ **kwargs
186
+ ) -> ...: # _postprocess_after_recording
187
+ pass
188
+
189
+ # ===== others =====
190
+
191
+ # noinspection PyMethodMayBeStatic
192
+ def _get_additional_data(self) -> dict:
193
+ return dict()
194
+
195
+
196
+ class COMInterface(AbstractFEMInterface):
197
+
198
+ com_members = {}
199
+
200
+ def __getstate__(self):
201
+ """Pickle するメンバーから COM を除外する"""
202
+ state = self.__dict__.copy()
203
+ for key in self.com_members.keys():
204
+ del state[key]
205
+ return state
206
+
207
+ def __setstate__(self, state):
208
+ """UnPickle 時に COM を再構築する
209
+
210
+ ただしメインプロセスでしか呼ばれない模様
211
+ dask のバージョン依存?
212
+ """
213
+ CoInitialize()
214
+ for key, value in self.com_members.items():
215
+ state.update({key: Dispatch(value)})
216
+ self.__dict__.update(state)
217
+
218
+
219
+ class NoFEM(AbstractFEMInterface):
220
+
221
+ def update(self) -> None:
222
+ return None
@@ -0,0 +1,3 @@
1
+ from .excel_interface import ExcelInterface
2
+
3
+ __all__ = ['ExcelInterface']