pyfemtet 1.0.0b0__tar.gz → 1.0.1__tar.gz

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 (172) hide show
  1. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/PKG-INFO +1 -1
  2. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/_util/df_util.py +18 -1
  3. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/_util/helper.py +9 -0
  4. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/femopt.py +13 -0
  5. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/history/_history.py +20 -6
  6. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/interface/_excel_interface/excel_interface.py +0 -2
  7. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/interface/_femtet_interface/femtet_interface.py +3 -4
  8. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/interface/_femtet_with_solidworks/femtet_with_solidworks_interface.py +20 -0
  9. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/interface/_solidworks_interface/solidworks_interface.py +21 -0
  10. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/optimizer/_base_optimizer.py +48 -22
  11. pyfemtet-1.0.1/pyfemtet/opt/optimizer/optuna_optimizer/_optuna_attribute.py +63 -0
  12. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/optimizer/optuna_optimizer/_optuna_optimizer.py +138 -20
  13. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/optimizer/optuna_optimizer/_pof_botorch/pof_botorch_sampler.py +3 -3
  14. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/optimizer/scipy_optimizer/_scipy_optimizer.py +19 -0
  15. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/problem/variable_manager/_variable_manager.py +84 -28
  16. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyproject.toml +3 -4
  17. pyfemtet-1.0.0b0/pyfemtet/opt/optimizer/optuna_optimizer/_optuna_attribute.py +0 -73
  18. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/LICENSE +0 -0
  19. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/LICENSE_THIRD_PARTY.txt +0 -0
  20. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/README.md +0 -0
  21. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/__init__.py +0 -0
  22. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/_i18n/1. make_pot_and_update_po.bat +0 -0
  23. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/_i18n/2. build_mo.bat +0 -0
  24. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/_i18n/__init__.py +0 -0
  25. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/_i18n/babel.cfg +0 -0
  26. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/_i18n/i18n.py +0 -0
  27. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/_i18n/locales/ja/LC_MESSAGES/messages.mo +0 -0
  28. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/_i18n/locales/ja/LC_MESSAGES/messages.po +0 -0
  29. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/_i18n/locales/messages.pot +0 -0
  30. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/_i18n/messages.py +0 -0
  31. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/_util/__init__.py +0 -0
  32. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/_util/closing.py +0 -0
  33. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/_util/dask_util.py +0 -0
  34. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/_util/excel_macro_util.py +0 -0
  35. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/_util/excel_parse_util.py +0 -0
  36. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/_util/femtet_access_inspection.py +0 -0
  37. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/_util/femtet_autosave.py +0 -0
  38. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/_util/femtet_exit.py +0 -0
  39. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/_util/femtet_version.py +0 -0
  40. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/_util/process_util.py +0 -0
  41. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/_util/sample.xlsx +0 -0
  42. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/_util/str_enum.py +0 -0
  43. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/core.py +0 -0
  44. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/dispatch_extensions/__init__.py +0 -0
  45. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/dispatch_extensions/_impl.py +0 -0
  46. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/logger/__init__.py +0 -0
  47. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/logger/_impl.py +0 -0
  48. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/__init__.py +0 -0
  49. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/exceptions.py +0 -0
  50. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/history/__init__.py +0 -0
  51. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/history/_hypervolume.py +0 -0
  52. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/history/_optimality.py +0 -0
  53. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/interface/__init__.py +0 -0
  54. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/interface/_base_interface.py +0 -0
  55. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/interface/_excel_interface/__init__.py +0 -0
  56. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/interface/_excel_interface/debug-excel-interface.xlsm +0 -0
  57. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/interface/_femtet_interface/__init__.py +0 -0
  58. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/interface/_femtet_interface/_femtet_parametric.py +0 -0
  59. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/interface/_femtet_with_nx_interface/__init__.py +0 -0
  60. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/interface/_femtet_with_nx_interface/femtet_with_nx_interface.py +0 -0
  61. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/interface/_femtet_with_nx_interface/model1.prt +0 -0
  62. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/interface/_femtet_with_nx_interface/model1.x_t +0 -0
  63. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/interface/_femtet_with_nx_interface/update_model.py +0 -0
  64. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/interface/_femtet_with_solidworks/__init__.py +0 -0
  65. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/interface/_solidworks_interface/__init__.py +0 -0
  66. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/interface/_surrogate_model_interface/__init__.py +0 -0
  67. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/interface/_surrogate_model_interface/base_surrogate_interface.py +0 -0
  68. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/interface/_surrogate_model_interface/botorch_interface.py +0 -0
  69. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/interface/_surrogate_model_interface/debug-pof-botorch.reccsv +0 -0
  70. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/interface/_with_excel_settings/__init__.py +0 -0
  71. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/interface/_with_excel_settings/with_excel_settings.py +0 -0
  72. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/meta_script/YAML_Generator.xlsm +0 -0
  73. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/meta_script/__init__.py +0 -0
  74. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/meta_script/__main__.py +0 -0
  75. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/meta_script/sample/sample.bas +0 -0
  76. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/meta_script/sample/sample.femprj +0 -0
  77. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/optimizer/__init__.py +0 -0
  78. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/optimizer/optuna_optimizer/__init__.py +0 -0
  79. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/optimizer/optuna_optimizer/_pof_botorch/__init__.py +0 -0
  80. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/optimizer/optuna_optimizer/_pof_botorch/debug-pof-botorch.reccsv +0 -0
  81. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/optimizer/optuna_optimizer/_pof_botorch/enable_nonlinear_constraint.py +0 -0
  82. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/optimizer/optuna_optimizer/wat_ex14_parametric_jp.femprj +0 -0
  83. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/optimizer/scipy_optimizer/__init__.py +0 -0
  84. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/prediction/__init__.py +0 -0
  85. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/prediction/_botorch_utils.py +0 -0
  86. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/prediction/_gpytorch_modules_extension.py +0 -0
  87. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/prediction/_helper.py +0 -0
  88. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/prediction/_model.py +0 -0
  89. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/problem/__init__.py +0 -0
  90. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/problem/problem.py +0 -0
  91. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/problem/variable_manager/__init__.py +0 -0
  92. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/problem/variable_manager/_string_as_expression.py +0 -0
  93. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/__init__.py +0 -0
  94. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/_create_wrapped_components.py +0 -0
  95. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/__init__.py +0 -0
  96. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/__main__.py +0 -0
  97. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/_base_application.py +0 -0
  98. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/_common_pages.py +0 -0
  99. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/_complex_components/__init__.py +0 -0
  100. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/_complex_components/alert_region.py +0 -0
  101. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/_complex_components/control_femtet.py +0 -0
  102. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/_complex_components/main_graph.py +0 -0
  103. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/_complex_components/pm_graph.py +0 -0
  104. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/_process_monitor/__init__.py +0 -0
  105. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/_process_monitor/_application.py +0 -0
  106. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/_process_monitor/_pages.py +0 -0
  107. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/_wrapped_components/__init__.py +0 -0
  108. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/_wrapped_components/dbc.py +0 -0
  109. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/_wrapped_components/dcc.py +0 -0
  110. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/_wrapped_components/html.py +0 -0
  111. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/_wrapped_components/str_enum.py +0 -0
  112. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/.gitignore +0 -0
  113. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/__init__.py +0 -0
  114. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/__main__.py +0 -0
  115. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/_application.py +0 -0
  116. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/_pages.py +0 -0
  117. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08.csv +0 -0
  118. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08.db +0 -0
  119. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8.jpg +0 -0
  120. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8.log +0 -0
  121. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8.pdt +0 -0
  122. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_1.jpg +0 -0
  123. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_1.pdt +0 -0
  124. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_10.jpg +0 -0
  125. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_10.pdt +0 -0
  126. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_11.jpg +0 -0
  127. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_11.pdt +0 -0
  128. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_12.jpg +0 -0
  129. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_12.pdt +0 -0
  130. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_13.jpg +0 -0
  131. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_13.pdt +0 -0
  132. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_14.jpg +0 -0
  133. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_14.pdt +0 -0
  134. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_15.jpg +0 -0
  135. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_15.pdt +0 -0
  136. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_16.jpg +0 -0
  137. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_16.pdt +0 -0
  138. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_17.jpg +0 -0
  139. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_17.pdt +0 -0
  140. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_18.jpg +0 -0
  141. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_18.pdt +0 -0
  142. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_19.jpg +0 -0
  143. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_19.pdt +0 -0
  144. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_2.jpg +0 -0
  145. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_2.pdt +0 -0
  146. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_20.jpg +0 -0
  147. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_20.pdt +0 -0
  148. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_3.jpg +0 -0
  149. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_3.pdt +0 -0
  150. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.bgr +0 -0
  151. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.bnd +0 -0
  152. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.btr +0 -0
  153. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.jpg +0 -0
  154. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.mtl +0 -0
  155. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.pdt +0 -0
  156. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.prm +0 -0
  157. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_5.jpg +0 -0
  158. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_5.pdt +0 -0
  159. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_6.jpg +0 -0
  160. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_6.pdt +0 -0
  161. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_7.jpg +0 -0
  162. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_7.pdt +0 -0
  163. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_8.jpg +0 -0
  164. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_8.pdt +0 -0
  165. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_9.jpg +0 -0
  166. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_9.pdt +0 -0
  167. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.femprj +0 -0
  168. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/plotter/__init__.py +0 -0
  169. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/plotter/main_figure_creator.py +0 -0
  170. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/visualization/plotter/pm_graph_creator.py +0 -0
  171. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/wat_ex14_parametric_jp.femprj +0 -0
  172. {pyfemtet-1.0.0b0 → pyfemtet-1.0.1}/pyfemtet/opt/worker_status.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pyfemtet
