pyfemtet 0.4.20__py3-none-any.whl → 0.4.21__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.

@@ -8,7 +8,7 @@ msgid ""
8
8
  msgstr ""
9
9
  "Project-Id-Version: PROJECT VERSION\n"
10
10
  "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
11
- "POT-Creation-Date: 2024-07-23 15:23+0900\n"
11
+ "POT-Creation-Date: 2024-08-20 10:15+0900\n"
12
12
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -57,383 +57,391 @@ msgstr ""
57
57
  msgid "Optimization finished. Results were saved in following:"
58
58
  msgstr ""
59
59
 
60
- #: pyfemtet/message/messages.py:55
60
+ #: pyfemtet/message/messages.py:53
61
+ msgid "No bounds specified."
62
+ msgstr ""
63
+
64
+ #: pyfemtet/message/messages.py:54
65
+ msgid "The optimization is now complete. You can view the results on the monitor until you press Enter to exit the program."
66
+ msgstr ""
67
+
68
+ #: pyfemtet/message/messages.py:57
61
69
  msgid "\"%UGII_BASE_DIR%\\NXBIN\\run_journal.exe\" is not found. Make sure you have NX installed and the environment variable UGII_BASE_DIR is set."
62
70
  msgstr ""
63
71
 
64
- #: pyfemtet/message/messages.py:56
72
+ #: pyfemtet/message/messages.py:58
65
73
  msgid "Model reconstruction failed."
66
74
  msgstr ""
67
75
 
68
- #: pyfemtet/message/messages.py:57
76
+ #: pyfemtet/message/messages.py:59
69
77
  msgid "Model update failed."
70
78
  msgstr ""
71
79
 
72
- #: pyfemtet/message/messages.py:58
80
+ #: pyfemtet/message/messages.py:60
73
81
  msgid "It was detected that the configuration of Femtet python macro constants has not been completed. The configuration was done automatically (python -m win32com.client.makepy FemtetMacro). Please restart the program."
74
82
  msgstr ""
75
83
 
76
- #: pyfemtet/message/messages.py:59
84
+ #: pyfemtet/message/messages.py:61
77
85
  msgid "Failed to connect to Femtet."
78
86
  msgstr ""
79
87
 
80
- #: pyfemtet/message/messages.py:60
88
+ #: pyfemtet/message/messages.py:62
81
89
  msgid "The Femtet process crashed and could not be restarted successfully."
82
90
  msgstr ""
83
91
 
84
- #: pyfemtet/message/messages.py:61
92
+ #: pyfemtet/message/messages.py:63
85
93
  msgid "An abnormal termination of the Femtet process has been detected. Recovery will be attempted."
86
94
  msgstr ""
87
95
 
88
- #: pyfemtet/message/messages.py:62
96
+ #: pyfemtet/message/messages.py:64
89
97
  msgid "Femtet has been restarted and will perform analysis and attempt to recover."
90
98
  msgstr ""
91
99
 
92
- #: pyfemtet/message/messages.py:63
100
+ #: pyfemtet/message/messages.py:65
93
101
  msgid "If you specify 'new' as the 'connect_method' argument, set the 'femprj_path' argument to existing femprj file path."
94
102
  msgstr ""
95
103
 
96
- #: pyfemtet/message/messages.py:64
104
+ #: pyfemtet/message/messages.py:66
97
105
  msgid "The specified variable is not included in the Femtet analysis model. Note the capitalization of the variable."
98
106
  msgstr ""
99
107
 
100
- #: pyfemtet/message/messages.py:65
108
+ #: pyfemtet/message/messages.py:67
101
109
  msgid "The following APIs are not accessible: "
102
110
  msgstr ""
103
111
 
104
- #: pyfemtet/message/messages.py:66
112
+ #: pyfemtet/message/messages.py:68
105
113
  msgid "Macros may not be enabled in the installed version of Femtet. Please run the \"Enable Macros\" command from the start menu with administrator privileges in the same version of Femtet that is installed."
106
114
  msgstr ""
107
115
 
108
- #: pyfemtet/message/messages.py:67
116
+ #: pyfemtet/message/messages.py:69
109
117
  msgid "No analysis model is open"
110
118
  msgstr ""
111
119
 
112
- #: pyfemtet/message/messages.py:68
120
+ #: pyfemtet/message/messages.py:70
113
121
  msgid "The analysis model does not contain any variables."
