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
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
from time import sleep
|
|
2
|
-
from subprocess import run
|
|
3
|
-
from multiprocessing import Process
|
|
4
|
-
from tqdm import tqdm
|
|
5
|
-
from win32com.client import Dispatch
|
|
6
|
-
from femtetutils import util
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def _open_femprj(femprj_path):
|
|
10
|
-
Femtet = Dispatch("FemtetMacro.Femtet")
|
|
11
|
-
for _ in tqdm(range(5), "Wait to complete Dispatch before opening femprj..."):
|
|
12
|
-
sleep(1)
|
|
13
|
-
Femtet.LoadProject(femprj_path, True)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def launch_femtet(femprj_path):
|
|
17
|
-
# launch Femtet externally
|
|
18
|
-
util.execute_femtet()
|
|
19
|
-
pid = util.get_last_executed_femtet_process_id()
|
|
20
|
-
for _ in tqdm(range(8), "Wait to complete Femtet launching."):
|
|
21
|
-
sleep(1)
|
|
22
|
-
|
|
23
|
-
# open femprj in a different process
|
|
24
|
-
# to release Femtet for sample program
|
|
25
|
-
if femprj_path:
|
|
26
|
-
p = Process(
|
|
27
|
-
target=_open_femprj,
|
|
28
|
-
args=(femprj_path,),
|
|
29
|
-
)
|
|
30
|
-
p.start()
|
|
31
|
-
p.join()
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def taskkill_femtet():
|
|
35
|
-
for _ in tqdm(range(3), "Wait before taskkill Femtet"):
|
|
36
|
-
sleep(1)
|
|
37
|
-
run(["taskkill", "/f", "/im", "Femtet.exe"])
|
|
38
|
-
for _ in tqdm(range(3), "Wait after taskkill Femtet"):
|
|
39
|
-
sleep(1)
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import numpy as np
|
|
2
|
-
from numpy import sin, cos
|
|
3
|
-
from pyfemtet.opt import AbstractOptimizer
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class HyperSphere(object):
|
|
7
|
-
|
|
8
|
-
def __init__(self, N):
|
|
9
|
-
self.N = N
|
|
10
|
-
self._x = np.zeros(self.N, dtype=float)
|
|
11
|
-
|
|
12
|
-
def calc(self, r, *angles):
|
|
13
|
-
_x = []
|
|
14
|
-
for i in range(self.N - 1):
|
|
15
|
-
__x = r * np.prod([sin(angles[j]) for j in range(i)])
|
|
16
|
-
__x = __x * cos(angles[i])
|
|
17
|
-
_x.append(__x)
|
|
18
|
-
_x.append(r * np.prod([sin(angles[j]) for j in range(self.N - 1)]))
|
|
19
|
-
self._x = np.array(_x)
|
|
20
|
-
|
|
21
|
-
def x(self, opt: AbstractOptimizer, index: int):
|
|
22
|
-
r, *angles = opt.get_parameter("values")
|
|
23
|
-
self.calc(r, *angles)
|
|
24
|
-
return self._x[index]
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import csv
|
|
3
|
-
from shutil import copy
|
|
4
|
-
from glob import glob
|
|
5
|
-
|
|
6
|
-
import numpy as np
|
|
7
|
-
import pandas as pd
|
|
8
|
-
|
|
9
|
-
from pyfemtet.opt import FEMOpt
|
|
10
|
-
from pyfemtet._message import encoding as ENCODING
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def remove_extra_data_from_csv(csv_path, encoding=ENCODING):
|
|
14
|
-
|
|
15
|
-
with open(csv_path, mode="r", encoding=encoding, newline="\n") as f:
|
|
16
|
-
reader = csv.reader(f, delimiter=",")
|
|
17
|
-
data = [line for line in reader]
|
|
18
|
-
|
|
19
|
-
new_meta_data = data[0]
|
|
20
|
-
new_meta_data[0] = ""
|
|
21
|
-
data[0] = new_meta_data
|
|
22
|
-
|
|
23
|
-
with open(csv_path, mode="w", encoding=encoding, newline="\n") as f:
|
|
24
|
-
writer = csv.writer(f, delimiter=',')
|
|
25
|
-
writer.writerows(data)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def find_latest_csv(dir_path=None):
|
|
29
|
-
if dir_path is None:
|
|
30
|
-
dir_path = ""
|
|
31
|
-
target = os.path.join(dir_path, "*.csv")
|
|
32
|
-
files = [(f, os.path.getmtime(f)) for f in glob(target)]
|
|
33
|
-
out = sorted(files, key=lambda files: files[1])[-1]
|
|
34
|
-
return os.path.abspath(out[0])
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def py_to_reccsv(py_path, suffix=""):
|
|
38
|
-
dst_csv_path = py_path + suffix
|
|
39
|
-
dst_csv_path = dst_csv_path.replace(f".py{suffix}", f"{suffix}.reccsv")
|
|
40
|
-
return dst_csv_path
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
def record_result(src: FEMOpt or str, py_path, suffix=""):
|
|
44
|
-
"""Record the result csv for `is_equal_result`."""
|
|
45
|
-
|
|
46
|
-
if isinstance(src, FEMOpt): # get df directory
|
|
47
|
-
src_csv_path = src.history_path
|
|
48
|
-
else:
|
|
49
|
-
src_csv_path = os.path.abspath(src)
|
|
50
|
-
|
|
51
|
-
dst_csv_path = py_to_reccsv(py_path, suffix)
|
|
52
|
-
copy(src_csv_path, dst_csv_path)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
def _get_obj_from_csv(csv_path, encoding=ENCODING):
|
|
56
|
-
df = pd.read_csv(csv_path, encoding=encoding, header=2)
|
|
57
|
-
columns = df.columns
|
|
58
|
-
with open(csv_path, mode="r", encoding=encoding, newline="\n") as f:
|
|
59
|
-
reader = csv.reader(f, delimiter=",")
|
|
60
|
-
meta = reader.__next__()
|
|
61
|
-
obj_indices = np.where(np.array(meta) == "obj")[0]
|
|
62
|
-
out: pd.DataFrame = df.iloc[:, obj_indices]
|
|
63
|
-
out = out.dropna(axis=0)
|
|
64
|
-
return out, columns
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
def is_equal_result(ref_path, dif_path, log_path=None, threashold=0.05):
|
|
68
|
-
"""Check the equality of two result csv files."""
|
|
69
|
-
ref_df, ref_columns = _get_obj_from_csv(ref_path)
|
|
70
|
-
dif_df, dif_columns = _get_obj_from_csv(dif_path)
|
|
71
|
-
|
|
72
|
-
if log_path is not None:
|
|
73
|
-
with open(log_path, "a", newline="\n", encoding=ENCODING) as f:
|
|
74
|
-
f.write("\n\n===== 結果の分析 =====\n\n")
|
|
75
|
-
f.write(f" \tref\tdif\n")
|
|
76
|
-
f.write(f"---------------------\n")
|
|
77
|
-
f.write(f"len(col)\t{len(ref_columns)}\t{len(dif_columns)}\n")
|
|
78
|
-
f.write(f"len(df) \t{len(ref_df)}\t{len(dif_df)}\n")
|
|
79
|
-
try:
|
|
80
|
-
difference = (
|
|
81
|
-
np.abs(ref_df.values - dif_df.values) / np.abs(dif_df.values)
|
|
82
|
-
).mean()
|
|
83
|
-
f.write(f"diff \t{int(difference*100)}%\n")
|
|
84
|
-
except Exception:
|
|
85
|
-
f.write(f"diff \tcannot calc\n")
|
|
86
|
-
|
|
87
|
-
else:
|
|
88
|
-
difference = (
|
|
89
|
-
np.abs(ref_df.values - dif_df.values) / np.abs(dif_df.values)
|
|
90
|
-
).mean()
|
|
91
|
-
|
|
92
|
-
assert len(ref_columns) == len(dif_columns), "結果 csv の column 数が異なります。"
|
|
93
|
-
assert len(ref_df) == len(dif_df), "結果 csv の row 数が異なります。"
|
|
94
|
-
assert difference <= threashold*100, f"前回の結果との平均差異が {int(difference)}% で {int(threashold*100)}% を超えています。"
|
|
95
|
-
print(f"OK! 前回の結果との平均差異が {int(difference)}% で {int(threashold*100)}% 以下です。")
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
def _get_simplified_df_values(csv_path, exclude_columns=None):
|
|
99
|
-
exclude_columns = exclude_columns if exclude_columns is not None else []
|
|
100
|
-
|
|
101
|
-
with open(csv_path, 'r', encoding='cp932') as f:
|
|
102
|
-
meta_header = f.readline()
|
|
103
|
-
meta_header = 'removed' + meta_header.split('}"')[-1]
|
|
104
|
-
meta_header = meta_header.split(',')
|
|
105
|
-
|
|
106
|
-
df = pd.read_csv(csv_path, encoding='cp932', header=2)
|
|
107
|
-
|
|
108
|
-
prm_names = []
|
|
109
|
-
for meta_data, col in zip(meta_header, df.columns):
|
|
110
|
-
if meta_data == 'prm':
|
|
111
|
-
if col not in exclude_columns:
|
|
112
|
-
prm_names.append(col)
|
|
113
|
-
|
|
114
|
-
obj_names = []
|
|
115
|
-
for meta_data, col in zip(meta_header, df.columns):
|
|
116
|
-
if meta_data == 'obj':
|
|
117
|
-
if col not in exclude_columns:
|
|
118
|
-
obj_names.append(col)
|
|
119
|
-
|
|
120
|
-
pdf = pd.DataFrame()
|
|
121
|
-
|
|
122
|
-
for col in prm_names:
|
|
123
|
-
pdf[col] = df[col]
|
|
124
|
-
|
|
125
|
-
for col in obj_names:
|
|
126
|
-
pdf[col] = df[col]
|
|
127
|
-
|
|
128
|
-
return pdf.values.astype(float)
|
|
129
|
-
|
|
130
|
-
|
|
Binary file
|
|
Binary file
|
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
"""同梱する femtet-macro.xlsm から pyfemtet を呼び出す際の pyfemtet スクリプト。"""
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import os
|
|
5
|
-
|
|
6
|
-
from fire import Fire
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def get_sampler_class(sampling_method):
|
|
10
|
-
if sampling_method is None:
|
|
11
|
-
# default
|
|
12
|
-
from pyfemtet.opt.optimizer import PoFBoTorchSampler
|
|
13
|
-
return PoFBoTorchSampler
|
|
14
|
-
elif sampling_method == 'QMC':
|
|
15
|
-
from optuna.samplers import QMCSampler
|
|
16
|
-
return QMCSampler
|
|
17
|
-
elif sampling_method == 'PoFBoTorch':
|
|
18
|
-
from pyfemtet.opt.optimizer import PoFBoTorchSampler
|
|
19
|
-
return PoFBoTorchSampler
|
|
20
|
-
elif sampling_method == 'Random':
|
|
21
|
-
from optuna.samplers import RandomSampler
|
|
22
|
-
return RandomSampler
|
|
23
|
-
elif sampling_method == 'NSGA2':
|
|
24
|
-
from optuna.samplers import NSGAIISampler
|
|
25
|
-
return NSGAIISampler
|
|
26
|
-
elif sampling_method == 'TPE':
|
|
27
|
-
from optuna.samplers import TPESampler
|
|
28
|
-
return TPESampler
|
|
29
|
-
elif sampling_method == 'BoTorch':
|
|
30
|
-
from optuna_integration import BoTorchSampler
|
|
31
|
-
return BoTorchSampler
|
|
32
|
-
else:
|
|
33
|
-
raise NotImplementedError(f'The method {sampling_method} is not implemented.')
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def core(
|
|
37
|
-
xlsm_path: str,
|
|
38
|
-
csv_path: str or None,
|
|
39
|
-
femprj_path: str or None, # xlsm と同じフォルダに配置する前提。
|
|
40
|
-
model_name: str or None,
|
|
41
|
-
input_sheet_name: str,
|
|
42
|
-
|
|
43
|
-
output_sheet_name: str or None,
|
|
44
|
-
constraint_sheet_name: str or None,
|
|
45
|
-
procedure_name: str or None, # 引数に拡張子を除く femprj ファイル名を取るように実装すること
|
|
46
|
-
setup_procedure_name: str or None,
|
|
47
|
-
teardown_procedure_name: str or None,
|
|
48
|
-
|
|
49
|
-
sampler_class: type('BaseSampler') or None,
|
|
50
|
-
sampler_kwargs: dict or None,
|
|
51
|
-
|
|
52
|
-
n_parallel: int,
|
|
53
|
-
n_trials: int or None,
|
|
54
|
-
timeout: float or None,
|
|
55
|
-
seed: int or None,
|
|
56
|
-
):
|
|
57
|
-
from pathlib import Path
|
|
58
|
-
from pyfemtet.opt import FEMOpt, OptunaOptimizer
|
|
59
|
-
from pyfemtet.opt.interface._excel_interface import ExcelInterface
|
|
60
|
-
|
|
61
|
-
procedure_args = []
|
|
62
|
-
related_file_paths = []
|
|
63
|
-
if femprj_path is not None:
|
|
64
|
-
prj_name = os.path.basename(femprj_path).removesuffix('.femprj')
|
|
65
|
-
procedure_args.append(prj_name)
|
|
66
|
-
related_file_paths = [Path(femprj_path)]
|
|
67
|
-
if model_name is not None:
|
|
68
|
-
procedure_args.append(model_name)
|
|
69
|
-
if femprj_path is None and model_name is not None:
|
|
70
|
-
raise NotImplementedError
|
|
71
|
-
|
|
72
|
-
fem = ExcelInterface(
|
|
73
|
-
input_xlsm_path=xlsm_path,
|
|
74
|
-
input_sheet_name=input_sheet_name,
|
|
75
|
-
output_xlsm_path=None,
|
|
76
|
-
output_sheet_name=output_sheet_name,
|
|
77
|
-
constraint_xlsm_path=None,
|
|
78
|
-
constraint_sheet_name=constraint_sheet_name,
|
|
79
|
-
procedure_name=procedure_name,
|
|
80
|
-
procedure_args=procedure_args,
|
|
81
|
-
connect_method='new',
|
|
82
|
-
setup_procedure_name=setup_procedure_name,
|
|
83
|
-
teardown_procedure_name=teardown_procedure_name,
|
|
84
|
-
related_file_paths=related_file_paths,
|
|
85
|
-
visible=False,
|
|
86
|
-
interactive=True,
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
opt = OptunaOptimizer(
|
|
90
|
-
sampler_class=sampler_class,
|
|
91
|
-
sampler_kwargs=sampler_kwargs,
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
femopt = FEMOpt(
|
|
95
|
-
fem=fem,
|
|
96
|
-
opt=opt,
|
|
97
|
-
history_path=csv_path,
|
|
98
|
-
)
|
|
99
|
-
|
|
100
|
-
if seed is not None:
|
|
101
|
-
femopt.set_random_seed(42)
|
|
102
|
-
|
|
103
|
-
femopt.optimize(
|
|
104
|
-
n_trials=n_trials,
|
|
105
|
-
n_parallel=n_parallel,
|
|
106
|
-
timeout=timeout,
|
|
107
|
-
confirm_before_exit=True,
|
|
108
|
-
)
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
def main(
|
|
112
|
-
# これらは Fire キーワード引数指定できるように None を与えているが必須
|
|
113
|
-
xlsm_path: str = None,
|
|
114
|
-
input_sheet_name: str = None,
|
|
115
|
-
n_parallel: int = 1,
|
|
116
|
-
output_sheet_name: str or None = None,
|
|
117
|
-
|
|
118
|
-
femprj_path: str or None = None, # 指定する場合は xlsm と同じフォルダに配置する前提にすること
|
|
119
|
-
model_name: str = None,
|
|
120
|
-
csv_path: str or None = None,
|
|
121
|
-
constraint_sheet_name: str or None = None,
|
|
122
|
-
procedure_name: str or None = None, # 引数に拡張子を除く femprj ファイル名を取るように実装すること
|
|
123
|
-
setup_procedure_name: str or None = None,
|
|
124
|
-
teardown_procedure_name: str or None = None,
|
|
125
|
-
|
|
126
|
-
algorithm: str or None = None,
|
|
127
|
-
|
|
128
|
-
n_trials: int or None = None,
|
|
129
|
-
timeout: float or None = None,
|
|
130
|
-
seed: int or None = None,
|
|
131
|
-
|
|
132
|
-
**algorithm_settings: dict,
|
|
133
|
-
|
|
134
|
-
):
|
|
135
|
-
import sys
|
|
136
|
-
import inspect
|
|
137
|
-
from pyfemtet.logger import get_module_logger
|
|
138
|
-
|
|
139
|
-
# ----- Fire memo -----
|
|
140
|
-
# print(csv_path) # 与えなければ None
|
|
141
|
-
# print(algorithm_settings) # 与えなければ {}, 与えれば {'n_startup_trials': 10} など
|
|
142
|
-
# print(n_parallel, type(n_parallel)) # int か float に自動変換される
|
|
143
|
-
# print(timeout, type(timeout)) # int か float に自動変換される
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
# ----- check 必須 args -----
|
|
147
|
-
logger = get_module_logger('opt.script', __name__)
|
|
148
|
-
|
|
149
|
-
os.chdir(os.path.dirname(__file__))
|
|
150
|
-
|
|
151
|
-
if xlsm_path is None:
|
|
152
|
-
logger.error(f'xlsm_path を指定してください。')
|
|
153
|
-
input('終了するには Enter を押してください。')
|
|
154
|
-
sys.exit(1)
|
|
155
|
-
|
|
156
|
-
if input_sheet_name is None:
|
|
157
|
-
logger.error(f'input_sheet_name を指定してください。')
|
|
158
|
-
input('終了するには Enter を押してください。')
|
|
159
|
-
sys.exit(1)
|
|
160
|
-
|
|
161
|
-
if output_sheet_name is None:
|
|
162
|
-
logger.error(f'output_sheet_name を指定してください。')
|
|
163
|
-
input('終了するには Enter を押してください。')
|
|
164
|
-
sys.exit(1)
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
# ----- check args -----
|
|
168
|
-
logger.info(f'{os.path.basename(__file__)} は {os.path.basename(xlsm_path)} に呼び出されました.')
|
|
169
|
-
|
|
170
|
-
# xlsm_path
|
|
171
|
-
xlsm_path = os.path.abspath(xlsm_path)
|
|
172
|
-
if not os.path.exists(xlsm_path):
|
|
173
|
-
logger.error(f'{xlsm_path} が見つかりませんでした。')
|
|
174
|
-
input('終了するには Enter を押してください。')
|
|
175
|
-
sys.exit(1)
|
|
176
|
-
|
|
177
|
-
# femprj_path
|
|
178
|
-
if femprj_path is not None:
|
|
179
|
-
femprj_path = os.path.abspath(femprj_path)
|
|
180
|
-
if not os.path.exists(femprj_path):
|
|
181
|
-
logger.error(f'{femprj_path} が見つかりませんでした。')
|
|
182
|
-
input('終了するには Enter を押してください。')
|
|
183
|
-
sys.exit(1)
|
|
184
|
-
|
|
185
|
-
# model_name
|
|
186
|
-
if model_name is not None and femprj_path is None:
|
|
187
|
-
logger.error(f'model_name ({model_name}) を指定する場合は femprj_path も指定してください。')
|
|
188
|
-
input('終了するには Enter を押してください。')
|
|
189
|
-
sys.exit(1)
|
|
190
|
-
|
|
191
|
-
# n_parallel
|
|
192
|
-
try:
|
|
193
|
-
n_parallel = int(n_parallel)
|
|
194
|
-
except ValueError:
|
|
195
|
-
logger.error(f'n_parallel ({n_parallel}) は自然数にできません。')
|
|
196
|
-
input('終了するには Enter を押してください。')
|
|
197
|
-
sys.exit(1)
|
|
198
|
-
|
|
199
|
-
# csv_path
|
|
200
|
-
csv_path = os.path.abspath(csv_path) if csv_path is not None else csv_path
|
|
201
|
-
|
|
202
|
-
# n_trials
|
|
203
|
-
if n_trials is not None:
|
|
204
|
-
try:
|
|
205
|
-
n_trials = int(n_trials)
|
|
206
|
-
except ValueError:
|
|
207
|
-
logger.error(f'n_trials ({n_trials}) は自然数にできません。')
|
|
208
|
-
input('終了するには Enter を押してください。')
|
|
209
|
-
sys.exit(1)
|
|
210
|
-
|
|
211
|
-
# timeout
|
|
212
|
-
if timeout is not None:
|
|
213
|
-
try:
|
|
214
|
-
timeout = float(timeout)
|
|
215
|
-
except ValueError:
|
|
216
|
-
logger.error(f'timeout ({timeout}) は数値にできません。')
|
|
217
|
-
input('終了するには Enter を押してください。')
|
|
218
|
-
sys.exit(1)
|
|
219
|
-
|
|
220
|
-
# seed
|
|
221
|
-
if seed is not None:
|
|
222
|
-
try:
|
|
223
|
-
seed = int(seed)
|
|
224
|
-
except ValueError:
|
|
225
|
-
logger.error(f'seed ({seed}) は自然数にできません。')
|
|
226
|
-
input('終了するには Enter を押してください。')
|
|
227
|
-
sys.exit(1)
|
|
228
|
-
|
|
229
|
-
# sampler
|
|
230
|
-
try:
|
|
231
|
-
sampler_class = get_sampler_class(algorithm)
|
|
232
|
-
except NotImplementedError:
|
|
233
|
-
logger.error(f'algorithm ({algorithm}) は非対応です。')
|
|
234
|
-
input('終了するには Enter を押してください。')
|
|
235
|
-
sys.exit(1)
|
|
236
|
-
|
|
237
|
-
# sampler_kwargs
|
|
238
|
-
sampler_kwargs = algorithm_settings
|
|
239
|
-
# noinspection PyUnboundLocalVariable
|
|
240
|
-
available_sampler_kwarg_keys = inspect.signature(sampler_class).parameters.keys()
|
|
241
|
-
for given_key in sampler_kwargs.keys():
|
|
242
|
-
if given_key not in available_sampler_kwarg_keys:
|
|
243
|
-
print()
|
|
244
|
-
print(sampler_class.__doc__)
|
|
245
|
-
print()
|
|
246
|
-
logger.error(f'algorithm_setting の項目 ({given_key}) は {sampler_class.__name__} に設定できません。詳しくは上記のドキュメントをご覧ください。')
|
|
247
|
-
input('終了するには Enter を押してください。')
|
|
248
|
-
sys.exit(1)
|
|
249
|
-
|
|
250
|
-
logger.info('引数の整合性チェックが終了しました。最適化を実行します。しばらくお待ちください...')
|
|
251
|
-
|
|
252
|
-
core(
|
|
253
|
-
xlsm_path,
|
|
254
|
-
csv_path,
|
|
255
|
-
femprj_path, # xlsm と同じフォルダに配置する前提。
|
|
256
|
-
model_name,
|
|
257
|
-
input_sheet_name,
|
|
258
|
-
|
|
259
|
-
output_sheet_name,
|
|
260
|
-
constraint_sheet_name,
|
|
261
|
-
procedure_name, # 引数に拡張子を除く femprj ファイル名を取るように実装すること
|
|
262
|
-
setup_procedure_name,
|
|
263
|
-
teardown_procedure_name,
|
|
264
|
-
|
|
265
|
-
sampler_class,
|
|
266
|
-
sampler_kwargs,
|
|
267
|
-
|
|
268
|
-
n_parallel,
|
|
269
|
-
n_trials,
|
|
270
|
-
timeout,
|
|
271
|
-
seed,
|
|
272
|
-
)
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
if __name__ == '__main__':
|
|
276
|
-
Fire(main)
|
|
277
|
-
|
|
278
|
-
# ===== Debug Code =====
|
|
279
|
-
# import os
|
|
280
|
-
# os.chdir(os.path.dirname(__file__))
|
|
281
|
-
# main(
|
|
282
|
-
# xlsm_path='インターフェース.xlsm',
|
|
283
|
-
# input_sheet_name='設計変数',
|
|
284
|
-
# n_parallel=1,
|
|
285
|
-
# output_sheet_name='目的関数',
|
|
286
|
-
# constraint_sheet_name='拘束関数',
|
|
287
|
-
# procedure_name='FemtetMacro.FemtetMain',
|
|
288
|
-
# setup_procedure_name='setup',
|
|
289
|
-
# teardown_procedure_name='teardown',
|
|
290
|
-
# n_trials=3,
|
|
291
|
-
# )
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
cd %~dp0
|
|
2
|
-
rem poetry run python pyfemtet-core.py --help
|
|
3
|
-
rem poetry run python pyfemtet-core.py "xlsm" "femprj" "input_sheet" 3
|
|
4
|
-
rem poetry run python pyfemtet-core.py "xlsm" "femprj" "input_sheet" 3 --n_startup_trials=10 --timeout=3.14
|
|
5
|
-
rem poetry run python pyfemtet-core.py "xlsm" "femprj" "input_sheet" 3 --n_startup_trials=10 --timeout=5
|
|
6
|
-
rem poetry run python pyfemtet-core.py "xlsm" "femprj" "input_sheet" 3.14 --n_startup_trials=10 --timeout=5
|
|
7
|
-
poetry run python pyfemtet-core.py ^
|
|
8
|
-
�C���^�[�t�F�[�X.xlsm ^
|
|
9
|
-
--input_sheet_name="�v�ϐ�" ^
|
|
10
|
-
--output_sheet_name="�ړI��" ^
|
|
11
|
-
--constraint_sheet_name="�S����" ^
|
|
12
|
-
|
|
13
|
-
--n_parallel=1 ^
|
|
14
|
-
--csv_path="test.csv" ^
|
|
15
|
-
--procedure_name=FemtetMacro.FemtetMain ^
|
|
16
|
-
--setup_procedure_name=PrePostProcessing.setup ^
|
|
17
|
-
--teardown_procedure_name=PrePostProcessing.teardown ^
|
|
18
|
-
|
|
19
|
-
--algorithm=Random ^
|
|
20
|
-
--n_startup_trials=10 ^
|
|
21
|
-
|
|
22
|
-
pause
|
|
Binary file
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
from time import sleep
|
|
3
|
-
|
|
4
|
-
from optuna.samplers import RandomSampler, NSGAIISampler, GPSampler, BaseSampler
|
|
5
|
-
|
|
6
|
-
from pyfemtet.opt import FEMOpt, FemtetInterface, OptunaOptimizer
|
|
7
|
-
|
|
8
|
-
os.chdir(os.path.dirname(__file__))
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def get_res_freq(Femtet):
|
|
12
|
-
Galileo = Femtet.Gogh.Galileo
|
|
13
|
-
Galileo.Mode = 0
|
|
14
|
-
sleep(0.01)
|
|
15
|
-
return Galileo.GetFreq().Real
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def main(n_trials, sampler_class: type[BaseSampler], sampler_kwargs: dict):
|
|
19
|
-
"""Main function
|
|
20
|
-
|
|
21
|
-
length
|
|
22
|
-
using different algorithms for each restarting.
|
|
23
|
-
|
|
24
|
-
So this main function requires n_trials and sampler_class.
|
|
25
|
-
|
|
26
|
-
Args:
|
|
27
|
-
|
|
28
|
-
n_trials (int):
|
|
29
|
-
How many additional succeeded trials
|
|
30
|
-
to terminate optimization.
|
|
31
|
-
|
|
32
|
-
sampler_class (type[optuna.samplers.BaseSampler]):
|
|
33
|
-
The algorithm we use.
|
|
34
|
-
|
|
35
|
-
sampler_kwargs (dict):
|
|
36
|
-
The arguments of sampler.
|
|
37
|
-
|
|
38
|
-
"""
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
# Connect to Femtet.
|
|
42
|
-
fem = FemtetInterface(
|
|
43
|
-
femprj_path='gal_ex13_parametric.femprj',
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
# Initialize the optimization object.
|
|
47
|
-
opt = OptunaOptimizer(
|
|
48
|
-
sampler_class=sampler_class,
|
|
49
|
-
sampler_kwargs=sampler_kwargs,
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
# To restart, it is necessary to inform the new optimization program
|
|
53
|
-
# about the history of the previous optimization.
|
|
54
|
-
# By specifying a csv for the `history_path` argument of FEMOpt,
|
|
55
|
-
# if it does not exist, a new csv file will be created,
|
|
56
|
-
# and if it exists, optimization will continue from that csv file.
|
|
57
|
-
#
|
|
58
|
-
# Note:
|
|
59
|
-
# When restarting, the number and names of variables,
|
|
60
|
-
# as well as the number and names of objective functions
|
|
61
|
-
# and constraints must be consistent.
|
|
62
|
-
# However, you can change the bounds of variables,
|
|
63
|
-
# direction of objective functions, and content of constraints.
|
|
64
|
-
#
|
|
65
|
-
# Note:
|
|
66
|
-
# When using OptunaOptimizer, the .db file with the same name
|
|
67
|
-
# (in this case restarting-sample.db) that is saved along with
|
|
68
|
-
# csv is required to be in the same folder as the csv file.
|
|
69
|
-
femopt = FEMOpt(
|
|
70
|
-
fem=fem,
|
|
71
|
-
opt=opt,
|
|
72
|
-
history_path='restarting-sample.csv'
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
# Set the design variables.
|
|
76
|
-
femopt.add_parameter('length', 0.1, 0.02, 0.2)
|
|
77
|
-
femopt.add_parameter('width', 0.01, 0.001, 0.02)
|
|
78
|
-
femopt.add_parameter('base_radius', 0.008, 0.006, 0.01)
|
|
79
|
-
|
|
80
|
-
# Set the objective function.
|
|
81
|
-
femopt.add_objective(fun=get_res_freq, name='First Resonant Frequency (Hz)', direction=800)
|
|
82
|
-
|
|
83
|
-
# Run optimization.
|
|
84
|
-
femopt.set_random_seed(42)
|
|
85
|
-
femopt.optimize(n_trials=n_trials, confirm_before_exit=False)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if __name__ == '__main__':
|
|
89
|
-
# First, we will perform 3 optimizations using the RandomSampler.
|
|
90
|
-
main(3, RandomSampler, {})
|
|
91
|
-
|
|
92
|
-
# Next, we will perform 3 optimizations using the NSGAIISampler.
|
|
93
|
-
main(3, NSGAIISampler, {})
|
|
94
|
-
|
|
95
|
-
# Finally, we will perform 3 optimizations using the GPSampler.
|
|
96
|
-
main(3, GPSampler, {'n_startup_trials': 0, 'deterministic_objective': True})
|
|
97
|
-
|
|
98
|
-
# After this program ends, you can continue further with
|
|
99
|
-
# restarting-sample.csv and the .db file.
|