3
- Version: 1.0.0b0
3
+ Version: 1.0.1
4
4
  Summary: Design parameter optimization using Femtet.
5
5
  License: MIT
6
6
  Author: kazuma.naito
@@ -1,3 +1,4 @@
1
+ from math import isnan
1
2
  import pandas as pd
2
3
 
3
4
 
@@ -9,8 +10,24 @@ __all__ = [
9
10
 
10
11
  def get_index(df, equality_filters):
11
12
  # フィルタ条件に一致する行のインデックスを取得
13
+
14
+ # na との == での比較は常に False なので別処理するために別リストを作る
15
+ want_na_keys = []
16
+ for key, value in equality_filters.items():
17
+ if isinstance(value, float):
18
+ if isnan(value):
19
+ want_na_keys.append(key)
20
+ [equality_filters.pop(key) for key in want_na_keys]
21
+
22
+ # na 以外の比較
12
23
  # noinspection PyUnresolvedReferences
13
- return (df[list(equality_filters.keys())] == pd.Series(equality_filters)).all(axis=1)
24
+ out: pd.Series = (df[list(equality_filters.keys())] == pd.Series(equality_filters)).all(axis=1)
25
+
26
+ # na との比較
27
+ for key in want_na_keys:
28
+ out = out & df[key].isna()
29
+
30
+ return out
14
31
 
15
32
 
16
33
  def get_partial_df(df: pd.DataFrame, equality_filters: dict):
@@ -1,6 +1,9 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from typing import Callable
4
+
5
+ import string
6
+ import secrets
4
7
  import warnings
5
8
  from time import time, sleep
6
9
  from threading import Thread
@@ -10,6 +13,7 @@ from pyfemtet._i18n import _
10
13
  __all__ = [
11
14
  'float_',
12
15
  'time_counting',
16
+ 'generate_random_id',
13
17
  ]
14
18
 
15
19
 
@@ -92,3 +96,8 @@ def time_counting(
92
96
  warning_message,
93
97
  warning_fun,
94
98
  )
99
+
100
+
101
+ def generate_random_id(length: int = 16) -> str:
102
+ alphabet = string.ascii_letters + string.digits
103
+ return ''.join(secrets.choice(alphabet) for _ in range(length))
@@ -29,6 +29,19 @@ logger = get_module_logger('opt.femopt', False)
29
29
 
30
30
 
31
31
  class FEMOpt:
32
+ """
33
+ A class to manage finite element method (FEM) optimization using a specified optimizer and FEM interface.
34
+
35
+ Attributes:
36
+ opt (AbstractOptimizer): The optimizer instance to be used for optimization.
37
+ monitor_info (dict[str, str | int | None]): Dictionary to store monitoring information such as host and port.
38
+
39
+ Args:
40
+ fem (AbstractFEMInterface, optional): An instance of a FEM interface. Defaults to None, in which case a FemtetInterface is used.
41
+ opt (AbstractOptimizer, optional): An optimizer instance. Defaults to None, in which case OptunaOptimizer is used.
42
+
43
+ """
44
+
32
45
  opt: AbstractOptimizer
33
46
 
34
47
  def __init__(
@@ -18,6 +18,7 @@ import pandas as pd
18
18
  import pyfemtet
19
19
 
20
20
  from pyfemtet._i18n import *
21
+ from pyfemtet._util.helper import generate_random_id
21
22
  from pyfemtet._util.df_util import *
22
23
  from pyfemtet._util.dask_util import *
23
24
  from pyfemtet._util.str_enum import StrEnum
@@ -43,7 +44,10 @@ __all__ = [
43
44
  'MAIN_FILTER',
44
45
  ]
45
46
 
46
- MAIN_FILTER: dict = {'sub_fidelity_name': MAIN_FIDELITY_NAME}
47
+ MAIN_FILTER: dict = {
48
+ 'sub_fidelity_name': MAIN_FIDELITY_NAME,
49
+ 'sub_sampling': float('nan')
50
+ }
47
51
 
48
52
 
49
53
  logger = get_module_logger('opt.history', False)
@@ -126,9 +130,10 @@ class DataFrameWrapper:
126
130
 
127
131
  __df: pd.DataFrame
128
132
  _lock_name = 'edit-df'
129
- _dataset_name = 'df'
133
+ _dataset_name: str
130
134
 
131
135
  def __init__(self, df: pd.DataFrame):
136
+ self._dataset_name = 'df-' + generate_random_id()
132
137
  self.set_df(df)
133
138
 
134
139
  def __len__(self):
@@ -1053,6 +1058,14 @@ class Records:
1053
1058
 
1054
1059
  with self.df_wrapper.lock_if_not_locked:
1055
1060
 
1061
+ # check trial_id is filled
1062
+ trial_processed = False
1063
+ if processing_df['trial_id'].notna().all():
1064
+ id_to_n: dict = {tid: i + 1 for i, tid
1065
+ in enumerate(processing_df['trial_id'].unique())}
1066
+ processing_df['trial'] = processing_df['trial_id'].map(id_to_n)
1067
+ trial_processed = True
1068
+
1056
1069
  # update main fidelity
1057
1070
  equality_filters = MAIN_FILTER
1058
1071
  mgr = EntireDependentValuesCalculator(
@@ -1062,13 +1075,13 @@ class Records:
1062
1075
  )
1063
1076
  mgr.update_optimality()
1064
1077
  mgr.update_hypervolume()
1065
- mgr.update_trial_number()
1078
+ if not trial_processed:
1079
+ mgr.update_trial_number() # per_fidelity
1066
1080
  pdf = mgr.partial_df
1067
1081
  apply_partial_df(df=processing_df, partial_df=pdf, equality_filters=equality_filters)
1068
1082
 
1069
1083
  # update sub fidelity
1070
- entire_df = self.df_wrapper.get_df()
1071
- sub_fidelity_names: list = np.unique(entire_df['sub_fidelity_name']).tolist()
1084
+ sub_fidelity_names: list = np.unique(processing_df['sub_fidelity_name']).tolist()
1072
1085
  if MAIN_FIDELITY_NAME in sub_fidelity_names:
1073
1086
  sub_fidelity_names.remove(MAIN_FIDELITY_NAME)
1074
1087
  for sub_fidelity_name in sub_fidelity_names:
@@ -1078,7 +1091,8 @@ class Records:
1078
1091
  equality_filters,
1079
1092
  processing_df
1080
1093
  )
1081
- mgr.update_trial_number()
1094
+ if not trial_processed:
1095
+ mgr.update_trial_number() # per_fidelity
1082
1096
  pdf = mgr.partial_df
1083
1097
  apply_partial_df(df=processing_df, partial_df=pdf, equality_filters=equality_filters)
1084
1098
 
@@ -258,8 +258,6 @@ class ExcelInterface(COMInterface):
258
258
  force_override_when_load: bool = False,
259
259
  ):
