pyfemtet 0.8.10__py3-none-any.whl → 0.8.11__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 CHANGED
@@ -1 +1 @@
1
- __version__ = "0.8.10"
1
+ __version__ = "0.8.11"
@@ -306,7 +306,7 @@ class Function:
306
306
  fun.__globals__[varname] = _Scapegoat()
307
307
 
308
308
  self.fun = fun
309
- self.name = name
309
+ self.name: str = name
310
310
  self.args = args
311
311
  self.kwargs = kwargs
312
312
 
@@ -853,7 +853,7 @@ class History:
853
853
 
854
854
  # 最小化問題に変換された objective values を取得
855
855
  raw_objective_values = df[self.obj_names].values
856
- objective_values = np.full_like(raw_objective_values, np.nan)
856
+ objective_values = np.full_like(raw_objective_values, np.nan, dtype=float)
857
857
  for n_trial in range(len(raw_objective_values)):
858
858
  for obj_idx, (_, objective) in enumerate(objectives.items()):
859
859
  objective_values[n_trial, obj_idx] = objective.convert(raw_objective_values[n_trial, obj_idx])
@@ -79,7 +79,7 @@ class ExcelInterface(FEMInterface):
79
79
 
80
80
  connect_method (str, optional):
81
81
  Excel との接続方法を指定します。 'auto' または
82
- 'new' が利用可能です。デフォルトは 'auto' です。
82
+ 'new' が利用可能です。デフォルトは 'new' です。
83
83
 
84
84
  procedure_timeout (float or None, optional):
85
85
  Excel マクロ関数のタイムアウト時間を秒単位で指定
@@ -232,7 +232,7 @@ class ExcelInterface(FEMInterface):
232
232
  constraint_sheet_name: str = None,
233
233
  procedure_name: str = None,
234
234
  procedure_args: list or tuple = None,
235
- connect_method: str = 'auto', # or 'new'
235
+ connect_method: str = 'new', # or 'auto'
236
236
  procedure_timeout: float or None = None,
237
237
  setup_xlsm_path: str or Path = None,
238
238
  setup_procedure_name: str = None,
@@ -443,7 +443,7 @@ class ExcelInterface(FEMInterface):
443
443
  self.excel = DispatchEx('Excel.Application')
444
444
 
445
445
  # FemtetRef を追加する
446
- self.open_femtet_ref_xla() # ここでエラーが発生しているかも?
446
+ self.open_femtet_ref_xla()
447
447
  sleep(0.5)
448
448
 
449
449
  # 起動した excel の pid を記憶する
@@ -730,11 +730,15 @@ class ExcelInterface(FEMInterface):
730
730
  def input_workbook(self) -> CDispatch:
731
731
  return self.wb_input
732
732
 
733
- def load_parameter(self, opt) -> None:
733
+ def load_parameter(self, opt, raise_if_no_keyword=True) -> None:
734
734
  from pyfemtet.opt.optimizer import AbstractOptimizer, logger
735
735
  opt: AbstractOptimizer
736
736
 
737
- df = ParseAsParameter.parse(self.input_xlsm_path, self.input_sheet_name)
737
+ df = ParseAsParameter.parse(
738
+ self.input_xlsm_path,
739
+ self.input_sheet_name,
740
+ raise_if_no_keyword,
741
+ )
738
742
 
739
743
  for i, row in df.iterrows():
740
744
 
@@ -781,6 +785,7 @@ class ExcelInterface(FEMInterface):
781
785
  opt.variables.add_parameter(prm)
782
786
 
783
787
  else:
788
+ # noinspection PyTypeChecker
784
789
  fixed_prm = Expression(
785
790
  name=name,
786
791
  fun=lambda: value,
@@ -794,7 +799,7 @@ class ExcelInterface(FEMInterface):
794
799
  )
795
800
  opt.variables.add_expression(fixed_prm)
796
801
 
797
- def load_objective(self, opt):
802
+ def load_objective(self, opt, raise_if_no_keyword=True):
798
803
  from pyfemtet.opt.optimizer import AbstractOptimizer
799
804
  from pyfemtet.opt._femopt_core import Objective
800
805
  opt: AbstractOptimizer
@@ -802,6 +807,7 @@ class ExcelInterface(FEMInterface):
802
807
  df = ParseAsObjective.parse(
803
808
  self.output_xlsm_path,
804
809
  self.output_sheet_name,
810
+ raise_if_no_keyword,
805
811
  )
806
812
 
807
813
  for i, row in df.iterrows():
