Skip to content

Commit 2f68d5a

Browse files
committed
Possibility to evaluate external functions in optimization scripts
1 parent 524183c commit 2f68d5a

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

HopsanGUI/OptimizationHandler.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -688,14 +688,19 @@ bool OptimizationHandler::evaluateCandidate(int idx)
688688
mEvalId = idx;
689689
mpHcomHandler->setModelPtr(mModelPtrs.at(idx));
690690
mpHcomHandler->executeCommand("opt set evalid "+QString::number(idx));
691-
mpHcomHandler->executeCommand("call setpars");
692691

693-
bool simOK=false;
694-
simOK = mModelPtrs.at(idx)->simulate_blocking();
692+
if(mpHcomHandler->hasFunction("evalexternal")) {
693+
mpHcomHandler->executeCommand("call evalexternal");
694+
}
695+
else {
696+
mpHcomHandler->executeCommand("call setpars");
697+
bool simOK=false;
698+
simOK = mModelPtrs.at(idx)->simulate_blocking();
695699

696-
if (!simOK)
697-
{
698-
return false;
700+
if (!simOK)
701+
{
702+
return false;
703+
}
699704
}
700705

701706
mpHcomHandler->executeCommand("opt set evalid "+QString::number(idx));

0 commit comments

Comments
 (0)