260
260
 
261
- show_experimental_warning("ExcelInterface")
262
-
263
261
  def proc_path(path_):
264
262
  if path_ is None:
265
263
  return self._original_input_xlsm_path
@@ -102,8 +102,6 @@ class FemtetInterface(COMInterface):
102
102
  If you do not want to delete the swept table,
103
103
  make a copy of the original file.
104
104
 
105
- **kwargs: Additional arguments from inherited classes.
106
-
107
105
  Warning:
108
106
  Even if you specify ``strictly_pid_specify=True`` on the constructor,
109
107
  **the connection behavior is like** ``strictly_pid_specify=False`` **in parallel processing**
@@ -119,6 +117,7 @@ class FemtetInterface(COMInterface):
119
117
 
120
118
  com_members = {'Femtet': 'FemtetMacro.Femtet'}
121
119
  _show_parametric_index_warning = True # for GUI
120
+ _femtet_connection_timeout = 10
122
121
 
123
122
  def __init__(
124
123
  self,
@@ -316,9 +315,9 @@ class FemtetInterface(COMInterface):
316
315
  logger.info("└ Try to connect existing Femtet process.")
317
316
  # 既存の Femtet を探して Dispatch する。
318
317
  if pid is None:
319
- self.Femtet, self.femtet_pid = dispatch_femtet(timeout=5)
318
+ self.Femtet, self.femtet_pid = dispatch_femtet(timeout=self._femtet_connection_timeout)
320
319
  else:
321
- self.Femtet, self.femtet_pid = dispatch_specific_femtet(pid, timeout=5)
320
+ self.Femtet, self.femtet_pid = dispatch_specific_femtet(pid, timeout=self._femtet_connection_timeout)
322
321
  self.connected_method = "existing"
323
322
 
324
323
  def connect_femtet(self, connect_method: str = "auto", pid: int or None = None):
@@ -20,6 +20,26 @@ if TYPE_CHECKING:
20
20
 
21
21
 
22
22
  class FemtetWithSolidworksInterface(FemtetInterface, SolidworksInterface, AbstractFEMInterface):
23
+ """
24
+ Interface class integrating Femtet and SolidWorks operations.
25
+
26
+ This class combines the capabilities of both Femtet and SolidWorks interfaces, allowing
27
+ coordinated operation between simulation (Femtet) and CAD manipulation (SolidWorks).
28
+
29
+ Args:
30
+ sldprt_path (str): Path to the SolidWorks part file (.sldprt).
31
+ femprj_path (str, optional): Path to the Femtet project file (.femprj). Defaults to None.
32
+ model_name (str, optional): Name of the model in the project. Defaults to None.
33
+ connect_method (str, optional): Connection method for Femtet. Defaults to "auto".
34
+ save_pdt (str, optional): Specifies which data to save. Defaults to "all".
35
+ strictly_pid_specify (bool, optional): Whether to strictly specify parameter IDs. Defaults to True.
36
+ allow_without_project (bool, optional): If True, allows operation without a project file. Defaults to False.
37
+ open_result_with_gui (bool, optional): If True, open results with GUI. Defaults to True.
38
+ parametric_output_indexes_use_as_objective (dict[int, str | float], optional): Indexes for parametric output used as objectives. Defaults to None.
39
+ always_open_copy (bool, optional): If True, always open a copy of the project. Defaults to False.
40
+ close_solidworks_on_terminate (bool, optional): If True, SolidWorks will close when this object is destroyed. Defaults to False.
41
+ solidworks_visible (bool, optional): If True, SolidWorks will be started in visible mode. Defaults to True.
42
+ """
23
43
 
24
44
  def __init__(
25
45
  self,
@@ -41,6 +41,27 @@ class FileNotOpenedError(Exception):
41
41
 
42
42
  # noinspection PyPep8Naming
43
43
  class SolidworksInterface(COMInterface):
44
+ """
45
+ Interface class for interacting with SolidWorks through COM automation.
46
+
47
+ This class manages the connection and interaction with SolidWorks using its COM interface.
48
+ It handles initialization, visibility, and clean termination of the SolidWorks application.
49
+
50
+ Attributes:
51
+ swApp (CDispatch): The COM dispatch object for SolidWorks application.
52
+ com_members (dict): Mapping of COM member names to their interface strings.
53
+ sldprt_path (str): Absolute path to the SolidWorks part file (.sldprt).
54
+ quit_solidworks_on_terminate (bool): Whether to close SolidWorks upon object destruction.
55
+ solidworks_visible (bool): Whether the SolidWorks application window is visible.
56
+
57
+ Args:
58
+ sldprt_path (str): Path to the SolidWorks part file (.sldprt).
59
+ close_solidworks_on_terminate (bool, optional): If True, SolidWorks will close when this object is destroyed. Defaults to False.
60
+ visible (bool, optional): If True, SolidWorks will be started in visible mode. Defaults to True.
61
+
62
+ Raises:
63
+ AssertionError: If the specified part file does not exist.
64
+ """
44
65
 
45
66
  swApp: CDispatch
46
67
  com_members = {'swApp': 'SLDWORKS.Application'}
@@ -434,6 +434,7 @@ class AbstractOptimizer:
434
434
 
435
435
  def __init__(self, opt: AbstractOptimizer):
436
436
  self.opt: AbstractOptimizer = opt
437
+ self.subsampling_idx: SubSampling | None = None
437
438
 
438
439
  def _preprocess(self):
439
440
  pass
@@ -460,6 +461,7 @@ class AbstractOptimizer:
460
461
  variables_pass_to_fem: dict[str, SupportedVariableTypes],
461
462
  history: History = None,
462
463
  datetime_start=None,
464
+ trial_id=None,
463
465
  ) -> _FReturnValue:
464
466
 
465
467
  # create context
@@ -486,6 +488,8 @@ class AbstractOptimizer:
486
488
  {obj_name: ObjectiveResult(obj, opt_.fem, float('nan'))
487
489
  for obj_name, obj in opt_.objectives.items()}
488
490
  )