@@ -44,9 +44,12 @@ class FemtetWithExcelSettingsInterface(FemtetInterface, ExcelInterface, FEMInter
44
44
  terminate_excel_when_quit: bool = None, interactive: bool = True, use_named_range: bool = True,
45
45
 
46
46
  ):
47
+
48
+ excel_connect_method = 'new'
49
+
47
50
  ExcelInterface.__init__(
48
51
  self, input_xlsm_path, input_sheet_name, output_xlsm_path, output_sheet_name, constraint_xlsm_path,
49
- constraint_sheet_name, procedure_name, procedure_args, connect_method, procedure_timeout,
52
+ constraint_sheet_name, procedure_name, procedure_args, excel_connect_method, procedure_timeout,
50
53
  setup_xlsm_path, setup_procedure_name, setup_procedure_args, teardown_xlsm_path,
51
54
  teardown_procedure_name, teardown_procedure_args, related_file_paths, visible, display_alerts,
52
55
  terminate_excel_when_quit, interactive, use_named_range)
@@ -58,7 +61,7 @@ class FemtetWithExcelSettingsInterface(FemtetInterface, ExcelInterface, FEMInter
58
61
  )
59
62
 
60
63
 
61
- def load_objective(self, opt):
64
+ def load_objective(self, opt, raise_if_no_keyword=True):
62
65
  from pyfemtet.opt.optimizer import AbstractOptimizer
63
66
  from pyfemtet.opt._femopt_core import Objective
64
67
  opt: AbstractOptimizer