114
122
  msgstr ""
115
123
 
116
- #: pyfemtet/message/messages.py:69
124
+ #: pyfemtet/message/messages.py:71
117
125
  msgid "Failed to update variables:"
118
126
  msgstr ""
119
127
 
120
- #: pyfemtet/message/messages.py:70
128
+ #: pyfemtet/message/messages.py:72
121
129
  msgid "The specified variable is not included in the analysis model and will be ignored."
122
130
  msgstr ""
123
131
 
124
- #: pyfemtet/message/messages.py:71
132
+ #: pyfemtet/message/messages.py:73
125
133
  msgid "Model history re-execute failed."
126
134
  msgstr ""
127
135
 
128
- #: pyfemtet/message/messages.py:72
136
+ #: pyfemtet/message/messages.py:74
129
137
  msgid "Model redraw failed."
130
138
  msgstr ""
131
139
 
132
- #: pyfemtet/message/messages.py:73
140
+ #: pyfemtet/message/messages.py:75
133
141
  msgid "Mesh generation failed"
134
142
  msgstr ""
135
143
 
136
- #: pyfemtet/message/messages.py:74
144
+ #: pyfemtet/message/messages.py:76
137
145
  msgid "Parametric solve failed"
138
146
  msgstr ""
139
147
 
140
- #: pyfemtet/message/messages.py:75
148
+ #: pyfemtet/message/messages.py:77
141
149
  msgid "Solve failed."
142
150
  msgstr ""
143
151
 
144
- #: pyfemtet/message/messages.py:76
152
+ #: pyfemtet/message/messages.py:78
145
153
  msgid "Open result failed."
146
154
  msgstr ""
147
155
 
148
- #: pyfemtet/message/messages.py:77
156
+ #: pyfemtet/message/messages.py:79
149
157
  msgid "Failed to close Femtet."
150
158
  msgstr ""
151
159
 
152
- #: pyfemtet/message/messages.py:78
160
+ #: pyfemtet/message/messages.py:80
153
161
  msgid "Failed to save result (.pdt) file."
154
162
  msgstr ""
155
163
 
156
- #: pyfemtet/message/messages.py:79
164
+ #: pyfemtet/message/messages.py:81
157
165
  msgid "Failed to save screenshot (.jpg)."
158
166
  msgstr ""
159
167
 
160
- #: pyfemtet/message/messages.py:80
168
+ #: pyfemtet/message/messages.py:82
161
169
  msgid "Screenshot (.jpg) is not found."
162
170
  msgstr ""
163
171
 
164
- #: pyfemtet/message/messages.py:81
172
+ #: pyfemtet/message/messages.py:83
165
173
  msgid "Failed to update model in solidworks."
166
174
  msgstr ""
167
175
 
168
- #: pyfemtet/message/messages.py:84
176
+ #: pyfemtet/message/messages.py:86
169
177
  msgid "The following features are not supported by the specified optimization method. "
170
178
  msgstr ""
171
179
 
172
- #: pyfemtet/message/messages.py:85
180
+ #: pyfemtet/message/messages.py:87
173
181
  msgid "The parameter set does not match the one added with add_init_parameter."
174
182
  msgstr ""
175
183
 
176
- #: pyfemtet/message/messages.py:86
184
+ #: pyfemtet/message/messages.py:88
177
185
  msgid "An exception has occurred during FEM update. Current parameters are: "
178
186
  msgstr ""
179
187
 
180
- #: pyfemtet/message/messages.py:87
188
+ #: pyfemtet/message/messages.py:89
181
189
  msgid "The constraints were not satisfied for the following sets of variables:"
182
190
  msgstr ""
183
191
 
184
- #: pyfemtet/message/messages.py:88
192
+ #: pyfemtet/message/messages.py:90
185
193
  msgid "Current parameter set cannot update FEM and this optimization method cannot skip current parameter set. The optimization process will be terminated."
186
194
  msgstr ""
187
195
 
188
- #: pyfemtet/message/messages.py:89
196
+ #: pyfemtet/message/messages.py:91
189
197
  msgid "Optimization has been interrupted. Note that you cannot acquire the OptimizationResult in case of `trust-constr`, `TNC`, `SLSQP` or `COBYLA`."
190
198
  msgstr ""