491
+ record.sub_sampling = self.subsampling_idx
492
+ record.trial_id = trial_id
489
493
  record.sub_fidelity_name = opt_.sub_fidelity_name
490
494
  record.fidelity = opt_.fidelity
491
495
  record.datetime_start = datetime_start
@@ -498,7 +502,8 @@ class AbstractOptimizer:
498
502
  raise SkipSolve
499
503
 
500
504
  # start solve
501
- if opt_.sub_fidelity_models != MAIN_FIDELITY_NAME:
505
+ if opt_.sub_fidelity_name != MAIN_FIDELITY_NAME:
506
+ logger.info('----------')
502
507
  logger.info(_('fidelity: ({name})', name=opt_.sub_fidelity_name))
503
508
  logger.info(_('input variables:'))
504
509
  logger.info(parameters)
@@ -629,7 +634,9 @@ class AbstractOptimizer:
629
634
  x: TrialInput,
630
635
  x_pass_to_fem_: dict[str, SupportedVariableTypes],
631
636
  opt_: AbstractOptimizer | None = None,
637
+ trial_id: str =None,
632
638
  ) -> _FReturnValue | None:
639
+ """Nothing will be raised even if infeasible."""
633
640
 
634
641
  vm = self.opt.variable_manager
635
642
 
@@ -643,32 +650,40 @@ class AbstractOptimizer:
643
650
  # if opt_ is not self, update variable manager
