pyfemtet 0.4.12__py3-none-any.whl → 0.4.13__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 +1 -1
- pyfemtet/opt/_femopt_core.py +6 -3
- pyfemtet/opt/femprj_sample/ParametricIF - True.femprj +0 -0
- pyfemtet/opt/femprj_sample/ParametricIF.femprj +0 -0
- pyfemtet/opt/femprj_sample/ParametricIF.py +31 -0
- pyfemtet/opt/femprj_sample/ParametricIF_test_result.reccsv +13 -0
- pyfemtet/opt/femprj_sample_jp/ParametricIF_jp.femprj +0 -0
- pyfemtet/opt/femprj_sample_jp/ParametricIF_jp.py +31 -0
- pyfemtet/opt/interface/_femtet.py +4 -2
- pyfemtet/opt/interface/_femtet_parametric.py +7 -2
- {pyfemtet-0.4.12.dist-info → pyfemtet-0.4.13.dist-info}/METADATA +1 -1
- {pyfemtet-0.4.12.dist-info → pyfemtet-0.4.13.dist-info}/RECORD +15 -9
- {pyfemtet-0.4.12.dist-info → pyfemtet-0.4.13.dist-info}/LICENSE +0 -0
- {pyfemtet-0.4.12.dist-info → pyfemtet-0.4.13.dist-info}/WHEEL +0 -0
- {pyfemtet-0.4.12.dist-info → pyfemtet-0.4.13.dist-info}/entry_points.txt +0 -0
pyfemtet/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.4.
|
|
1
|
+
__version__ = "0.4.13"
|
pyfemtet/opt/_femopt_core.py
CHANGED
|
@@ -240,7 +240,7 @@ class Objective(Function):
|
|
|
240
240
|
|
|
241
241
|
default_name = 'obj'
|
|
242
242
|
|
|
243
|
-
def __init__(self, fun, name, direction, args, kwargs):
|
|
243
|
+
def __init__(self, fun, name, direction, args, kwargs, with_symlog=False):
|
|
244
244
|
"""Initializes an Objective instance.
|
|
245
245
|
|
|
246
246
|
Args:
|
|
@@ -261,6 +261,7 @@ class Objective(Function):
|
|
|
261
261
|
"""
|
|
262
262
|
self._check_direction(direction)
|
|
263
263
|
self.direction = direction
|
|
264
|
+
self.with_symlog = with_symlog
|
|
264
265
|
super().__init__(fun, name, args, kwargs)
|
|
265
266
|
|
|
266
267
|
def convert(self, value: float):
|
|
@@ -290,11 +291,13 @@ class Objective(Function):
|
|
|
290
291
|
elif self.direction == 'maximize':
|
|
291
292
|
ret = -value
|
|
292
293
|
|
|
293
|
-
|
|
294
|
+
if self.with_symlog:
|
|
295
|
+
ret = symlog(ret)
|
|
294
296
|
|
|
295
297
|
return float(ret)
|
|
296
298
|
|
|
297
|
-
|
|
299
|
+
@staticmethod
|
|
300
|
+
def _check_direction(direction):
|
|
298
301
|
message = '評価関数の direction は "minimize", "maximize", 又は数値でなければなりません.'
|
|
299
302
|
message += f'与えられた値は {direction} です.'
|
|
300
303
|
if isinstance(direction, float) or isinstance(direction, int):
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from pyfemtet.opt import FemtetInterface, FEMOpt, AbstractOptimizer
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def ex_in(_, opt: AbstractOptimizer):
|
|
5
|
+
ex_r, in_r = opt.get_parameter('values')
|
|
6
|
+
return ex_r - in_r
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
if __name__ == '__main__':
|
|
11
|
+
|
|
12
|
+
fem = FemtetInterface(
|
|
13
|
+
parametric_output_indexes_use_as_objective={
|
|
14
|
+
0: "minimize",
|
|
15
|
+
1: "minimize",
|
|
16
|
+
2: "minimize",
|
|
17
|
+
},
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
femopt = FEMOpt(fem=fem)
|
|
21
|
+
|
|
22
|
+
femopt.add_parameter("external_radius", 10, 1, 10)
|
|
23
|
+
femopt.add_parameter("internal_radius", 5, 1, 10)
|
|
24
|
+
femopt.add_constraint(ex_in, lower_bound=1, strict=True, args=(femopt.opt,))
|
|
25
|
+
femopt.set_random_seed(42)
|
|
26
|
+
femopt.optimize(
|
|
27
|
+
n_trials=10,
|
|
28
|
+
n_parallel=1,
|
|
29
|
+
)
|
|
30
|
+
input() # required to tests script
|
|
31
|
+
femopt.terminate_all()
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"{""femprj_path"": null, ""model_name"": ""test_5""}",prm,prm,obj,obj_direction,obj,obj_direction,obj,obj_direction,,cns,cns_lb,cns_ub,,,,
|
|
2
|
+
,,,,,,,,,,,,,,,,
|
|
3
|
+
trial,external_radius,internal_radius,����[Kg] / Cylinder,����[Kg] / Cylinder_direction,����[Pa] / �~�[�[�X�̑������� / �ő�l / Cylinder,����[Pa] / �~�[�[�X�̑������� / �ő�l / Cylinder_direction,�ψ�[m] / �傫�� / �ő�l / Cylinder,�ψ�[m] / �傫�� / �ő�l / Cylinder_direction,non_domi,cns_0,cns_0_lower_bound,cns_0_upper_bound,feasible,hypervolume,message,time
|
|
4
|
+
1,10.0,5.0,0.08025126265847096,minimize,699391.2725838805,minimize,3.5987514289319256e-07,minimize,True,5.0,1,,True,0.0,initial,2024-07-22 10:24:17.069700
|
|
5
|
+
2,7.587945476302646,6.387926357773329,0.018829523087730202,minimize,2819410.535505582,minimize,1.963363626126861e-06,minimize,True,1.2000191185293163,1,,True,0.007260964524591699,,2024-07-22 10:24:27.705655
|
|
6
|
+
3,8.491983767203795,2.9110519961044856,0.06578893373109447,minimize,1058372.3464237931,minimize,6.396966638619928e-07,minimize,True,5.580931771099309,1,,True,0.13523811540217548,,2024-07-22 10:24:39.393305
|
|
7
|
+
4,9.488999089406718,1.053974646602355,0.09344346108490897,minimize,738819.436439415,minimize,3.9190983806914676e-07,minimize,False,8.435024442804362,1,,True,0.13523811540217548,,2024-07-22 10:24:50.756940
|
|
8
|
+
5,9.838880436025262,4.121658022659597,0.08482642054771264,minimize,701388.4079328978,minimize,3.6449256002795423e-07,minimize,False,5.717222413365665,1,,True,0.13523811540217548,,2024-07-22 10:25:01.226665
|
|
9
|
+
6,8.455917394686129,4.306340483879064,0.055191055245607905,minimize,1170551.8035054468,minimize,7.014254816528714e-07,minimize,True,4.149576910807064,1,,True,0.23270317407275296,,2024-07-22 10:25:11.971368
|
|
10
|
+
7,7.5733020568630876,4.532076028923693,0.038663363226300325,minimize,1680507.6211177334,minimize,1.1514101726343067e-06,minimize,True,3.041226027939395,1,,True,0.298888903032948,,2024-07-22 10:25:22.041491
|
|
11
|
+
8,6.64195280415911,4.3268559224164935,0.02513863374590192,minimize,2992920.1148875966,minimize,2.210659795360814e-06,minimize,False,2.3150968817426163,1,,True,0.298888903032948,,2024-07-22 10:25:32.810507
|
|
12
|
+
9,5.457560349207987,3.6301461895178777,0.016440094818037845,minimize,5824575.229249716,minimize,4.8047762082829075e-06,minimize,False,1.8274141596901092,1,,True,0.298888903032948,,2024-07-22 10:25:44.827040
|
|
13
|
+
10,7.075956010136126,6.0727177168143935,0.013058674177275532,minimize,4421271.285800073,minimize,3.2060909568366592e-06,minimize,True,1.0032382933217328,1,,True,0.3600967952288273,,2024-07-22 10:25:55.442006
|
|
Binary file
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from pyfemtet.opt import FemtetInterface, FEMOpt, AbstractOptimizer
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def ex_in(_, opt: AbstractOptimizer):
|
|
5
|
+
ex_r, in_r = opt.get_parameter('values')
|
|
6
|
+
return ex_r - in_r
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
if __name__ == '__main__':
|
|
11
|
+
|
|
12
|
+
fem = FemtetInterface(
|
|
13
|
+
parametric_output_indexes_use_as_objective={
|
|
14
|
+
0: "minimize",
|
|
15
|
+
1: "minimize",
|
|
16
|
+
2: "minimize",
|
|
17
|
+
},
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
femopt = FEMOpt(fem=fem)
|
|
21
|
+
|
|
22
|
+
femopt.add_parameter("external_radius", 10, 1, 10)
|
|
23
|
+
femopt.add_parameter("internal_radius", 5, 1, 10)
|
|
24
|
+
femopt.add_constraint(ex_in, lower_bound=1, strict=True, args=(femopt.opt,))
|
|
25
|
+
femopt.set_random_seed(42)
|
|
26
|
+
femopt.optimize(
|
|
27
|
+
n_trials=10,
|
|
28
|
+
n_parallel=1,
|
|
29
|
+
)
|
|
30
|
+
input('enter to quit') # required to tests script
|
|
31
|
+
femopt.terminate_all()
|
|
@@ -292,9 +292,11 @@ class FemtetInterface(FEMInterface):
|
|
|
292
292
|
try:
|
|
293
293
|
# 解析結果を開いた状態で Gaudi.Activate して ReExecute する場合、ReExecute の前後にアクティブ化イベントが必要
|
|
294
294
|
if fun.__name__ == 'ReExecute':
|
|
295
|
-
|
|
295
|
+
if self.open_result_with_gui or self.parametric_output_indexes_use_as_objective:
|
|
296
|
+
post_activate_message(self.Femtet.hWnd) # can raise pywintypes.error
|
|
296
297
|
returns = fun(*args, **kwargs)
|
|
297
|
-
|
|
298
|
+
if self.open_result_with_gui or self.parametric_output_indexes_use_as_objective:
|
|
299
|
+
post_activate_message(self.Femtet.hWnd)
|
|
298
300
|
else:
|
|
299
301
|
returns = fun(*args, **kwargs)
|
|
300
302
|
except (com_error, error):
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from femtetutils import util, logger
|
|
2
4
|
from pyfemtet.dispatch_extensions import _get_pid
|
|
3
5
|
|
|
4
6
|
import ctypes
|
|
5
7
|
|
|
6
8
|
|
|
9
|
+
logger.setLevel(logging.ERROR)
|
|
10
|
+
|
|
11
|
+
|
|
7
12
|
def _get_dll():
|
|
8
13
|
femtet_exe_path = util.get_femtet_exe_path()
|
|
9
14
|
dll_path = femtet_exe_path.replace('Femtet.exe', 'ParametricIF.dll')
|
|
@@ -11,7 +16,7 @@ def _get_dll():
|
|
|
11
16
|
|
|
12
17
|
|
|
13
18
|
def _get_dll_with_set_femtet(Femtet):
|
|
14
|
-
dll = _get_dll(
|
|
19
|
+
dll = _get_dll()
|
|
15
20
|
pid = _get_pid(Femtet.hWnd)
|
|
16
21
|
dll.SetCurrentFemtet.restype = ctypes.c_bool
|
|
17
22
|
dll.SetCurrentFemtet(pid)
|
|
@@ -12,14 +12,18 @@ pyfemtet/FemtetPJTSample/her_ex40_parametric.py,sha256=B5PQoh71Q3KN2CyLU1gP_Yh9g
|
|
|
12
12
|
pyfemtet/FemtetPJTSample/wat_ex14_parallel_parametric.py,sha256=UfhJffuXyhzdIWNpOrpV6xLTK1fuVvgyhlyg4Rp-628,2148
|
|
13
13
|
pyfemtet/FemtetPJTSample/wat_ex14_parametric.femprj,sha256=pxacKe0NPNUPAcxqo2cATFApsMKiVt2g2e_FOk4fpjA,172895
|
|
14
14
|
pyfemtet/FemtetPJTSample/wat_ex14_parametric.py,sha256=LGbWxCek0Ad2YrDCKykiQkE3aIypM4g8P3mLd_2anEE,2052
|
|
15
|
-
pyfemtet/__init__.py,sha256=
|
|
15
|
+
pyfemtet/__init__.py,sha256=Sx2UQ-dvjuvIuCjLDBYprq3tkBTzlrMLi4DXjCFHYVI,22
|
|
16
16
|
pyfemtet/_test_util.py,sha256=VLRyeLrBbaZ-tBoncyiR9-1BgT5N91SPR8u1j0AI6dU,4445
|
|
17
17
|
pyfemtet/core.py,sha256=3lqfBGJ5IuKz2Nqj5pRo7YQqKwx_0ZDL72u95Ur_1p0,1386
|
|
18
18
|
pyfemtet/dispatch_extensions.py,sha256=MhWiUXVt2Cq8vDeajMK4SrajjiAmb4m2fK8gXwHLrWA,16177
|
|
19
19
|
pyfemtet/logger.py,sha256=JYD0FvzijMS2NvZN7VT7vZA5hqtHEkvS93AHlIMDePw,2507
|
|
20
20
|
pyfemtet/opt/__init__.py,sha256=AJc1_d0sQ2_X4h_8FOcdmHvSPrFV_vfxlRrZTsqDZuE,612
|
|
21
21
|
pyfemtet/opt/_femopt.py,sha256=NdqXbeH81AHnMpuq1PFKD3Bo1FTfYVji5H2kyUQR6xI,23693
|
|
22
|
-
pyfemtet/opt/_femopt_core.py,sha256=
|
|
22
|
+
pyfemtet/opt/_femopt_core.py,sha256=R7n5CouGKcxpciOI2nCGpntlpgBizQqv4VF0OsFAriE,25593
|
|
23
|
+
pyfemtet/opt/femprj_sample/ParametricIF - True.femprj,sha256=tCd29CUXmyJ0VH6cV0xTdjQMLBPkCk0UrFwvRbyrcYA,431415
|
|
24
|
+
pyfemtet/opt/femprj_sample/ParametricIF.femprj,sha256=9BtDHmc3cdom0Zq33DTdZ0mDAsIUY6i8SRkkg-n7GO0,442090
|
|
25
|
+
pyfemtet/opt/femprj_sample/ParametricIF.py,sha256=yzFmG0041RMOBc1qQW46st5uMrplSf25JCbYUADvM3k,774
|
|
26
|
+
pyfemtet/opt/femprj_sample/ParametricIF_test_result.reccsv,sha256=74yY33DtyQ5ogVGP8-iuL7lqV-h1S6UAc_s_MOLHlgo,2534
|
|
23
27
|
pyfemtet/opt/femprj_sample/cad_ex01_NX.femprj,sha256=KC8JlHqHzqgyKriK911QSnQByQpRlw-SX5OSQ_GNe5M,149193
|
|
24
28
|
pyfemtet/opt/femprj_sample/cad_ex01_NX.prt,sha256=3okHLeMdslrRA_wkhppZtxIe-2-ZPMfNqWCdQwUV31o,226626
|
|
25
29
|
pyfemtet/opt/femprj_sample/cad_ex01_NX.py,sha256=TmM8wQ5CuesS8-QWlQNwykoAJWaPxUfNjqjx7xhDqz8,4892
|
|
@@ -45,6 +49,8 @@ pyfemtet/opt/femprj_sample/wat_ex14_parametric.femprj,sha256=F-yu2dGrsbrIA1Lhizu
|
|
|
45
49
|
pyfemtet/opt/femprj_sample/wat_ex14_parametric.py,sha256=o_LeUpo779a8vCBjxqS6NNF5zS7ID4mBfFjHsYvI1vs,2484
|
|
46
50
|
pyfemtet/opt/femprj_sample/wat_ex14_parametric_parallel.py,sha256=_kZVa4zSxY9UAa_CA1V_tFeTpjf4F8BHAJpYLZzF-r4,2560
|
|
47
51
|
pyfemtet/opt/femprj_sample/wat_ex14_parametric_test_result.reccsv,sha256=92IkN7HdHBatyacO6aU3MVhOG6rkXlodlw34oF91BSM,3056
|
|
52
|
+
pyfemtet/opt/femprj_sample_jp/ParametricIF_jp.femprj,sha256=9BtDHmc3cdom0Zq33DTdZ0mDAsIUY6i8SRkkg-n7GO0,442090
|
|
53
|
+
pyfemtet/opt/femprj_sample_jp/ParametricIF_jp.py,sha256=gv8RFRsTld1c5wCE0cfvc_lCj4gIFAl4LuBh9iWe_6k,789
|
|
48
54
|
pyfemtet/opt/femprj_sample_jp/cad_ex01_NX_jp.femprj,sha256=0RBhOGhtiFAp0QSCTBYEaDY9EZymn9hJYchAOJ6PaBA,143533
|
|
49
55
|
pyfemtet/opt/femprj_sample_jp/cad_ex01_NX_jp.py,sha256=sqhOskvRn84e1xET5rTfvbu5WG0kXvLoNfdAJ3e_XqA,5205
|
|
50
56
|
pyfemtet/opt/femprj_sample_jp/cad_ex01_SW_jp.femprj,sha256=ZZhT9XjB9Xu9YwHWv4gbvKBiUWlOFKEoHjAcGWb3vvQ,128026
|
|
@@ -63,8 +69,8 @@ pyfemtet/opt/femprj_sample_jp/wat_ex14_parametric_jp.py,sha256=W30jobW1eEYuAsJJR
|
|
|
63
69
|
pyfemtet/opt/femprj_sample_jp/wat_ex14_parametric_parallel_jp.py,sha256=ul2JUwlM5jfjNRELHkT7ZDuyMOq5RAHO32vAweEhCwg,2641
|
|
64
70
|
pyfemtet/opt/interface/__init__.py,sha256=qz5BszPuU3jZIoDnPjkPDAgvgHLlx1sYhuqh5ID798k,480
|
|
65
71
|
pyfemtet/opt/interface/_base.py,sha256=I4pJttLeRW-6WWMuCNynwxWPwriiGZk20vHLVcfixZY,2332
|
|
66
|
-
pyfemtet/opt/interface/_femtet.py,sha256=
|
|
67
|
-
pyfemtet/opt/interface/_femtet_parametric.py,sha256=
|
|
72
|
+
pyfemtet/opt/interface/_femtet.py,sha256=uNAm_dnv0Y5AvCf1QSLeAJ7Dwp1hHwVgLbcadtuZG5w,34397
|
|
73
|
+
pyfemtet/opt/interface/_femtet_parametric.py,sha256=KDG8SB43AgwuhpCStjvx10G0RzyHhga6k4dfvp0gvYU,2175
|
|
68
74
|
pyfemtet/opt/interface/_femtet_with_nx/__init__.py,sha256=-6W2g2FDEcKzGHmI5KAKQe-4U5jDpMj0CXuma-GZca0,83
|
|
69
75
|
pyfemtet/opt/interface/_femtet_with_nx/_interface.py,sha256=8ZvD6ajNmKUqXPkDsGJ4tOHrQOYwWBlO9OSPaCO3ml0,5666
|
|
70
76
|
pyfemtet/opt/interface/_femtet_with_nx/update_model.py,sha256=uFf_SU96_BYUmLBBR5w3NS3WqXvEvSbOoxVnz9FA3Ug,3187
|
|
@@ -131,8 +137,8 @@ pyfemtet/opt/visualization/wrapped_components/dbc.py,sha256=wzR1ZMOb4uwPNTMFn5up
|
|
|
131
137
|
pyfemtet/opt/visualization/wrapped_components/dcc.py,sha256=hcW7SR6VIMn4S4-JMyohvOzdc0Aw8A4chIeHqQEUbFU,17499
|
|
132
138
|
pyfemtet/opt/visualization/wrapped_components/html.py,sha256=sE2XHTDY1GvA1NW7y6SKWf-WglVXFKKvXhU9h3z53_g,95652
|
|
133
139
|
pyfemtet/opt/visualization/wrapped_components/str_enum.py,sha256=NZqbh2jNEAckvJyZv__MWeRs2F2Q-dkJCWo30rU2rrM,1383
|
|
134
|
-
pyfemtet-0.4.
|
|
135
|
-
pyfemtet-0.4.
|
|
136
|
-
pyfemtet-0.4.
|
|
137
|
-
pyfemtet-0.4.
|
|
138
|
-
pyfemtet-0.4.
|
|
140
|
+
pyfemtet-0.4.13.dist-info/LICENSE,sha256=sVQBhyoglGJUu65-BP3iR6ujORI6YgEU2Qm-V4fGlOA,1485
|
|
141
|
+
pyfemtet-0.4.13.dist-info/METADATA,sha256=AfigIymGD1NAe_b9NDM9oncoAV-6J2fb0J1ZjNh5TBA,3382
|
|
142
|
+
pyfemtet-0.4.13.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
143
|
+
pyfemtet-0.4.13.dist-info/entry_points.txt,sha256=ZfYqRaoiPtuWqFi2_msccyrVF0LurMn-IHlYamAegZo,104
|
|
144
|
+
pyfemtet-0.4.13.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|