191
199
 
192
- #: pyfemtet/message/messages.py:93
200
+ #: pyfemtet/message/messages.py:95
193
201
  msgid "Connect to Femtet"
194
202
  msgstr ""
195
203
 
196
- #: pyfemtet/message/messages.py:94
204
+ #: pyfemtet/message/messages.py:96
197
205
  msgid "Analysis model name described in csv does not exist in project."
198
206
  msgstr ""
199
207
 
200
- #: pyfemtet/message/messages.py:95
208
+ #: pyfemtet/message/messages.py:97
201
209
  msgid "History csv is not read yet. Open your project manually."
202
210
  msgstr ""
203
211
 
204
- #: pyfemtet/message/messages.py:96
212
+ #: pyfemtet/message/messages.py:98
205
213
  msgid "Cannot read project data from csv. Open your project manually."
206
214
  msgstr ""
207
215
 
208
- #: pyfemtet/message/messages.py:97
216
+ #: pyfemtet/message/messages.py:99
209
217
  msgid ".femprj file described in csv is not found. Open your project manually."
210
218
  msgstr ""
211
219
 
212
- #: pyfemtet/message/messages.py:98
220
+ #: pyfemtet/message/messages.py:100
213
221
  msgid "Analysis model name is not specified. Open your model in the project manually."
214
222
  msgstr ""
215
223
 
216
- #: pyfemtet/message/messages.py:100
224
+ #: pyfemtet/message/messages.py:102
217
225
  msgid "Constraint"
218
226
  msgstr ""
219
227
 
220
- #: pyfemtet/message/messages.py:101
228
+ #: pyfemtet/message/messages.py:103
221
229
  msgid "feasible"
222
230
  msgstr ""
223
231
 
224
- #: pyfemtet/message/messages.py:102
232
+ #: pyfemtet/message/messages.py:104
225
233
  msgid "infeasible"
226
234
  msgstr ""
227
235
 
228
- #: pyfemtet/message/messages.py:103
236
+ #: pyfemtet/message/messages.py:105
229
237
  msgid "Optimality"
230
238
  msgstr ""
231
239
 
232
- #: pyfemtet/message/messages.py:104
240
+ #: pyfemtet/message/messages.py:106
233
241
  msgid "non dominated"
234
242
  msgstr ""
235
243
 
236
- #: pyfemtet/message/messages.py:105
244
+ #: pyfemtet/message/messages.py:107
237
245
  msgid "dominated"
238
246
  msgstr ""
239
247
 
240
- #: pyfemtet/message/messages.py:106
248
+ #: pyfemtet/message/messages.py:108
241
249
  msgid "Hypervolume Plot"
242
250
  msgstr ""
243
251
 
244
- #: pyfemtet/message/messages.py:107
252
+ #: pyfemtet/message/messages.py:109
245
253
  msgid "Objective Plot"
246
254
  msgstr ""
247
255
 
248
- #: pyfemtet/message/messages.py:108
256
+ #: pyfemtet/message/messages.py:110
249
257
  msgid "Multi Objective Pair Plot"
250
258
  msgstr ""
251
259
 
252
- #: pyfemtet/message/messages.py:109
260
+ #: pyfemtet/message/messages.py:111
253
261
  msgid "trial number"
254
262
  msgstr ""
255
263
 
256
- #: pyfemtet/message/messages.py:111
264
+ #: pyfemtet/message/messages.py:113
257
265
  msgid "Objectives"
258
266
  msgstr ""
259
267
 
260
- #: pyfemtet/message/messages.py:113
268
+ #: pyfemtet/message/messages.py:115
261
269
  msgid "Prediction Model"
262
270
  msgstr ""
263
271
 
264
- #: pyfemtet/message/messages.py:114
272
+ #: pyfemtet/message/messages.py:116
265
273
  msgid " Recalculate Model"
266
274
  msgstr ""
267
275
 
268
- #: pyfemtet/message/messages.py:115
276
+ #: pyfemtet/message/messages.py:117
269
277
  msgid " Redraw graph"
270
278
  msgstr ""
271
279
 
272
- #: pyfemtet/message/messages.py:116
280
+ #: pyfemtet/message/messages.py:118
273
281
  msgid "Parameter"
274
282
  msgstr ""
275
283
 