644
651
  opt_.variable_manager = vm
645
652
 
646
- # preprocess
647
- self._preprocess()
653
+ # noinspection PyMethodParameters
654
+ class Process:
655
+ def __enter__(self_):
656
+ # preprocess
657
+ self._preprocess()
648
658
 
649
- # declare output
650
- f_return = None
659
+ def __exit__(self_, exc_type, exc_val, exc_tb):
660
+ # postprocess
661
+ self._postprocess()
651
662
 
652
- # start solve
653
- datetime_start = datetime.datetime.now()
654
- try:
655
- f_return = self._solve_or_raise(
656
- opt_, x, x_pass_to_fem_, self.opt.history, datetime_start
657
- )
663
+ with Process():
658
664
 
659
- except HardConstraintViolation as e:
660
- self._hard_constraint_handling(e)
665
+ # declare output
666
+ f_return = None
661
667
 
662
- except _HiddenConstraintViolation as e:
663
- self._hidden_constraint_handling(e)
668
+ # start solve
669
+ datetime_start = datetime.datetime.now()
670
+ try:
671
+ f_return = self._solve_or_raise(
672
+ opt_, x, x_pass_to_fem_, self.opt.history,
673
+ datetime_start, trial_id
674
+ )
664
675
 
665
- except SkipSolve as e:
666
- self._skip_handling(e)
676
+ except HardConstraintViolation as e:
677
+ self._hard_constraint_handling(e)
667
678
 
668
- else:
669
- self._if_succeeded(f_return)
679
+ except _HiddenConstraintViolation as e:
680
+ self._hidden_constraint_handling(e)
670
681
 