@@ -66,7 +69,7 @@ class FemtetWithExcelSettingsInterface(FemtetInterface, ExcelInterface, FEMInter
66
69
  df = ParseAsObjective.parse(
67
70
  self.output_xlsm_path,
68
71
  self.output_sheet_name,
69
- False
72
+ raise_if_no_keyword,
70
73
  )
71
74
 
72
75
  for i, row in df.iterrows():
@@ -107,7 +107,8 @@ class ParametricResultCSVProcessor:
107
107
 
108
108
  # 与えられた output_number に関連する行だけ抜き出し
109
109
  # エラーがあるかどうかチェックする
110
- pdf = df['結果出力設定番号'] == parametric_output_index + 1
110
+ idx = df['結果出力設定番号'] == parametric_output_index + 1
111
+ pdf = df[idx]
111
112
 
112
113
  # 結果出力設定番号 カラムが存在しない
113
114
  else:
@@ -18,7 +18,6 @@ class PoFBoTorchInterfaceWithExcelSettingsInterface(
18
18
 
19
19
  # SurrogateModel
20
20
  history_path: str = None, train_history: History = None,
21
- _output_directions: dict[int, str | float] | list[str | float] = None,
22
21
 
23
22
  # Excel
24
23
  input_xlsm_path: str or Path = None,
@@ -29,7 +28,7 @@ class PoFBoTorchInterfaceWithExcelSettingsInterface(
29
28
  constraint_sheet_name: str = None,
30
29
  procedure_name: str = None,
31
30
  procedure_args: list or tuple = None,
32
- connect_method: str = 'auto', # or 'new'
31
+ # connect_method: str = 'auto', # or 'new'
33
32
  procedure_timeout: float or None = None,
34
33
  setup_xlsm_path: str or Path = None,
35
34
  setup_procedure_name: str = None,
@@ -48,9 +47,10 @@ class PoFBoTorchInterfaceWithExcelSettingsInterface(
48
47
  self,
49
48
  history_path,
50
49
  train_history,
51
- _output_directions,
52
50
  )
53
51
 
52
+ connect_method = 'new'
53
+
54
54
  ExcelInterface.__init__(
55
55
  self,
56
56
  input_xlsm_path,
@@ -77,11 +77,11 @@ class PoFBoTorchInterfaceWithExcelSettingsInterface(
77
77
  use_named_range,
78
78
  )
79
79
 
80
- def load_parameter(self, opt) -> None:
81
- ExcelInterface.load_parameter(self, opt)
80
+ def load_parameter(self, opt, raise_if_no_keyword=True) -> None:
81
+ ExcelInterface.load_parameter(self, opt, raise_if_no_keyword)
82
82
 
83
- def load_objective(self, opt) -> None:
84
- PoFBoTorchInterface.load_objective(self, opt)
83
+ def load_objective(self, opt, raise_if_no_keyword=True) -> None:
84
+ ExcelInterface.load_objective(self, opt, raise_if_no_keyword)
85
85
 
86
86
  def load_constraint(self, opt, raise_if_no_keyword=False):
87
87
  ExcelInterface.load_constraint(self, opt, raise_if_no_keyword)
File without changes
@@ -0,0 +1,213 @@
1
+ CONFIRM_BEFORE_ABNORMAL_TERMINATION = True
2
+
3
+ try:
4
+
5
+ # for meta script
6
+ import os
7
+ import sys
8
+ import importlib
9
+ import pyfemtet
10
+
11
+ if __name__ == '__main__':
12
+ print(f'pyfemtet {pyfemtet.__version__} starting.')
13
+
14
+ from pyfemtet._message.messages import encoding
15
+
16
+ from fire import Fire
17
+ import yaml
18
+
19
+ # for concrete script
20
+ from optuna.samplers import *
21
+ from pyfemtet.opt import FEMOpt
22
+ from pyfemtet.opt.interface import *
23
+ from pyfemtet.opt.optimizer import *
24
+ from pyfemtet.opt.interface._femtet_excel import FemtetWithExcelSettingsInterface
25
+ from pyfemtet.opt.interface._surrogate_excel import PoFBoTorchInterfaceWithExcelSettingsInterface
26
+
27
+ # for debug
28
+ DEBUG = False
29
+
30
+ class ContentContext:
31
+
32
+ def __init__(self, content_):
33
+ self.content = content_
34
+
35
+ def __enter__(self):
36
+ return self.content
37
+
38
+ def __exit__(self, exc_type, exc_val, exc_tb):
39
+ pass
40
+
41
+ # for importing user-defined module
42
+ def import_from_path(module_name, file_path):
43
+
44
+ print(f'{file_path=}')
45
+
46
+ # noinspection PyUnresolvedReferences
47
+ spec = importlib.util.spec_from_file_location(module_name, file_path)
48
+
49
+ print(f'{spec=}')
50
+
51
+ # noinspection PyUnresolvedReferences
52
+ module = importlib.util.module_from_spec(spec)
53
+
54
+ print(f'{module=}')
55
+
56
+ sys.modules[module_name] = module
57
+ spec.loader.exec_module(module)
58
+ return module
59
+
60
+
61
+ def main(
62
+ yaml_path: str = None,
63
+
64
+ interface_class: str = None, # including parameter definition excel
65
+ interface_kwargs: str = None, # including Parametric Analysis Output
66
+ optimizer_class: str = None,
67
+ optimizer_kwargs: str = None,
68
+ femopt_kwargs: str = None,
69
+ seed: str = 'null',
70
+ optimize_kwargs: str = None,
71
+ additional_module_paths: list[str] = None,
72
+
73
+ confirm_before_abnormal_termination: bool = True,
74
+ ):
75
+ """
76
+
77
+ Args:
78
+ yaml_path:
79
+ If this argument is passed, the other arguments will be ignored
80
+ and load by .yaml file.
81
+ The yaml file must contain the other arguments.
82
+
83
+ interface_class: FemtetWithExcelSettingsInterface or SurrogateModelInterface.
84
+ interface_kwargs: See documentation of each interface class.
85
+ optimizer_class: OptunaOptimizer or ScipyOptimizer.
86
+ optimizer_kwargs: See documentation of each optimizer class.
87
+ femopt_kwargs: See documentation of FEMOpt.
88
+ seed: int or None.
89
+ optimize_kwargs: See documentation of FEMOpt.optimize().
90
+ additional_module_paths:
91
+ The .py file paths containing user-defined objective and constraints functions.
92
+ The module must contain __objective_functions__ or __constraint_functions__.
93
+ They must be a dict variable that contains the required arguments of
94
+ `FEMOpt.add_objective()` or `FEMOpt.add_constraint()` method.
95
+ Note that the `args` argument of constraint function is reserved by meta_script
96
+ and that value is fixed to `FEMOpt.opt`, so you can not use `args` argument
97
+ in __constraint_functions__.
98
+ Note that the functions should not contain the python variables defined outside
99
+ global scope.
100
+ confirm_before_abnormal_termination: Pause before termination if an error occurs. Default is True.
101
+
102
+ """
103
+
104
+ global CONFIRM_BEFORE_ABNORMAL_TERMINATION
105
+ CONFIRM_BEFORE_ABNORMAL_TERMINATION = confirm_before_abnormal_termination
106
+
107
+ # load variables from yaml file
108
+ if yaml_path is not None:
109
+
110
+ # check
111
+ if os.path.isfile(yaml_path):
112
+ context = open(yaml_path, 'r', encoding='utf-8')
113
+
114
+ else:
115
+ if DEBUG:
116
+ print('debug mode')
117
+ context = ContentContext(yaml_path) # yaml_path is yaml content
118
+
119
+ else:
120
+ raise FileNotFoundError(yaml_path)
121
+
122
+ # load **as yaml content**
123
+ with context as f:
124
+ d = yaml.safe_load(f)
125
+ interface_class = yaml.safe_dump(d['interface_class'], allow_unicode=True)
126
+ interface_kwargs = yaml.safe_dump(d['interface_kwargs'], allow_unicode=True)
127
+ optimizer_class = yaml.safe_dump(d['optimizer_class'], allow_unicode=True)
128
+ optimizer_kwargs = yaml.safe_dump(d['optimizer_kwargs'], allow_unicode=True)
129
+ femopt_kwargs = yaml.safe_dump(d['femopt_kwargs'], allow_unicode=True)
130
+ seed = yaml.safe_dump(d['seed'], allow_unicode=True)
131
+ optimize_kwargs = yaml.safe_dump(d['optimize_kwargs'], allow_unicode=True)
132
+ additional_module_paths = yaml.safe_dump(d.get('additional_module_paths', None), allow_unicode=True)
133
+
134
+ # load **python variables** from yaml content
135
+
136
+ # additional import
137
+ additional_module_paths_ = yaml.safe_load(additional_module_paths)
138
+
139
+ if additional_module_paths_ is not None:
140
+
141
+ for i, path_ in enumerate(additional_module_paths_):
142
+
143
+ # noinspection PyUnresolvedReferences
144
+ additional_module = import_from_path(f'additional_module_{i}', path_)
145
+
146
+ # from additional_module import *
147
+ if hasattr(additional_module, '__all__'):
148
+ globals().update({key: getattr(additional_module, key) for key in additional_module.__all__})
149
+
150
+ Interface = eval(yaml.safe_load(interface_class))
151
+ interface_kwargs_ = yaml.safe_load(interface_kwargs)
152
+
153
+ Optimizer = eval(yaml.safe_load(optimizer_class))
154
+ optimizer_kwargs_ = yaml.safe_load(optimizer_kwargs)
155
+
156
+ optimizer_kwargs_['sampler_class'] = eval(optimizer_kwargs_['sampler_class'])
157
+
158
+ femopt_kwargs_ = yaml.safe_load(femopt_kwargs)
159
+
160
+ seed_ = yaml.safe_load(seed)
161
+
162
+ optimize_kwargs_ = yaml.safe_load(optimize_kwargs)
163
+
164
+ fem = Interface(**interface_kwargs_)
165
+ opt = Optimizer(**optimizer_kwargs_)
166
+ femopt = FEMOpt(fem=fem, opt=opt, **femopt_kwargs_)
167
+
168
+ if additional_module_paths_ is not None:
169
+
170
+ for i, path_ in enumerate(additional_module_paths_):
171
+
172
+ # noinspection PyUnresolvedReferences
173
+ additional_module = import_from_path(f'additional_module_{i}', path_)
174
+
175
+ # import obj & cns
176
+ d: dict
177
+ if hasattr(additional_module, '__objective_functions__'):
178
+ for d in additional_module.__objective_functions__:
179
+ femopt.add_objective(
180
+ fun=d['fun'],
181
+ name=d.get('name'),
182
+ direction=d.get('direction'),
183
+ args=d.get('args'),
184
+ kwargs=d.get('kwargs'),
185
+ )
186
+ if hasattr(additional_module, '__constraint_functions__'):
187
+ for d in additional_module.__constraint_functions__:
188
+ femopt.add_constraint(
189
+ fun=d['fun'],
190
+ name=d.get('name'),
191
+ lower_bound=d.get('lower_bound'),
192
+ upper_bound=d.get('upper_bound'),
193
+ strict=d.get('strict', True),
194
+ using_fem=d.get('using_fem'),
195
+ args=(femopt.opt,),
196
+ kwargs=d.get('kwargs'),
197
+ )
198
+
199
+ femopt.set_random_seed(seed_)
200
+ femopt.optimize(**optimize_kwargs_)
201
+
202
+
203
+ if __name__ == '__main__':
204
+ Fire(main)
205
+
206
+
207
+ except Exception as e:
208
+ from traceback import print_exception
209
+
210
+ print_exception(e)
211
+ print()
212
+ if CONFIRM_BEFORE_ABNORMAL_TERMINATION:
213
+ input('終了するには Enter を押してください。')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pyfemtet
3
- Version: 0.8.10
3
+ Version: 0.8.11
4
4
  Summary: Design parameter optimization using Femtet.
5
5
  License: BSD-3-Clause
6
6
  Author: kazuma.naito
@@ -1,4 +1,4 @@
1
- pyfemtet/__init__.py,sha256=CKrbpoGm6OyINBDoT8Nfpyecbw2W68SS4YSkSpJJ5-0,22
1
+ pyfemtet/__init__.py,sha256=2JL5Qr1tMuuX9W0K2n-UaciQXJtKIEm_9ijSZ2wv2C0,22
2
2
  pyfemtet/_femtet_config_util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  pyfemtet/_femtet_config_util/autosave.py,sha256=dNirA9XGuFehas8_Jkj2BW9GOzMbPyhnt1WHcH_ObSU,2070
4
4
  pyfemtet/_femtet_config_util/exit.py,sha256=0BWID-tjOkmZwmgPFkcJMkWW39voccz5ARIBWvZbHaw,1877
@@ -25,7 +25,7 @@ pyfemtet/logger/__init__.py,sha256=UOJ9n_U2xwdTrp0Xgg-N6geySxNzKqTBQlXsaH0kW_w,4
25
25
  pyfemtet/logger/_impl.py,sha256=rsAd0HpmveOaLS39ucp3U2OcDhQMWjC5fnVGhbJtWVw,6375
26
26
  pyfemtet/opt/__init__.py,sha256=wRR8LbEhb5I6MUgmnCgjB6-tqHlOVxDIo7yPkq0QbBs,758
27
27
  pyfemtet/opt/_femopt.py,sha256=MSqSJzyD2sRYBNQAe0P5rpSvvVihOV2ugUa-hZyYnBA,40671
28
- pyfemtet/opt/_femopt_core.py,sha256=mm7ySxFSp4RhRT_Bt2TxWVUXaA2ejRJJZDOHj9CV6Ho,39348
28
+ pyfemtet/opt/_femopt_core.py,sha256=w8jcKAIxakO2JMC51TTWI3iL-3wlEg6wCDn45D4ZCe4,39366
29
29
  pyfemtet/opt/_test_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
30
  pyfemtet/opt/_test_utils/control_femtet.py,sha256=8oAl9y5V2n8Nnsgx_ebcZVzwFt1eI3swkdiKg6pg3-M,1085
31
31
  pyfemtet/opt/_test_utils/hyper_sphere.py,sha256=nQhw8EIY0DwvcTqrbKhkxiITLZifr4-nG77E-_6ggmA,700
@@ -34,10 +34,6 @@ pyfemtet/opt/advanced_samples/excel_ui/(ref) original_project.femprj,sha256=5OqZ
34
34
  pyfemtet/opt/advanced_samples/excel_ui/femtet-macro.xlsm,sha256=7G9hr1Oj1zwTFv6mh2fWk4FZ0R5ZNDQmvjNvujy6gbw,124145
35
35
  pyfemtet/opt/advanced_samples/excel_ui/pyfemtet-core.py,sha256=aF2TWXdbt7dnkeBqqVO6GvIExozjFp0mxx3BX8rpYNc,9879
36
36
  pyfemtet/opt/advanced_samples/excel_ui/test-pyfemtet-core.cmd,sha256=r-Pa1Ng9sa6wfDqIhTf2BUDrN9rePWFymz7pmtBbvcQ,895
37
- pyfemtet/opt/advanced_samples/meta_script/meta_script.py,sha256=v0D-4xqH_fvMEQ4B_OnJrtlUsJ6kQfLLcE4YHlsgmMw,4896
38
- pyfemtet/opt/advanced_samples/meta_script/sample.yaml,sha256=_X95DVX1BMIFlML1mW4UqymOMxLElw3aeWiI9KJBD-k,351
39
- pyfemtet/opt/advanced_samples/meta_script/yaml_generator.txt,sha256=n2IWoAge_fWWBDfOi-rHQYZvfyGQqdS4BOSTvsdKYjk,670
40
- pyfemtet/opt/advanced_samples/meta_script/yaml_generator.xlsm,sha256=YUaVVqtoa5dTY0c2gJ5C3s4y7eC5Gx5PRtxA2rwV9-s,18287
41
37
  pyfemtet/opt/advanced_samples/restart/gal_ex13_parametric.femprj,sha256=iIHH1X-wWBqEYj4cFJXco73LCJXSrYBsSKOD0HxYu60,87599
42
38
  pyfemtet/opt/advanced_samples/restart/gal_ex13_parametric_restart.py,sha256=YCqtLjazFDRKhEu7sGJlDJDDL7YPH6GmWEb6X0e30Og,3045
43
39
  pyfemtet/opt/advanced_samples/restart/gal_ex13_parametric_restart_jp.py,sha256=Oaua2Eb8NGtlWjvYC9B1uYTKcEuWxWZxzJbLi_4IqxE,3580
@@ -48,10 +44,10 @@ pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_optimize_with_surrogate_j
48
44
  pyfemtet/opt/advanced_samples/surrogate_model/gal_ex13_parametric.femprj,sha256=iIHH1X-wWBqEYj4cFJXco73LCJXSrYBsSKOD0HxYu60,87599
49
45
  pyfemtet/opt/interface/__init__.py,sha256=SstCN9WMYqF5lKNbb8xAzq0hBV-Hk8YuCrajvF3sOg0,1350
50
46
  pyfemtet/opt/interface/_base.py,sha256=zbRhNB4fwznKHsllC1X29TONoB9MP8qMH8Nqz4NX_yA,2838
51
- pyfemtet/opt/interface/_excel_interface.py,sha256=pJ2JGBbAuU_UrxVYj6_DL51WkUbsl1-eEJsUxeq_dQk,40007
47
+ pyfemtet/opt/interface/_excel_interface.py,sha256=1PYB056rU2mX-LgBWRwwTUxDkt7crgHAk3fKJuMNMMU,40152
52
48
  pyfemtet/opt/interface/_femtet.py,sha256=bAeFG4oik0zt3PcbPOhhQOm0-kboS83JKn0RX_mIrP0,37779
53
- pyfemtet/opt/interface/_femtet_excel.py,sha256=4o1jdP1WZxaVhe8Me60SGKV4AP7Dvy0ZqnUjyeIfCWY,5882
54
- pyfemtet/opt/interface/_femtet_parametric.py,sha256=rhvnpHdbjNJAKxiCkgnExnZdV5qOB6pBv6AaLeTkeF8,10155
49
+ pyfemtet/opt/interface/_femtet_excel.py,sha256=dWPQguKNOVdJ4jTfwLykCeM9iwA2S1KOLynw8UGzmvk,5968
50
+ pyfemtet/opt/interface/_femtet_parametric.py,sha256=hxNiZfhR1IPtrMXg39TZutXTcOXdoxTKiRTTcYRGgVs,10181
55
51
  pyfemtet/opt/interface/_femtet_with_nx/__init__.py,sha256=-6W2g2FDEcKzGHmI5KAKQe-4U5jDpMj0CXuma-GZca0,83
56
52
  pyfemtet/opt/interface/_femtet_with_nx/_interface.py,sha256=LkaODUSpBLq05uz5Jf-JKuH6Evq8ElZoItXxFZopWeM,5994
57
53
  pyfemtet/opt/interface/_femtet_with_nx/update_model.py,sha256=P7VH0i_o-X9OUe6AGaLF1fACPeHNrMjcrOBCA3MMrI4,3092
@@ -60,7 +56,10 @@ pyfemtet/opt/interface/_surrogate/__init__.py,sha256=2UT5NuBylyWQJNjg1zsBRCV-MzN
60
56
  pyfemtet/opt/interface/_surrogate/_base.py,sha256=s_Mqo7CUAhaj-ZYYxxGKekiox4EnH_SnWB8eVj-VnFU,4739
61
57
  pyfemtet/opt/interface/_surrogate/_chaospy.py,sha256=Bqej89Mo0zgdJq1OK7YKRqHOcuyN0wL4ZQUQXdJtYJ8,1987
62
58
  pyfemtet/opt/interface/_surrogate/_singletaskgp.py,sha256=bHzY5QIjA9zhLxweexz259XQMZLgkHWfrIDW7f3q-2k,2520
63
- pyfemtet/opt/interface/_surrogate_excel.py,sha256=YOXa4EMqPw8fo75tr_cb1wJw6vKzUipI3m-1BQAl-5Y,3501
59
+ pyfemtet/opt/interface/_surrogate_excel.py,sha256=r0i9xNb6R-1SHL911Pi9x6lD4mQbCl8m3cQG2dQft1E,3509
60
+ pyfemtet/opt/meta_script/YAML_Generator.xlsm,sha256=2hZKioZfGkH_0ufre8xi2gps8SJUNwgSB_6b9vCc2tI,66648
61
+ pyfemtet/opt/meta_script/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
62
+ pyfemtet/opt/meta_script/__main__.py,sha256=J7RD6aFr67t62tcwgLcoC4GzQ2DdYFxx7z63imro9A4,8061
64
63
  pyfemtet/opt/optimizer/__init__.py,sha256=Ia6viowECkG0IFXtFef0tJ4jDKsoDzJLqMJ9xLFH2LQ,543
65
64
  pyfemtet/opt/optimizer/_base.py,sha256=1TY1iVZdpgJcmF6g3-CcY-6u4REs8_gR_0y9cXUQe2s,12932
66
65
  pyfemtet/opt/optimizer/_optuna/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -149,8 +148,8 @@ pyfemtet/opt/visualization/result_viewer/.gitignore,sha256=ryvb4aqbbsHireHWlPQfx
149
148
  pyfemtet/opt/visualization/result_viewer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
150
149
  pyfemtet/opt/visualization/result_viewer/application.py,sha256=WcHBx_J5eNLKSaprpk9BGifwhO04oN8FiNGYTWorrXA,1691
151
150
  pyfemtet/opt/visualization/result_viewer/pages.py,sha256=MZAjzbuq0toZrR-iJhElM3A12_jHVCTt65gz1kdNPbw,32193
152
- pyfemtet-0.8.10.dist-info/LICENSE,sha256=sVQBhyoglGJUu65-BP3iR6ujORI6YgEU2Qm-V4fGlOA,1485
153
- pyfemtet-0.8.10.dist-info/METADATA,sha256=IfB4bF5vQgSvuRP8aMQZqIsn7bO9UnNH5rME4ZIOXNY,3549
154
- pyfemtet-0.8.10.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
155
- pyfemtet-0.8.10.dist-info/entry_points.txt,sha256=ZfYqRaoiPtuWqFi2_msccyrVF0LurMn-IHlYamAegZo,104
156
- pyfemtet-0.8.10.dist-info/RECORD,,
151
+ pyfemtet-0.8.11.dist-info/LICENSE,sha256=sVQBhyoglGJUu65-BP3iR6ujORI6YgEU2Qm-V4fGlOA,1485
152
+ pyfemtet-0.8.11.dist-info/METADATA,sha256=Yg6P6oApQo_63zTEzB4m2Ls3TQCljx_Tddr_T5bWgYs,3549
153
+ pyfemtet-0.8.11.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
154
+ pyfemtet-0.8.11.dist-info/entry_points.txt,sha256=ZfYqRaoiPtuWqFi2_msccyrVF0LurMn-IHlYamAegZo,104
155
+ pyfemtet-0.8.11.dist-info/RECORD,,
@@ -1,163 +0,0 @@
1
- # for meta script
2
- import os
3
- import pyfemtet
4
-
5
- if __name__ == '__main__':
6
- print(f'pyfemtet {pyfemtet.__version__} starting.')
7
-
8
- from pyfemtet._message.messages import encoding
9
-
10
- from fire import Fire
11
- import yaml
12
-
13
- # for concrete script
14
- from pyfemtet.opt import FEMOpt
15
- from pyfemtet.opt.interface import *
16
- from pyfemtet.opt.optimizer import *
17
- from optuna.samplers import *
18
- from pyfemtet.opt.interface._femtet_excel import FemtetWithExcelSettingsInterface
19
-
20
-
21
- # fore debug
22
- class ContentContext:
23
-
24
- def __init__(self, content_):
25
- self.content = content_
26
-
27
- def __enter__(self):
28
- return self.content
29
-
30
- def __exit__(self, exc_type, exc_val, exc_tb):
31
- pass
32
-
33
-
34
- def main(
35
- yaml_path: str = None,
36
-
37
- interface_class: str = None, # including parameter definition excel
38
- interface_kwargs: str = None, # including Parametric Analysis Output
39
- optimizer_class: str = None,
40
- optimizer_kwargs: str = None,
41
- femopt_kwargs: str = None,
42
- seed: str = 'null',
43
- optimize_kwargs: str = None,
44
- ):
45
- """
46
-
47
- Args:
48
- yaml_path:
49
- If this argument is passed, the other arguments will be ignored
50
- and load by .yaml file.
51
- The yaml file must contain the other arguments.
52
-
53
- interface_class: FemtetWithExcelSettingsInterface or SurrogateModelInterface.
54
- interface_kwargs: See documentation of each interface class.
55
- optimizer_class: OptunaOptimizer or ScipyOptimizer.
56
- optimizer_kwargs: See documentation of each optimizer class.
57
- femopt_kwargs: See documentation of FEMOpt.
58
- seed: int or None.
59
- optimize_kwargs: See documentation of FEMOpt.optimize().
60
-
61
- """
62
-
63
- if yaml_path is not None:
64
- if os.path.isfile(yaml_path):
65
- context = open(yaml_path, 'r', encoding='utf-8')
66
- else:
67
- print('debug mode')
68
- context = ContentContext(yaml_path)
69
- with context as f:
70
- d = yaml.safe_load(f)
71
- interface_class = yaml.safe_dump(d['interface_class'], allow_unicode=True)
72
- interface_kwargs = yaml.safe_dump(d['interface_kwargs'], allow_unicode=True)
73
- optimizer_class = yaml.safe_dump(d['optimizer_class'], allow_unicode=True)
74
- optimizer_kwargs = yaml.safe_dump(d['optimizer_kwargs'], allow_unicode=True)
75
- femopt_kwargs = yaml.safe_dump(d['femopt_kwargs'], allow_unicode=True)
76
- seed = yaml.safe_dump(d['seed'], allow_unicode=True)
77
- optimize_kwargs = yaml.safe_dump(d['optimize_kwargs'], allow_unicode=True)
78
-
79
- Interface = eval(yaml.safe_load(interface_class))
80
- interface_kwargs_ = yaml.safe_load(interface_kwargs)
81
-
82
- Optimizer = eval(yaml.safe_load(optimizer_class))
83
- optimizer_kwargs_ = yaml.safe_load(optimizer_kwargs)
84
-
85
- femopt_kwargs_ = yaml.safe_load(femopt_kwargs)
86
-
87
- seed_ = yaml.safe_load(seed)
88
-
89
- optimize_kwargs_ = yaml.safe_load(optimize_kwargs)
90
-
91
- fem = Interface(**interface_kwargs_)
92
- opt = Optimizer(**optimizer_kwargs_)
93
- femopt = FEMOpt(fem=fem, opt=opt, **femopt_kwargs_)
94
- femopt.set_random_seed(seed_)
95
- femopt.optimize(**optimize_kwargs_)
96
-
97
-
98
- # if __name__ == '__main__':
99
- # Fire(main)
100
-
101
-
102
- # for debugging file input
103
- if __name__ == '__main__':
104
- os.chdir(os.path.dirname(__file__))
105
- path = 'sample.yaml'
106
- main(yaml_path=path)
107
-
108
-
109
- # for debugging yaml input
110
- # if __name__ == '__main__':
111
- # content = r"""
112
- # interface_class: FemtetInterface
113
- # interface_kwargs:
114
- # femprj_path: C:\日本語ファイル.femprj
115
- # optimizer_class: OptunaOptimizer
116
- # optimizer_kwargs:
117
- # sampler_class: TPESampler
118
- # sampler_kwargs:
119
- # n_startup_trials: 10
120
- # femopt_kwargs:
121
- # history_path: sample.csv
122
- # optimize_kwargs:
123
- # n_trials: 15
124
- # confirm_before_exit: False
125
- # seed: null
126
- # """
127
- #
128
- # main(yaml_path=content)
129
-
130
-
131
- # for debugging CLI input
132
- # if __name__ == '__main__':
133
- #
134
- # interface_kwargs = dict(
135
- # femprj_path=r'sample.femprj',
136
- # parametric_output_indexes_use_as_objective={0: 0, 1: 'minimize'}
137
- # )
138
- # optimizer_kwargs = dict(
139
- # sampler_class='TPESampler',
140
- # sampler_kwargs=dict(
141
- # n_startup_trials=10,
142
- # )
143
- # )
144
- # femopt_kwargs = dict(
145
- # history_path='sample.csv'
146
- # )
147
- #
148
- # seed = None
149
- #
150
- # optimize_kwargs = dict(
151
- # n_trials=15,
152
- # confirm_before_exit=False,
153
- # )
154
- #
155
- # main(
156
- # interface_class='FemtetWithExcelSettingsInterface',
157
- # interface_kwargs=yaml.safe_dump(interface_kwargs, allow_unicode=True),
158
- # optimizer_class='OptunaOptimizer',
159
- # optimizer_kwargs=yaml.safe_dump(optimizer_kwargs, allow_unicode=True),
160
- # femopt_kwargs=yaml.safe_dump(femopt_kwargs, allow_unicode=True),
161
- # seed=yaml.safe_dump(femopt_kwargs, allow_unicode=True),
162
- # optimize_kwargs=yaml.safe_dump(optimize_kwargs, allow_unicode=True),
163
- # )
@@ -1,14 +0,0 @@
1
-  interface_class: FemtetInterface
2
- interface_kwargs:
3
- femprj_path: C:\日本語ファイル.femprj
4
- optimizer_class: OptunaOptimizer
5
- optimizer_kwargs:
6
- sampler_class: TPESampler
7
- sampler_kwargs:
8
- n_startup_trials: 10
9
- femopt_kwargs:
10
- history_path: sample.csv
11
- optimize_kwargs:
12
- n_trials: 15
13
- confirm_before_exit: False
14
- seed: null