276
- #: pyfemtet/message/messages.py:117
284
+ #: pyfemtet/message/messages.py:119
277
285
  msgid "Parameter2"
278
286
  msgstr ""
279
287
 
280
- #: pyfemtet/message/messages.py:118
288
+ #: pyfemtet/message/messages.py:120
281
289
  msgid "Objective"
282
290
  msgstr ""
283
291
 
284
- #: pyfemtet/message/messages.py:119
292
+ #: pyfemtet/message/messages.py:121
285
293
  msgid "No history selected."
286
294
  msgstr ""
287
295
 
288
- #: pyfemtet/message/messages.py:120
296
+ #: pyfemtet/message/messages.py:122
289
297
  msgid "No FEM result (yet)."
290
298
  msgstr ""
291
299
 
292
- #: pyfemtet/message/messages.py:121
300
+ #: pyfemtet/message/messages.py:123
293
301
  msgid "Prediction model is not calculated yet."
294
302
  msgstr ""
295
303
 
296
- #: pyfemtet/message/messages.py:122
304
+ #: pyfemtet/message/messages.py:124
297
305
  msgid "Cannot select same parameter"
298
306
  msgstr ""
299
307
 
300
- #: pyfemtet/message/messages.py:124
308
+ #: pyfemtet/message/messages.py:126
301
309
  msgid "Prediction Model of Objective"
302
310
  msgstr ""
303
311
 
304
- #: pyfemtet/message/messages.py:125
312
+ #: pyfemtet/message/messages.py:127
305
313
  msgid "prediction model"
306
314
  msgstr ""
307
315
 
308
- #: pyfemtet/message/messages.py:126
316
+ #: pyfemtet/message/messages.py:128
309
317
  msgid "std. dev. of model"
310
318
  msgstr ""
311
319
 
312
- #: pyfemtet/message/messages.py:128
320
+ #: pyfemtet/message/messages.py:130
313
321
  msgid "Progress"
314
322
  msgstr ""
315
323
 
316
- #: pyfemtet/message/messages.py:129
324
+ #: pyfemtet/message/messages.py:131
317
325
  msgid "Prediction"
318
326
  msgstr ""
319
327
 
320
- #: pyfemtet/message/messages.py:130
328
+ #: pyfemtet/message/messages.py:132
321
329
  msgid "Workers"
322
330
  msgstr ""
323
331
 
324
- #: pyfemtet/message/messages.py:132
332
+ #: pyfemtet/message/messages.py:134
325
333
  msgid "Optimization status will be shown here."
326
334
  msgstr ""
327
335
 
328
- #: pyfemtet/message/messages.py:133
336
+ #: pyfemtet/message/messages.py:135
329
337
  msgid "Auto-update graph"
330
338
  msgstr ""
331
339
 
332
- #: pyfemtet/message/messages.py:134
340
+ #: pyfemtet/message/messages.py:136
333
341
  msgid "Interrupt Optimization"
334
342
  msgstr ""
335
343
 
336
- #: pyfemtet/message/messages.py:136
344
+ #: pyfemtet/message/messages.py:138
337
345
  msgid "Result"
338
346
  msgstr ""
339
347
 
340
- #: pyfemtet/message/messages.py:138
348
+ #: pyfemtet/message/messages.py:140
341
349
  msgid "Open Result in Femtet"
342
350
  msgstr ""
343
351
 
344
- #: pyfemtet/message/messages.py:139
352
+ #: pyfemtet/message/messages.py:141
345
353
  msgid "Reconstruct Model"
346
354
  msgstr ""
347
355
 
348
- #: pyfemtet/message/messages.py:140
356
+ #: pyfemtet/message/messages.py:142
349
357
  msgid "Drag and drop or select csv file"
350
358
  msgstr ""
351
359
 
352
- #: pyfemtet/message/messages.py:141
360
+ #: pyfemtet/message/messages.py:143
353
361
  msgid "Connection to Femtet is not established. Launch Femtet and Open a project."
354
362
  msgstr ""
355
363
 
356
- #: pyfemtet/message/messages.py:142
364
+ #: pyfemtet/message/messages.py:144
357
365
  msgid "No result plot is selected."
358
366
  msgstr ""
359
367
 
360
- #: pyfemtet/message/messages.py:143
368
+ #: pyfemtet/message/messages.py:145
361
369
  msgid "The femprj file path in the history csv is not found or valid."