671
- self._postprocess()
682
+ except SkipSolve as e:
683
+ self._skip_handling(e)
684
+
685
+ else:
686
+ self._if_succeeded(f_return)
672
687
 
673
688
  # check interruption
674
689
  self.opt._check_and_raise_interruption()
@@ -799,8 +814,19 @@ class AbstractOptimizer:
799
814
  # noinspection PyMethodParameters
800
815
  class LoggingOutput:
801
816
  def __enter__(self_):
802
- self_.count = len(self.history.get_df()) + 1
803
- logger.info(f'▼▼▼▼▼ solve {self_.count} start ▼▼▼▼▼')
817
+ df = self.history.get_df(
818
+ equality_filters=MAIN_FILTER
819
+ )
820
+ self_.count = len(df) + 1
821
+
822
+ succeeded_count = len(df[df['state'] == TrialState.succeeded])
823
+ succeeded_text = _(
824
+ en_message='{succeeded_count} succeeded trials',
825
+ jp_message='成功した試行数: {succeeded_count}',
826
+ succeeded_count=succeeded_count,
827
+ )
828
+
829
+ logger.info(f'▼▼▼▼▼ solve {self_.count} ({succeeded_text}) start ▼▼▼▼▼')
804
830
 
805
831
  def __exit__(self_, exc_type, exc_val, exc_tb):
806
832
  logger.info(f'▲▲▲▲▲ solve {self_.count} end ▲▲▲▲▲\n')
