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.
- pyfemtet/__init__.py +6 -1
- pyfemtet/_i18n/1. make_pot_and_update_po.bat +8 -0
- pyfemtet/_i18n/2. build_mo.bat +5 -0
- pyfemtet/_i18n/__init__.py +4 -0
- pyfemtet/_i18n/babel.cfg +2 -0
- pyfemtet/_i18n/i18n.py +37 -0
- pyfemtet/_i18n/locales/ja/LC_MESSAGES/messages.mo +0 -0
- pyfemtet/_i18n/locales/ja/LC_MESSAGES/messages.po +1020 -0
- pyfemtet/_i18n/locales/messages.pot +987 -0
- pyfemtet/{_message → _i18n}/messages.py +128 -41
- pyfemtet/_util/closing.py +19 -0
- pyfemtet/_util/dask_util.py +89 -7
- pyfemtet/_util/df_util.py +29 -0
- pyfemtet/_util/excel_macro_util.py +8 -3
- pyfemtet/_util/excel_parse_util.py +43 -23
- pyfemtet/_util/femtet_access_inspection.py +120 -0
- pyfemtet/{_femtet_config_util/autosave.py → _util/femtet_autosave.py} +7 -0
- pyfemtet/_util/femtet_exit.py +105 -0
- pyfemtet/_util/femtet_version.py +20 -0
- pyfemtet/_util/helper.py +94 -0
- pyfemtet/_util/process_util.py +107 -0
- pyfemtet/_util/str_enum.py +44 -0
- pyfemtet/core.py +15 -47
- pyfemtet/dispatch_extensions/__init__.py +8 -11
- pyfemtet/dispatch_extensions/_impl.py +42 -198
- pyfemtet/logger/__init__.py +8 -1
- pyfemtet/logger/_impl.py +5 -6
- pyfemtet/opt/__init__.py +3 -17
- pyfemtet/opt/exceptions.py +45 -0
- pyfemtet/opt/femopt.py +608 -0
- pyfemtet/opt/history/__init__.py +11 -0
- pyfemtet/opt/history/_history.py +1404 -0
- pyfemtet/opt/history/_hypervolume.py +169 -0
- pyfemtet/opt/history/_optimality.py +79 -0
- pyfemtet/opt/interface/__init__.py +17 -24
- pyfemtet/opt/interface/_base_interface.py +222 -0
- pyfemtet/opt/interface/_excel_interface/__init__.py +3 -0
- pyfemtet/opt/interface/_excel_interface/debug-excel-interface.xlsm +0 -0
- pyfemtet/opt/interface/_excel_interface/excel_interface.py +999 -0
- pyfemtet/opt/interface/_femtet_interface/__init__.py +3 -0
- pyfemtet/opt/interface/{_femtet_parametric.py → _femtet_interface/_femtet_parametric.py} +20 -12
- pyfemtet/opt/interface/{_femtet.py → _femtet_interface/femtet_interface.py} +505 -349
- pyfemtet/opt/interface/_femtet_with_nx_interface/__init__.py +5 -0
- pyfemtet/opt/interface/_femtet_with_nx_interface/femtet_with_nx_interface.py +230 -0
- pyfemtet/opt/interface/_femtet_with_nx_interface/model1.prt +0 -0
- pyfemtet/opt/interface/_femtet_with_nx_interface/model1.x_t +98 -0
- pyfemtet/opt/interface/{_femtet_with_nx → _femtet_with_nx_interface}/update_model.py +1 -3
- pyfemtet/opt/interface/_femtet_with_solidworks/__init__.py +5 -0
- pyfemtet/opt/interface/_femtet_with_solidworks/femtet_with_solidworks_interface.py +122 -0
- pyfemtet/opt/interface/_solidworks_interface/__init__.py +5 -0
- pyfemtet/opt/interface/_solidworks_interface/solidworks_interface.py +206 -0
- pyfemtet/opt/interface/_surrogate_model_interface/__init__.py +8 -0
- pyfemtet/opt/interface/_surrogate_model_interface/base_surrogate_interface.py +150 -0
- pyfemtet/opt/interface/_surrogate_model_interface/botorch_interface.py +298 -0
- pyfemtet/opt/interface/_surrogate_model_interface/debug-pof-botorch.reccsv +18 -0
- pyfemtet/opt/interface/_with_excel_settings/__init__.py +61 -0
- pyfemtet/opt/interface/_with_excel_settings/with_excel_settings.py +134 -0
- pyfemtet/opt/meta_script/YAML_Generator.xlsm +0 -0
- pyfemtet/opt/meta_script/__main__.py +58 -36
- pyfemtet/opt/optimizer/__init__.py +7 -9
- pyfemtet/opt/optimizer/_base_optimizer.py +885 -0
- pyfemtet/opt/optimizer/optuna_optimizer/__init__.py +9 -0
- pyfemtet/opt/optimizer/optuna_optimizer/_optuna_attribute.py +73 -0
- pyfemtet/opt/optimizer/optuna_optimizer/_optuna_optimizer.py +678 -0
- pyfemtet/opt/optimizer/optuna_optimizer/_pof_botorch/__init__.py +7 -0
- pyfemtet/opt/optimizer/optuna_optimizer/_pof_botorch/debug-pof-botorch.reccsv +18 -0
- pyfemtet/opt/optimizer/optuna_optimizer/_pof_botorch/enable_nonlinear_constraint.py +244 -0
- pyfemtet/opt/optimizer/optuna_optimizer/_pof_botorch/pof_botorch_sampler.py +1249 -0
- pyfemtet/opt/optimizer/optuna_optimizer/wat_ex14_parametric_jp.femprj +0 -0
- pyfemtet/opt/optimizer/scipy_optimizer/__init__.py +1 -0
- pyfemtet/opt/optimizer/scipy_optimizer/_scipy_optimizer.py +364 -0
- pyfemtet/opt/prediction/__init__.py +7 -0
- pyfemtet/opt/prediction/_botorch_utils.py +133 -0
- pyfemtet/opt/prediction/_gpytorch_modules_extension.py +142 -0
- pyfemtet/opt/prediction/_helper.py +155 -0
- pyfemtet/opt/prediction/_model.py +118 -0
- pyfemtet/opt/problem/problem.py +304 -0
- pyfemtet/opt/problem/variable_manager/__init__.py +20 -0
- pyfemtet/opt/problem/variable_manager/_string_as_expression.py +115 -0
- pyfemtet/opt/problem/variable_manager/_variable_manager.py +295 -0
- pyfemtet/opt/visualization/history_viewer/__main__.py +5 -0
- pyfemtet/opt/visualization/{_base.py → history_viewer/_base_application.py} +18 -13
- pyfemtet/opt/visualization/history_viewer/_common_pages.py +150 -0
- pyfemtet/opt/visualization/{_complex_components → history_viewer/_complex_components}/alert_region.py +10 -5
- pyfemtet/opt/visualization/{_complex_components → history_viewer/_complex_components}/control_femtet.py +16 -13
- pyfemtet/opt/visualization/{_complex_components → history_viewer/_complex_components}/main_graph.py +117 -47
- pyfemtet/opt/visualization/{_complex_components → history_viewer/_complex_components}/pm_graph.py +159 -138
- pyfemtet/opt/visualization/history_viewer/_process_monitor/_application.py +173 -0
- pyfemtet/opt/visualization/history_viewer/_process_monitor/_pages.py +291 -0
- pyfemtet/opt/visualization/{_wrapped_components → history_viewer/_wrapped_components}/dbc.py +1 -1
- pyfemtet/opt/visualization/{_wrapped_components → history_viewer/_wrapped_components}/dcc.py +1 -1
- pyfemtet/opt/visualization/{_wrapped_components → history_viewer/_wrapped_components}/html.py +1 -1
- pyfemtet/opt/visualization/history_viewer/result_viewer/__main__.py +5 -0
- pyfemtet/opt/visualization/{result_viewer/application.py → history_viewer/result_viewer/_application.py} +6 -6
- pyfemtet/opt/visualization/{result_viewer/pages.py → history_viewer/result_viewer/_pages.py} +106 -82
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08.csv +18 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08.db +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8.jpg +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8.log +45 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8.pdt +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_1.jpg +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_1.pdt +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_10.jpg +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_10.pdt +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_11.jpg +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_11.pdt +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_12.jpg +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_12.pdt +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_13.jpg +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_13.pdt +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_14.jpg +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_14.pdt +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_15.jpg +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_15.pdt +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_16.jpg +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_16.pdt +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_17.jpg +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_17.pdt +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_18.jpg +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_18.pdt +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_19.jpg +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_19.pdt +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_2.jpg +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_2.pdt +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_20.jpg +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_20.pdt +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_3.jpg +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_3.pdt +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.bgr +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.bnd +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.btr +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.jpg +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.mtl +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.pdt +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_4.prm +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_5.jpg +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_5.pdt +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_6.jpg +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_6.pdt +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_7.jpg +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_7.pdt +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_8.jpg +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_8.pdt +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_9.jpg +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.Results/ex8_trial_9.pdt +0 -0
- pyfemtet/opt/visualization/history_viewer/result_viewer/tutorial_files/tutorial_gau_ex08_parametric.femprj +0 -0
- pyfemtet/opt/visualization/plotter/main_figure_creator.py +536 -0
- pyfemtet/opt/visualization/plotter/pm_graph_creator.py +359 -0
- pyfemtet/opt/worker_status.py +120 -0
- {pyfemtet-0.9.5.dist-info → pyfemtet-1.0.0b0.dist-info}/METADATA +23 -24
- pyfemtet-1.0.0b0.dist-info/RECORD +172 -0
- pyfemtet-1.0.0b0.dist-info/entry_points.txt +3 -0
- pyfemtet/_femtet_config_util/exit.py +0 -59
- pyfemtet/_message/1. make_pot.bat +0 -11
- pyfemtet/_message/2. make_mo.bat +0 -6
- pyfemtet/_message/__init__.py +0 -5
- pyfemtet/_message/babel.cfg +0 -2
- pyfemtet/_message/locales/ja/LC_MESSAGES/messages.mo +0 -0
- pyfemtet/_message/locales/ja/LC_MESSAGES/messages.po +0 -570
- pyfemtet/_message/locales/messages.pot +0 -551
- pyfemtet/_warning.py +0 -87
- pyfemtet/brep/_impl.py +0 -18
- pyfemtet/opt/_femopt.py +0 -1007
- pyfemtet/opt/_femopt_core.py +0 -1169
- pyfemtet/opt/_test_utils/control_femtet.py +0 -39
- pyfemtet/opt/_test_utils/hyper_sphere.py +0 -24
- pyfemtet/opt/_test_utils/record_history.py +0 -130
- pyfemtet/opt/advanced_samples/excel_ui/(ref) original_project.femprj +0 -0
- pyfemtet/opt/advanced_samples/excel_ui/femtet-macro.xlsm +0 -0
- pyfemtet/opt/advanced_samples/excel_ui/pyfemtet-core.py +0 -291
- pyfemtet/opt/advanced_samples/excel_ui/test-pyfemtet-core.cmd +0 -22
- pyfemtet/opt/advanced_samples/restart/gal_ex13_parametric.femprj +0 -0
- pyfemtet/opt/advanced_samples/restart/gal_ex13_parametric_restart.py +0 -99
- pyfemtet/opt/advanced_samples/restart/gal_ex13_parametric_restart_jp.py +0 -102
- pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_create_training_data.py +0 -60
- pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_create_training_data_jp.py +0 -57
- pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_optimize_with_surrogate.py +0 -100
- pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_optimize_with_surrogate_jp.py +0 -90
- pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_parametric.femprj +0 -0
- pyfemtet/opt/interface/_base.py +0 -101
- pyfemtet/opt/interface/_excel_interface.py +0 -984
- pyfemtet/opt/interface/_femtet_excel.py +0 -141
- pyfemtet/opt/interface/_femtet_with_nx/__init__.py +0 -3
- pyfemtet/opt/interface/_femtet_with_nx/_interface.py +0 -178
- pyfemtet/opt/interface/_femtet_with_sldworks.py +0 -298
- pyfemtet/opt/interface/_surrogate/__init__.py +0 -5
- pyfemtet/opt/interface/_surrogate/_base.py +0 -129
- pyfemtet/opt/interface/_surrogate/_chaospy.py +0 -71
- pyfemtet/opt/interface/_surrogate/_singletaskgp.py +0 -71
- pyfemtet/opt/interface/_surrogate_excel.py +0 -102
- pyfemtet/opt/optimizer/_base.py +0 -376
- pyfemtet/opt/optimizer/_optuna/_botorch_patch/enable_nonlinear_constraint.py +0 -220
- pyfemtet/opt/optimizer/_optuna/_optuna.py +0 -434
- pyfemtet/opt/optimizer/_optuna/_pof_botorch.py +0 -1914
- pyfemtet/opt/optimizer/_scipy.py +0 -159
- pyfemtet/opt/optimizer/_scipy_scalar.py +0 -127
- pyfemtet/opt/optimizer/parameter.py +0 -113
- pyfemtet/opt/prediction/_base.py +0 -61
- pyfemtet/opt/prediction/single_task_gp.py +0 -119
- pyfemtet/opt/samples/femprj_sample/ParametricIF.femprj +0 -0
- pyfemtet/opt/samples/femprj_sample/ParametricIF.py +0 -29
- pyfemtet/opt/samples/femprj_sample/ParametricIF_test_result.reccsv +0 -13
- pyfemtet/opt/samples/femprj_sample/cad_ex01_NX.femprj +0 -0
- pyfemtet/opt/samples/femprj_sample/cad_ex01_NX.prt +0 -0
- pyfemtet/opt/samples/femprj_sample/cad_ex01_NX.py +0 -135
- pyfemtet/opt/samples/femprj_sample/cad_ex01_NX_test_result.reccsv +0 -23
- pyfemtet/opt/samples/femprj_sample/cad_ex01_SW.SLDPRT +0 -0
- pyfemtet/opt/samples/femprj_sample/cad_ex01_SW.femprj +0 -0
- pyfemtet/opt/samples/femprj_sample/cad_ex01_SW.py +0 -131
- pyfemtet/opt/samples/femprj_sample/cad_ex01_SW_test_result.reccsv +0 -23
- pyfemtet/opt/samples/femprj_sample/constrained_pipe.femprj +0 -0
- pyfemtet/opt/samples/femprj_sample/constrained_pipe.py +0 -96
- pyfemtet/opt/samples/femprj_sample/constrained_pipe_test_result.reccsv +0 -13
- pyfemtet/opt/samples/femprj_sample/gal_ex58_parametric.femprj +0 -0
- pyfemtet/opt/samples/femprj_sample/gal_ex58_parametric.py +0 -74
- pyfemtet/opt/samples/femprj_sample/gal_ex58_parametric_test_result.reccsv +0 -13
- pyfemtet/opt/samples/femprj_sample/gau_ex08_parametric.femprj +0 -0
- pyfemtet/opt/samples/femprj_sample/gau_ex08_parametric.py +0 -58
- pyfemtet/opt/samples/femprj_sample/gau_ex08_parametric_test_result.reccsv +0 -23
- pyfemtet/opt/samples/femprj_sample/gau_ex12_parametric.femprj +0 -0
- pyfemtet/opt/samples/femprj_sample/gau_ex12_parametric.py +0 -52
- pyfemtet/opt/samples/femprj_sample/her_ex40_parametric.femprj +0 -0
- pyfemtet/opt/samples/femprj_sample/her_ex40_parametric.py +0 -138
- pyfemtet/opt/samples/femprj_sample/her_ex40_parametric_test_result.reccsv +0 -18
- pyfemtet/opt/samples/femprj_sample/paswat_ex1_parametric.femprj +0 -0
- pyfemtet/opt/samples/femprj_sample/paswat_ex1_parametric.py +0 -60
- pyfemtet/opt/samples/femprj_sample/paswat_ex1_parametric_parallel.py +0 -61
- pyfemtet/opt/samples/femprj_sample/paswat_ex1_parametric_test_result.reccsv +0 -18
- pyfemtet/opt/samples/femprj_sample/wat_ex14_parametric.femprj +0 -0
- pyfemtet/opt/samples/femprj_sample/wat_ex14_parametric.py +0 -58
- pyfemtet/opt/samples/femprj_sample/wat_ex14_parametric_parallel.py +0 -58
- pyfemtet/opt/samples/femprj_sample/wat_ex14_parametric_test_result.reccsv +0 -18
- pyfemtet/opt/samples/femprj_sample_jp/ParametricIF_jp.femprj +0 -0
- pyfemtet/opt/samples/femprj_sample_jp/ParametricIF_jp.py +0 -29
- pyfemtet/opt/samples/femprj_sample_jp/cad_ex01_NX_jp.femprj +0 -0
- pyfemtet/opt/samples/femprj_sample_jp/cad_ex01_NX_jp.py +0 -129
- pyfemtet/opt/samples/femprj_sample_jp/cad_ex01_SW_jp.femprj +0 -0
- pyfemtet/opt/samples/femprj_sample_jp/cad_ex01_SW_jp.py +0 -125
- pyfemtet/opt/samples/femprj_sample_jp/constrained_pipe_jp.py +0 -93
- pyfemtet/opt/samples/femprj_sample_jp/gal_ex58_parametric_jp.femprj +0 -0
- pyfemtet/opt/samples/femprj_sample_jp/gal_ex58_parametric_jp.py +0 -70
- pyfemtet/opt/samples/femprj_sample_jp/gau_ex08_parametric_jp.femprj +0 -0
- pyfemtet/opt/samples/femprj_sample_jp/gau_ex08_parametric_jp.py +0 -57
- pyfemtet/opt/samples/femprj_sample_jp/gau_ex12_parametric_jp.py +0 -52
- pyfemtet/opt/samples/femprj_sample_jp/her_ex40_parametric_jp.femprj +0 -0
- pyfemtet/opt/samples/femprj_sample_jp/her_ex40_parametric_jp.py +0 -138
- pyfemtet/opt/samples/femprj_sample_jp/paswat_ex1_parametric_jp.femprj +0 -0
- pyfemtet/opt/samples/femprj_sample_jp/paswat_ex1_parametric_jp.py +0 -58
- pyfemtet/opt/samples/femprj_sample_jp/paswat_ex1_parametric_parallel_jp.py +0 -59
- pyfemtet/opt/samples/femprj_sample_jp/wat_ex14_parametric_jp.py +0 -56
- pyfemtet/opt/samples/femprj_sample_jp/wat_ex14_parametric_parallel_jp.py +0 -56
- pyfemtet/opt/visualization/_complex_components/main_figure_creator.py +0 -332
- pyfemtet/opt/visualization/_complex_components/pm_graph_creator.py +0 -201
- pyfemtet/opt/visualization/_process_monitor/application.py +0 -226
- pyfemtet/opt/visualization/_process_monitor/pages.py +0 -406
- pyfemtet/opt/visualization/_wrapped_components/__init__.py +0 -0
- pyfemtet/opt/visualization/result_viewer/__init__.py +0 -0
- pyfemtet-0.9.5.dist-info/RECORD +0 -158
- pyfemtet-0.9.5.dist-info/entry_points.txt +0 -3
- /pyfemtet/{_femtet_config_util → opt/problem}/__init__.py +0 -0
- /pyfemtet/{brep → opt/visualization/history_viewer}/__init__.py +0 -0
- /pyfemtet/opt/{_test_utils → visualization/history_viewer/_complex_components}/__init__.py +0 -0
- /pyfemtet/opt/{optimizer/_optuna → visualization/history_viewer/_process_monitor}/__init__.py +0 -0
- /pyfemtet/opt/{optimizer/_optuna/_botorch_patch → visualization/history_viewer/_wrapped_components}/__init__.py +0 -0
- /pyfemtet/opt/visualization/{_wrapped_components → history_viewer/_wrapped_components}/str_enum.py +0 -0
- /pyfemtet/opt/visualization/{result_viewer → history_viewer/result_viewer}/.gitignore +0 -0
- /pyfemtet/opt/visualization/{_complex_components → history_viewer/result_viewer}/__init__.py +0 -0
- /pyfemtet/opt/visualization/{_process_monitor → plotter}/__init__.py +0 -0
- /pyfemtet/opt/{samples/femprj_sample_jp/wat_ex14_parametric_jp.femprj → wat_ex14_parametric_jp.femprj} +0 -0
- {pyfemtet-0.9.5.dist-info → pyfemtet-1.0.0b0.dist-info}/LICENSE +0 -0
- {pyfemtet-0.9.5.dist-info → pyfemtet-1.0.0b0.dist-info}/LICENSE_THIRD_PARTY.txt +0 -0
- {pyfemtet-0.9.5.dist-info → pyfemtet-1.0.0b0.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
|
|
3
|
+
import torch
|
|
4
|
+
from torch import Tensor
|
|
5
|
+
|
|
6
|
+
from optuna._transform import _SearchSpaceTransform
|
|
7
|
+
|
|
8
|
+
from botorch.optim.initializers import gen_batch_initial_conditions
|
|
9
|
+
|
|
10
|
+
from pyfemtet._i18n import _
|
|
11
|
+
from pyfemtet.logger import get_module_logger
|
|
12
|
+
from pyfemtet.opt.problem.problem import *
|
|
13
|
+
from pyfemtet.opt.optimizer import AbstractOptimizer
|
|
14
|
+
|
|
15
|
+
logger = get_module_logger('opt.optimizer')
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
__all__ = ['NonlinearInequalityConstraints']
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# 拘束関数に pytorch の自動微分機能を適用するためのクラス
|
|
22
|
+
class _GeneralFunctionWithForwardDifference(torch.autograd.Function):
|
|
23
|
+
"""自作関数を pytorch で自動微分するためのクラスです。
|
|
24
|
+
|
|
25
|
+
ユーザー定義関数を botorch 形式に変換する過程で微分の計算ができなくなるのでこれが必要です。
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
@staticmethod
|
|
29
|
+
def forward(ctx, f, xs):
|
|
30
|
+
ys = f(xs)
|
|
31
|
+
ctx.save_for_backward(xs, ys)
|
|
32
|
+
ctx.f = f
|
|
33
|
+
return ys
|
|
34
|
+
|
|
35
|
+
# noinspection PyMethodOverriding
|
|
36
|
+
@staticmethod
|
|
37
|
+
def backward(ctx, grad_output):
|
|
38
|
+
xs, ys = ctx.saved_tensors
|
|
39
|
+
f = ctx.f
|
|
40
|
+
dx = 0.001 # 入力は normalized なので決め打ちでよい
|
|
41
|
+
diff = []
|
|
42
|
+
xs_ = xs.detach() # xs に余計な計算履歴を残さないために、detachする。
|
|
43
|
+
for i in range(len(xs_)):
|
|
44
|
+
xs_[i] += dx
|
|
45
|
+
diff.append(torch.sum(grad_output * (f(xs) - ys)))
|
|
46
|
+
xs_[i] -= dx
|
|
47
|
+
diff = torch.tensor(diff).to(xs) / dx
|
|
48
|
+
return None, diff
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
# 入力 x を受けて pyfemtet.opt.Constraint を評価する関数
|
|
52
|
+
def _evaluate_pyfemtet_cns(
|
|
53
|
+
cns: Constraint,
|
|
54
|
+
opt: AbstractOptimizer,
|
|
55
|
+
trans: _SearchSpaceTransform,
|
|
56
|
+
x: np.ndarray,
|
|
57
|
+
) -> float:
|
|
58
|
+
|
|
59
|
+
# un-transform continuous to original
|
|
60
|
+
new_params: dict[str, ...] = trans.untransform(x)
|
|
61
|
+
params: TrialInput = opt.variable_manager.get_variables()
|
|
62
|
+
|
|
63
|
+
# update
|
|
64
|
+
for prm_name, prm in params.items():
|
|
65
|
+
if prm_name in new_params:
|
|
66
|
+
prm.value = new_params[prm_name]
|
|
67
|
+
opt.variable_manager.eval_expressions()
|
|
68
|
+
|
|
69
|
+
# update fem (very slow!)
|
|
70
|
+
if cns.using_fem:
|
|
71
|
+
logger.warning(_(
|
|
72
|
+
en_message='Accessing FEM API inside hard constraint '
|
|
73
|
+
'function may be very slow.',
|
|
74
|
+
jp_message='hard constraint 関数の評価中の FEM への'
|
|
75
|
+
'アクセスは著しく時間がかかりますので'
|
|
76
|
+
'ご注意ください。'
|
|
77
|
+
))
|
|
78
|
+
pass_to_fem = opt.variable_manager.get_variables(filter='pass_to_fem')
|
|
79
|
+
opt.fem.update_parameter(pass_to_fem)
|
|
80
|
+
|
|
81
|
+
# eval
|
|
82
|
+
return cns.eval(opt.fem)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
# ユーザー定義関数 (pyfemtet.opt.Constraint) を受け取り、
|
|
86
|
+
# botorch で処理できる callable オブジェクトを作成するクラス
|
|
87
|
+
class _ConvertedConstraint:
|
|
88
|
+
|
|
89
|
+
def __init__(
|
|
90
|
+
self,
|
|
91
|
+
cns: Constraint,
|
|
92
|
+
opt: AbstractOptimizer,
|
|
93
|
+
trans: _SearchSpaceTransform,
|
|
94
|
+
ub_or_lb: str,
|
|
95
|
+
constraint_enhancement: float = None,
|
|
96
|
+
):
|
|
97
|
+
self.cns: Constraint = cns
|
|
98
|
+
self.ub_or_lb = ub_or_lb
|
|
99
|
+
self.opt = opt
|
|
100
|
+
self.trans = trans
|
|
101
|
+
self.ce = constraint_enhancement or 0.
|
|
102
|
+
|
|
103
|
+
def __call__(self, X: Tensor) -> Tensor: # BotorchConstraint
|
|
104
|
+
"""optimize_acqf() に渡される非線形拘束関数の処理です。
|
|
105
|
+
|
|
106
|
+
Args:
|
|
107
|
+
X (Tensor): Normalized parameters. Its length is d (== len(prm)).
|
|
108
|
+
|
|
109
|
+
Returns:
|
|
110
|
+
float Tensor. >= 0 is feasible.
|
|
111
|
+
|
|
112
|
+
"""
|
|
113
|
+
|
|
114
|
+
x = X.detach().numpy()
|
|
115
|
+
cns_value = _evaluate_pyfemtet_cns(
|
|
116
|
+
self.cns,
|
|
117
|
+
self.opt,
|
|
118
|
+
self.trans,
|
|
119
|
+
x,
|
|
120
|
+
)
|
|
121
|
+
if self.ub_or_lb == 'lb':
|
|
122
|
+
return Tensor([cns_value - self.cns.lower_bound - self.ce])
|
|
123
|
+
elif self.ub_or_lb == 'ub':
|
|
124
|
+
return Tensor([self.cns.upper_bound - cns_value - self.ce])
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
# list[pyfemtet.opt.Constraint] について、正規化された入力に対し、 feasible or not を返す関数
|
|
128
|
+
def _is_feasible(
|
|
129
|
+
constraints: list[Constraint],
|
|
130
|
+
opt: AbstractOptimizer,
|
|
131
|
+
trans: _SearchSpaceTransform,
|
|
132
|
+
x: np.ndarray,
|
|
133
|
+
constraint_enhancement: float = None,
|
|
134
|
+
constraint_scaling: float = None,
|
|
135
|
+
) -> bool:
|
|
136
|
+
for cns in constraints:
|
|
137
|
+
cns_value = _evaluate_pyfemtet_cns(cns, opt, trans, x)
|
|
138
|
+
cns_result = ConstraintResult(cns, opt.fem, cns_value, constraint_enhancement, constraint_scaling)
|
|
139
|
+
if cns_result.check_violation() is not None:
|
|
140
|
+
return False
|
|
141
|
+
return True
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
# botorch の optimize_acqf で非線形拘束を使えるようにするクラス。以下を備える。
|
|
145
|
+
# - 渡すパラメータ nonlinear_constraints を作成する
|
|
146
|
+
# - gen_initial_conditions で feasible なものを返すラッパー関数
|
|
147
|
+
class NonlinearInequalityConstraints:
|
|
148
|
+
"""botorch の optimize_acqf に parameter constraints を設定するための引数を作成します。"""
|
|
149
|
+
|
|
150
|
+
def __init__(
|
|
151
|
+
self,
|
|
152
|
+
constraints: list[Constraint],
|
|
153
|
+
opt: AbstractOptimizer,
|
|
154
|
+
trans: _SearchSpaceTransform,
|
|
155
|
+
constraint_enhancement: float = None,
|
|
156
|
+
constraint_scaling: float = None,
|
|
157
|
+
):
|
|
158
|
+
self.trans = trans
|
|
159
|
+
self.constraints = constraints
|
|
160
|
+
self.opt = opt
|
|
161
|
+
self.ce = constraint_enhancement or 0.
|
|
162
|
+
self.cs = constraint_scaling or 1.
|
|
163
|
+
|
|
164
|
+
self.nonlinear_inequality_constraints = []
|
|
165
|
+
cns: Constraint
|
|
166
|
+
for cns in self.constraints:
|
|
167
|
+
|
|
168
|
+
if cns.lower_bound is not None:
|
|
169
|
+
cns_botorch = _ConvertedConstraint(cns, self.opt, self.trans, 'lb', self.ce)
|
|
170
|
+
item = (lambda x: _GeneralFunctionWithForwardDifference.apply(cns_botorch, x), True)
|
|
171
|
+
self.nonlinear_inequality_constraints.append(item)
|
|
172
|
+
|
|
173
|
+
if cns.upper_bound is not None:
|
|
174
|
+
cns_botorch = _ConvertedConstraint(cns, self.opt, self.trans, 'ub', self.ce)
|
|
175
|
+
item = (lambda x: _GeneralFunctionWithForwardDifference.apply(cns_botorch, x), True)
|
|
176
|
+
self.nonlinear_inequality_constraints.append(item)
|
|
177
|
+
|
|
178
|
+
def _filter_feasible_conditions(self, ic_batch):
|
|
179
|
+
# List to store feasible initial conditions
|
|
180
|
+
feasible_ic_list = []
|
|
181
|
+
|
|
182
|
+
for each_num_restarts in ic_batch:
|
|
183
|
+
feasible_q_list = []
|
|
184
|
+
for each_q in each_num_restarts:
|
|
185
|
+
x: np.ndarray = each_q.detach().numpy() # normalized parameters
|
|
186
|
+
if _is_feasible(self.constraints, self.opt, self.trans, x, self.ce, self.cs):
|
|
187
|
+
feasible_q_list.append(each_q) # Keep only feasible rows
|
|
188
|
+
|
|
189
|
+
if feasible_q_list: # Only add if there are feasible rows
|
|
190
|
+
feasible_ic_list.append(torch.stack(feasible_q_list))
|
|
191
|
+
|
|
192
|
+
# Stack feasible conditions back into tensor format
|
|
193
|
+
if feasible_ic_list:
|
|
194
|
+
return torch.stack(feasible_ic_list).to(ic_batch)
|
|
195
|
+
else:
|
|
196
|
+
return None # Return None if none are feasible
|
|
197
|
+
|
|
198
|
+
@staticmethod
|
|
199
|
+
def _generate_random_initial_conditions(ic_batch):
|
|
200
|
+
# Generates random initial conditions with the same shape as ic_batch
|
|
201
|
+
return torch.rand(ic_batch.shape).to(ic_batch)
|
|
202
|
+
|
|
203
|
+
def _generate_feasible_initial_conditions(self, *args, **kwargs):
|
|
204
|
+
# A `num_restarts x q x d` tensor of initial conditions.
|
|
205
|
+
ic_batch = gen_batch_initial_conditions(*args, **kwargs)
|
|
206
|
+
feasible_ic_batch = self._filter_feasible_conditions(ic_batch)
|
|
207
|
+
|
|
208
|
+
while feasible_ic_batch is None:
|
|
209
|
+
# Generate new random ic_batch with the same shape
|
|
210
|
+
logger.warning(_(
|
|
211
|
+
en_message='gen_batch_initial_conditions() failed to generate '
|
|
212
|
+
'feasible initial conditions for acquisition '
|
|
213
|
+
'function optimization sub-problem, '
|
|
214
|
+
'so trying to use random feasible parameters '
|
|
215
|
+
'as initial conditions.'
|
|
216
|
+
'The constraint functions or solutions spaces '
|
|
217
|
+
'may be too complicated.',
|
|
218
|
+
jp_message='gen_batch_initial_conditions() は獲得関数を最適化する'
|
|
219
|
+
'サブ最適化問題で実行可能な初期値を生成できませんでした。'
|
|
220
|
+
'サブ最適化問題の初期値としてランダムなパラメータを設定します。'
|
|
221
|
+
'拘束が厳しすぎるか、目的関数が複雑すぎるかもしれません。'
|
|
222
|
+
))
|
|
223
|
+
random_ic_batch = self._generate_random_initial_conditions(ic_batch)
|
|
224
|
+
feasible_ic_batch = self._filter_feasible_conditions(random_ic_batch)
|
|
225
|
+
|
|
226
|
+
return feasible_ic_batch
|
|
227
|
+
|
|
228
|
+
def create_kwargs(self) -> dict:
|
|
229
|
+
"""
|
|
230
|
+
nonlinear_inequality_constraints:
|
|
231
|
+
非線形不等式制約を表すタプルのリスト。
|
|
232
|
+
タプルの最初の要素は、`callable(x) >= 0` という形式の制約を表す呼び出し可能オブジェクトです。
|
|
233
|
+
2 番目の要素はブール値で、点内制約の場合は `True`
|
|
234
|
+
制約は後で scipy ソルバーに渡されます。
|
|
235
|
+
この場合、`batch_initial_conditions` を渡す必要があります。
|
|
236
|
+
非線形不等式制約を使用するには、`batch_limit` を 1 に設定する必要もあります。
|
|
237
|
+
これは、`options` で指定されていない場合は自動的に行われます。
|
|
238
|
+
"""
|
|
239
|
+
return dict(
|
|
240
|
+
q=1,
|
|
241
|
+
options_batch_limit=1,
|
|
242
|
+
nonlinear_inequality_constraints=self.nonlinear_inequality_constraints,
|
|
243
|
+
ic_generator=self._generate_feasible_initial_conditions,
|
|
244
|
+
)
|