362
370
  msgstr ""
363
371
 
364
- #: pyfemtet/message/messages.py:144
372
+ #: pyfemtet/message/messages.py:146
365
373
  msgid "The model name in the history csv is not found."
366
374
  msgstr ""
367
375
 
368
- #: pyfemtet/message/messages.py:145
376
+ #: pyfemtet/message/messages.py:147
369
377
  msgid ".pdt file is not found. Please check the .Results folder. Note that .pdt file save mode depends on the `save_pdt` argument of FemtetInterface in optimization script(default to `all`)."
370
378
  msgstr ""
371
379
 
372
- #: pyfemtet/message/messages.py:150
380
+ #: pyfemtet/message/messages.py:152
373
381
  msgid "Failed to open "
374
382
  msgstr ""
375
383
 
376
- #: pyfemtet/message/messages.py:151
384
+ #: pyfemtet/message/messages.py:153
377
385
  msgid "Specified model is not in current project. Please check opened project. For example, not \"analysis model only\" but your .femprj file."
378
386
  msgstr ""
379
387
 
380
- #: pyfemtet/message/messages.py:154
388
+ #: pyfemtet/message/messages.py:156
381
389
  msgid ".femprj file path of the history csv is invalid. Please certify matching between csv and opening .femprj file."
382
390
  msgstr ""
383
391
 
384
- #: pyfemtet/message/messages.py:155
392
+ #: pyfemtet/message/messages.py:157
385
393
  msgid "Analysis model name of the history csv is invalid. Please certify matching between csv and opening analysis model."
386
394
  msgstr ""
387
395
 
388
- #: pyfemtet/message/messages.py:156
396
+ #: pyfemtet/message/messages.py:158
389
397
  msgid "Analysis model name of the history csv and opened in Femtet is inconsistent. Please certify matching between csv and opening analysis model."
390
398
  msgstr ""
391
399
 
392
- #: pyfemtet/message/messages.py:157
400
+ #: pyfemtet/message/messages.py:159
393
401
  msgid "tutorial mode"
394
402
  msgstr ""
395
403
 
396
- #: pyfemtet/message/messages.py:158
404
+ #: pyfemtet/message/messages.py:160
397
405
  msgid "Load Sample CSV"
398
406
  msgstr ""
399
407
 
400
- #: pyfemtet/message/messages.py:159
408
+ #: pyfemtet/message/messages.py:161
401
409
  msgid "Load CSV"
402
410
  msgstr ""
403
411
 
404
- #: pyfemtet/message/messages.py:160
412
+ #: pyfemtet/message/messages.py:162
405
413
  msgid "Open your optimization result. Then connecting to femtet will start automatically. Note that in tutorial mode, this button loads the ready-made sample csv and open sample femprj."
406
414
  msgstr ""
407
415
 
408
- #: pyfemtet/message/messages.py:162
416
+ #: pyfemtet/message/messages.py:164
409
417
  msgid "Main Graph"
410
418
  msgstr ""
411
419
 
412
- #: pyfemtet/message/messages.py:163
420
+ #: pyfemtet/message/messages.py:165
413
421
  msgid "Here the optimization history is shown. Each plot represents single FEM result. You can pick a result to open the corresponding result in Femtet. "
414
422
  msgstr ""
415
423
 
416
- #: pyfemtet/message/messages.py:166
424
+ #: pyfemtet/message/messages.py:168
417
425
  msgid "Open Result"
418
426
  msgstr ""
419
427
 
420
- #: pyfemtet/message/messages.py:167
428
+ #: pyfemtet/message/messages.py:169
421
429
  msgid "After pick a point in the main graph, This button shows the corresponding FEM result in Femtet."
422
430
  msgstr ""
423
431
 
424
- #: pyfemtet/message/messages.py:169
432
+ #: pyfemtet/message/messages.py:171
425
433
  msgid "Re-connect to Femtet."
426
434
  msgstr ""
427
435
 
428
- #: pyfemtet/message/messages.py:170
436
+ #: pyfemtet/message/messages.py:172
429
437
  msgid "Sample csv is not found. Please consider to re-install pyfemtet by `py -m pip install pyfemtet -U --force-reinstall`"
430
438
  msgstr ""
431
439
 