@@ -0,0 +1,63 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TypedDict, Sequence
4
+
5
+ import optuna.trial
6
+
7
+ from pyfemtet.opt.problem.problem import *
8
+ from pyfemtet.opt.history import *
9
+ from pyfemtet.opt.optimizer._base_optimizer import *
10
+
11
+
12
+ class OptunaAttribute:
13
+ """Manage optuna user attribute.
14
+
15
+ By `set_user_attr_to_trial`,
16
+ key (str):
17
+ {sub_fidelity_name}(_{subsampling_idx})
18
+ value (dict):
19
+ fidelity: ...
20
+ internal_y_values: ...
21
+ violation_values: ...
22
+ pf_state: ...
23
+
24
+ """
25
+ class AttributeStructure(TypedDict):
26
+ fidelity: Fidelity | None
27
+ internal_y_values: Sequence[float] | None
28
+ violation_values: Sequence[float] | None
29
+ pf_state: TrialState | None
30
+
31
+ def __init__(
32
+ self,
33
+ opt: AbstractOptimizer,
34
+ subsampling_idx: SubSampling | None = None,
35
+ ):
36
+ # key
37
+ self.sub_fidelity_name: str = opt.sub_fidelity_name
38
+ self.subsampling_idx: SubSampling | None = subsampling_idx
39
+ # value
40
+ self.fidelity: Fidelity = opt.fidelity
41
+ self.y_values: Sequence[float] | None = None
42
+ self.v_values: Sequence[float] | None = None
43
+ self.pf_state: TrialState | None = None
44
+
45
+ @property
46
+ def key(self) -> str:
47
+ key = self.sub_fidelity_name
48
+ if self.subsampling_idx is not None:
49
+ key += f'_{self.subsampling_idx}'
50
+ return key
51
+
52
+ @property
53
+ def value(self) -> AttributeStructure:
54
+ out = self.AttributeStructure(
55
+ fidelity=self.fidelity,
56
+ internal_y_values=self.y_values,
57
+ violation_values=self.v_values,
58
+ pf_state=self.pf_state,
59
+ )
60
+ return out
61
+
62
+ def set_user_attr_to_trial(self, trial: optuna.trial.Trial):
63
+ trial.set_user_attr(self.key, self.value)
@@ -39,6 +39,37 @@ warnings.filterwarnings('ignore', 'Argument ``constraints_func`` is an experimen
39
39
 
40
40
 
41
41
  class OptunaOptimizer(AbstractOptimizer):
42
+ """
43
+ An optimizer class utilizing Optuna for hyperparameter optimization.
44
+
45
+ This class provides an interface to conduct optimization studies using Optuna.
46
+ It manages the study lifecycle, sampler configuration, and trial execution.
47
+
48
+ Attributes:
49
+ study_name (str): Name of the Optuna study.
50
+ storage (str | optuna.storages.BaseStorage): Storage URL or object for the Optuna study.
51
+ storage_path (str): Path to the Optuna study storage.
52
+ current_trial (optuna.trial.Trial | None): The current Optuna trial being evaluated.
53
+ sampler_class (type[optuna.samplers.BaseSampler]): The class of the Optuna sampler to use.
54
+ sampler_kwargs (dict): Keyword arguments to initialize the sampler.
55
+ n_trials (int | None): Number of trials to run in the study.
56
+ timeout (float | None): Maximum time allowed for the optimization.
57
+ callbacks (list): List of callback functions to invoke during optimization.
58
+
59
+ Args:
60
+ sampler_class (type[optuna.samplers.BaseSampler], optional): The sampler class for suggesting parameter values. Defaults to TPESampler if None.
61
+ sampler_kwargs (dict[str, ...], optional): Dictionary of keyword arguments for the sampler. Defaults to an empty dictionary.
62
+
63
+ Raises:
64
+ None
65
+
66
+ Examples:
67
+ >>> optimizer = OptunaOptimizer()
68
+ >>> optimizer.n_trials = 100
69
+ >>> optimizer.timeout = 600
70
+ >>> # Further configuration and usage...
71
+ """
72
+
42
73
  # system
43
74
  study_name = 'pyfemtet-study'
44
75
  storage: str | optuna.storages.BaseStorage
@@ -122,7 +153,7 @@ class OptunaOptimizer(AbstractOptimizer):
122
153
 
123
154
  y, dict_y_internal, c, record = f_return
124
155
 
125
- # convert constraint to **sorted** violation
156
+ # convert constraint to **sorted 1-d array** violation
126
157
  assert len(c) == len(self.opt_.constraints)
127
158
  v = {}
128
159
  for cns_name, cns in self.opt_.constraints.items():
@@ -139,10 +170,7 @@ class OptunaOptimizer(AbstractOptimizer):
139
170
 
140
171
  def _postprocess(self):
141
172
  # update trial attribute
142
- self.opt.current_trial.set_user_attr(
143
- self.optuna_attr.key,
144
- self.optuna_attr.value,
145
- )
173
+ self.optuna_attr.set_user_attr_to_trial(self.opt.current_trial)
146
174
 
147
175
  def _create_infeasible_constraints(self, opt_: AbstractOptimizer = None) -> tuple:
148
176
  opt_ = opt_ if opt_ is not None else self
@@ -155,9 +183,9 @@ class OptunaOptimizer(AbstractOptimizer):
155
183
  return tuple(1e9 * np.ones(count, dtype=np.float64))
156
184
 
157
185
  def _constraint(self, trial: optuna.trial.FrozenTrial):
158
- key = OptunaAttribute(self).key
159
- value = trial.user_attrs[key]
160
- return OptunaAttribute.get_violation_from_trial_attr(value)
186
+ main_key = OptunaAttribute(self).key
187
+ user_attribute: OptunaAttribute.AttributeStructure = trial.user_attrs[main_key]
188
+ return user_attribute['violation_values']
161
189
 
162
190
  def _objective(self, trial: optuna.trial.Trial):
163
191
 
@@ -226,9 +254,9 @@ class OptunaOptimizer(AbstractOptimizer):
226
254
 
227
255
  # To avoid trial FAILED with hard constraint
228
256
  # violation, check pf_state and raise TrialPruned.
229
- key = OptunaAttribute(self).key
230
- value = trial.user_attrs[key]
231
- state = OptunaAttribute.get_pf_state_from_trial_attr(value)
257
+ main_key = OptunaAttribute(self).key
258
+ user_attribute: OptunaAttribute.AttributeStructure = trial.user_attrs[main_key]
259
+ state: TrialState = user_attribute['pf_state']
232
260
  if state in [
233
261
  TrialState.hard_constraint_violation,
234
262
  TrialState.model_error,
@@ -245,9 +273,6 @@ class OptunaOptimizer(AbstractOptimizer):
245
273
 
246
274
  return y_internal
247
275
 
248
- if get_client() is None:
249
- self.history.save()
250
-
251
276
  def _get_callback(self, n_trials: int):
252
277
 
253
278
  # restart である場合、追加 N 回と見做す
@@ -587,16 +612,16 @@ def debug_1():
587
612
  _opt.add_parameter('x1', 1, -1, 1, step=0.1)
588
613
  _opt.add_parameter('x2', 1, -1, 1, step=0.1)
589
614
  _opt.add_categorical_parameter('x3', 'a', choices=['a', 'b', 'c'])
590
- _opt.add_constraint('cns', _cns, lower_bound=-0.9, args=(_fem, _opt))
591
- _opt.add_objective('obj1', _parabola, args=(_fem, _opt))
592
- # _opt.add_objective('obj2', _parabola2, args=(_fem, _opt))
615
+ # _opt.add_constraint('cns', _cns, lower_bound=-0.9, args=(_opt,))
616
+ _opt.add_objective('obj1', _parabola, args=(_opt,))
617
+ # _opt.add_objective('obj2', _parabola2, args=(_opt,))
593
618
 
594
619
  # # ===== sub-fidelity =====
595
620
  # __fem = NoFEM()
596
621
  # __opt = SubFidelityModel()
597
622
  # __opt.fem = __fem
598
- # __opt.add_objective('obj1', _parabola, args=(__fem, __opt))
599
- # __opt.add_objective('obj2', _parabola2, args=(__fem, __opt))
623
+ # __opt.add_objective('obj1', _parabola, args=(__opt,))
624
+ # # __opt.add_objective('obj2', _parabola2, args=(__opt,))
600
625
  #
601
626
  # _opt.add_sub_fidelity_model(name='low-fidelity', sub_fidelity_model=__opt, fidelity=0.5)
602
627
  #
@@ -622,6 +647,96 @@ def debug_1():
622
647
  _opt.history.save()
623
648
 
624
649
 
650
+ def debug_1s():
651
+ # from pyfemtet.opt.optimizer.optuna_optimizer.pof_botorch.pof_botorch_sampler import
652
+ # sampler = PoFBoTorchSampler(
653
+ # n_startup_trials=5,
654
+ # seed=42,
655
+ # constraints_func=self._constraint,
656
+ # pof_config=PoFConfig(
657
+ # # consider_pof=False,
658
+ # # feasibility_cdf_threshold='mean',
659
+ # ),
660
+ # partial_optimize_acqf_kwargs=PartialOptimizeACQFConfig(
661
+ # # gen_candidates='scipy',
662
+ # timeout_sec=5.,
663
+ # # method='SLSQP' # 'COBYLA, COBYQA, SLSQP or trust-constr
664
+ # tol=0.1,
665
+ # # scipy_minimize_kwargs=dict(),
666
+ # ),
667
+ # )
668
+ # from optuna_integration import BoTorchSampler
669
+ # sampler = BoTorchSampler(n_startup_trials=5)
670
+
671
+ os.chdir(os.path.dirname(__file__))
672
+
673
+ def _parabola(_fem: AbstractFEMInterface, _opt: AbstractOptimizer) -> float:
674
+ d = _opt.get_variables()
675
+ x1 = d['x1']
676
+ x2 = d['x2']
677
+ # if _cns(_fem, _opt) < 0:
678
+ # raise PostProcessError
679
+ return x1 ** 2 + x2 ** 2
680
+
681
+ def _parabola2(_fem: AbstractFEMInterface, _opt: AbstractOptimizer) -> float:
682
+ x = _opt.get_variables('values')
683
+ return ((x - 0.1) ** 2).sum()
684
+
685
+ def _cns(_fem: AbstractFEMInterface, _opt: AbstractOptimizer) -> float:
686
+ x = _opt.get_variables('values')
687
+ return x[0]
688
+
689
+ _fem = NoFEM()
690
+ _opt = OptunaOptimizer()
691
+ _opt.fem = _fem
692
+
693
+ # _opt.sampler = optuna.samplers.RandomSampler(seed=42)
694
+ _opt.seed = 42
695
+ _opt.sampler_class = optuna.samplers.TPESampler
696
+ # _opt.sampler_class = optuna.samplers.RandomSampler
697
+ _opt.sampler_kwargs = dict(
698
+ n_startup_trials=5,
699
+ )
700
+ _opt.n_trials = 10
701
+
702
+ _opt.add_parameter('x1', 1, -1, 1, step=0.1)
703
+ _opt.add_parameter('x2', 1, -1, 1, step=0.1)
704
+ _opt.add_categorical_parameter('x3', 'a', choices=['a', 'b', 'c'])
705
+ # _opt.add_constraint('cns', _cns, lower_bound=-0.9, args=(_opt,))
706
+ _opt.add_objective('obj1', _parabola, args=(_opt,))
707
+ # _opt.add_objective('obj2', _parabola2, args=(_opt,))
708
+
709
+ # ===== sub-fidelity =====
710
+ __fem = NoFEM()
711
+ __opt = SubFidelityModel()
712
+ __opt.fem = __fem
713
+ __opt.add_objective('obj1', _parabola, args=(__opt,))
714
+ # __opt.add_objective('obj2', _parabola2, args=(__opt,))
715
+
716
+ _opt.add_sub_fidelity_model(name='low-fidelity', sub_fidelity_model=__opt, fidelity=0.5)
717
+
718
+ def _solve_condition(_history: History):
719
+
720
+ sub_fidelity_df = _history.get_df(
721
+ {'sub_fidelity_name': 'low-fidelity'}
722
+ )
723
+ idx = sub_fidelity_df['state'] == TrialState.succeeded
724
+ pdf = sub_fidelity_df[idx]
725
+
726
+ return len(pdf) % 5 == 0
727
+
728
+ _opt.set_solve_condition(_solve_condition)
729
+
730
+ # _opt.history.path = 'restart-test.csv'
731
+ _opt.run()
732
+
733
+ # import plotly.express as px
734
+ # _df = _opt.history.get_df()
735
+ # px.scatter_3d(_df, x='x1', y='x2', z='obj', color='fidelity', opacity=0.5).show()
736
+
737
+ _opt.history.save()
738
+
739
+
625
740
  def substrate_size(Femtet):
626
741
  """基板のXY平面上での専有面積を計算します。"""
627
742
  substrate_w = Femtet.GetVariableValue('substrate_w')
@@ -669,10 +784,13 @@ def debug_3():
669
784
  opt.add_parameter(name="substrate_d", initial_value=60, lower_bound=34, upper_bound=60)
670
785
 
671
786
  opt.n_trials = 5
672
- opt.history.path = os.path.join(os.path.dirname(__file__), 'femtet-test.csv')
787
+ opt.history.path = os.path.join(os.path.dirname(__file__), 'femtet-test-2.csv')
673
788
 
674
789
  opt.run()
675
790
 
676
791
 
677
792
  if __name__ == '__main__':
793
+ debug_1()
794
+ debug_1s()
795
+ debug_2()
678
796
  debug_3()