Skip to content

Commit 93160a4

Browse files
committed
Improve docstring for optimize()
1 parent 7153f98 commit 93160a4

1 file changed

Lines changed: 26 additions & 7 deletions

File tree

OMPython/ModelicaSystem.py

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,13 +1307,32 @@ def convertFmu2Mo(self, fmuName): # 20
13071307

13081308
return fileName
13091309

1310-
# to optimize model
1311-
def optimize(self): # 21
1312-
"""
1313-
This method optimizes model according to the optimized options. It can be called:
1314-
only without any arguments
1315-
usage
1316-
>>> optimize()
1310+
def optimize(self) -> dict[str, Any]:
1311+
"""Perform model-based optimization.
1312+
1313+
Optimization options set by setOptimizationOptions() are used.
1314+
1315+
Returns:
1316+
A dict with various values is returned. One of these values is the
1317+
path to the result file.
1318+
1319+
Examples:
1320+
>>> mod.optimize()
1321+
{'messages': 'LOG_SUCCESS | info | The initialization finished successfully without homotopy method. ...'
1322+
'resultFile': '/tmp/tmp68guvjhs/BangBang2021_res.mat',
1323+
'simulationOptions': 'startTime = 0.0, stopTime = 1.0, numberOfIntervals = '
1324+
"1000, tolerance = 1e-8, method = 'optimization', "
1325+
"fileNamePrefix = 'BangBang2021', options = '', "
1326+
"outputFormat = 'mat', variableFilter = '.*', cflags = "
1327+
"'', simflags = '-s=\\'optimization\\' "
1328+
"-optimizerNP=\\'1\\''",
1329+
'timeBackend': 0.008684897,
1330+
'timeCompile': 0.7546678929999999,
1331+
'timeFrontend': 0.045438053000000006,
1332+
'timeSimCode': 0.0018537170000000002,
1333+
'timeSimulation': 0.266354356,
1334+
'timeTemplates': 0.002007785,
1335+
'timeTotal': 1.079097854}
13171336
"""
13181337
cName = self._modelName
13191338
properties = ','.join(f"{key}={val}" for key, val in self._optimizeOptions.items())

0 commit comments

Comments
 (0)