432
- #: pyfemtet/message/messages.py:171
440
+ #: pyfemtet/message/messages.py:173
433
441
  msgid "Sample femprj file is not found. Please consider to re-install pyfemtet by `py -m pip install pyfemtet -U --force-reinstall`"
434
442
  msgstr ""
435
443
 
436
- #: pyfemtet/message/messages.py:172
444
+ #: pyfemtet/message/messages.py:174
437
445
  msgid "Sample femprj result folder is not found. Please consider to re-install pyfemtet by `py -m pip install pyfemtet -U --force-reinstall`"
438
446
  msgstr ""
439
447
 
pyfemtet/opt/_femopt.py CHANGED
@@ -1,4 +1,5 @@
1
1
  # built-in
2
+ from typing import Optional, Any, Callable
2
3
  import os
3
4
  import datetime
4
5
  from time import time, sleep
@@ -24,6 +25,7 @@ from pyfemtet.opt._femopt_core import (
24
25
  logger,
25
26
  )
26
27
  from pyfemtet.message import Msg, encoding
28
+ from pyfemtet.opt.parameter import Parameter, Expression
27
29
 
28
30
 
29
31
  class FEMOpt:
@@ -109,7 +111,8 @@ class FEMOpt:
109
111
  lower_bound: float or None = None,
110
112
  upper_bound: float or None = None,
111
113
  step: float or None = None,
112
- memo: str = ''
114
+ properties: Optional[dict] = None,
115
+ pass_to_fem: Optional[bool] = True,
113
116
  ):
114
117
  """Adds a parameter to the optimization problem.
115
118
 
@@ -119,34 +122,63 @@ class FEMOpt:
119
122
  lower_bound (float or None, optional): The lower bound of the parameter. Defaults to None. However, this argument is required for some algorithms.
120
123
  upper_bound (float or None, optional): The upper bound of the parameter. Defaults to None. However, this argument is required for some algorithms.
121
124
  step (float or None, optional): The step of parameter. Defaults to None.
122
- memo (str, optional): Additional information about the parameter. Defaults to ''.
125
+ properties (dict, optional): Additional information about the parameter. Defaults to None.
126
+ pass_to_fem (bool, optional): If this variable is used directly in FEM model update or not. If False, this parameter can be just used as inpt of expressions. Defaults to True.
123
127
  Raises:
124
128
  ValueError: If initial_value is not specified and the value for the given name is also not specified.
125
129
 
126
130
  """
127
131
 
128
132
  _check_bound(lower_bound, upper_bound, name)
129
- value = self.fem.check_param_value(name)
130
- if initial_value is None:
131
- if value is not None:
132
- initial_value = value
133
- else:
134
- raise ValueError('initial_value を指定してください.')
135
133
 
136
- d = {
137
- 'name': name,
138
- 'value': float(initial_value),
139
- 'lb': float(lower_bound) if lower_bound is not None else None,
140
- 'ub': float(upper_bound) if upper_bound is not None else None,
141
- 'step': float(step) if step is not None else None,
142
- 'memo': memo,
143
- }
144
- pdf = pd.DataFrame(d, index=[0], dtype=object)
145
-
146
- if len(self.opt.parameters) == 0:
147
- self.opt.parameters = pdf
134
+ if pass_to_fem:
135
+ value = self.fem.check_param_value(name)
136
+ if initial_value is None:
137
+ if value is not None:
138
+ initial_value = value
139
+ else:
140
+ raise ValueError('initial_value を指定してください.')
148
141
  else:
149
- self.opt.parameters = pd.concat([self.opt.parameters, pdf], ignore_index=True)
142
+ if initial_value is None:
143
+ raise ValueError('initial_value を指定してください.')
144
+
145
+ prm = Parameter(
146
+ name=name,
147
+ value=float(initial_value),
148
+ lower_bound=float(lower_bound) if lower_bound is not None else None,
149
+ upper_bound=float(upper_bound) if upper_bound is not None else None,
150
+ step=float(step) if step is not None else None,
151
+ pass_to_fem=pass_to_fem,
152
+ properties=properties,
153
+ )
154
+ self.opt.variables.add_parameter(prm)
155
+
156
+ def add_expression(
157
+ self,
158
+ name: str,
159
+ fun: Callable[[Any], float],
160
+ properties=property,
161
+ kwargs: Optional[dict] = None,
162
+ pass_to_fem=True,
163
+ ):
164
+ """Add expression to the optimization problem.
165
+
166
+ Args:
167
+ name (str): The name of the variable.
168
+ fun (Callable[[Any], float]): An expression function. The arguments that you want to use as input variables must be the same with ``name`` of Variable objects added by ``add_parameter()`` or ``add_expression()``. If you use other objects as argument of the function, you must specify ``kwargs``.
169
+ properties ([type], optional): Property names and their values of the variable. Defaults to property.
170
+ kwargs (Optional[dict], optional): Remaining arguments of ``fun``. Defaults to None.
171
+ pass_to_fem (bool, optional): If this variable is used directly in FEM model update or not. If False, this variable can be just used as inpt of other expressions. Defaults to True.
172
+ """
173
+ exp = Expression(
174
+ name=name,
175
+ value=None,
176
+ properties=properties,
177
+ fun=fun,
178
+ kwargs=kwargs if kwargs else {},
179
+ pass_to_fem=pass_to_fem,
180
+ )
181
+ self.opt.variables.add_expression(exp)
150
182
 
151
183
  def add_objective(
152
184
  self,
@@ -250,20 +282,8 @@ class FEMOpt:
250
282
 
251
283
  self.opt.constraints[name] = Constraint(fun, name, lower_bound, upper_bound, strict, args, kwargs)
252
284
 
253
- def get_parameter(self, format='dict') -> pd.DataFrame or dict or np.ndarray:
254
- """Returns the parameter in a specified format.
255
-
256
- Args:
257
- format (str, optional): The desired output format. Defaults to 'dict'. Valid formats are 'values', 'df' and 'dict'.
258
-
259
- Returns:
260
- pd.DataFrame or dict or np.ndarray: The parameter data converted into the specified format.
261
-
262
- Raises:
263
- ValueError: If an invalid format is provided.
264
-
265
- """
266
- return self.opt.get_parameter(format)
285
+ def get_parameter(self, format='dict'):
286
+ raise DeprecationWarning('FEMOpt.get_parameter() was deprecated. Use Femopt.opt.get_parameter() instead.')
267
287
 
268
288
  def set_monitor_host(self, host=None, port=None):
269
289
  """Sets up the monitor server with the specified host and port.
@@ -338,8 +358,9 @@ class FEMOpt:
338
358
  self.opt.method_checker.check_seed()
339
359
 
340
360
  is_incomplete_bounds = False
341
- for _, row in self.opt.parameters.iterrows():
342
- lb, ub = row['lb'], row['ub']
361
+ prm: Parameter = None
362
+ for prm in self.opt.variables.parameters.values():
363
+ lb, ub = prm.lower_bound, prm.upper_bound
343
364
  is_incomplete_bounds = is_incomplete_bounds + (lb is None) + (ub is None)
344
365
  if is_incomplete_bounds:
345
366
  self.opt.method_checker.check_incomplete_bounds()
@@ -348,6 +369,10 @@ class FEMOpt:
348
369
  self.opt.n_trials = n_trials
349
370
  self.opt.timeout = timeout
350
371
 
372
+ # resolve expression dependencies
373
+ self.opt.variables.resolve()
374
+ self.opt.variables.evaluate()
375
+
351
376
  # クラスターの設定
352
377
  self.opt.is_cluster = self.scheduler_address is not None
353
378
  if self.opt.is_cluster:
@@ -427,7 +452,7 @@ class FEMOpt:
427
452
  self.status.set(OptimizationStatus.SETTING_UP)
428
453
  self.history = History(
429
454
  self.history_path,
430
- self.opt.parameters['name'].to_list(),
455
+ self.opt.variables.get_parameter_names(),
431
456
  list(self.opt.objectives.keys()),
432
457
  list(self.opt.constraints.keys()),
433
458
  self.client,
@@ -569,8 +569,8 @@ class History:
569
569
  # parameters
570
570
  for i, _row in parameters.iterrows():
571
571
  row.append(_row['value'])
572
- row.append(_row['lb'])
573
- row.append(_row['ub'])
572
+ row.append(_row['lower_bound'])
573
+ row.append(_row['upper_bound'])
574
574
 
575
575
  # objectives and their direction
576
576
  for (_, obj), obj_value in zip(objectives.items(), obj_values): # objectives, direction