diff --git a/src/api/libcellml/generatorprofile.h b/src/api/libcellml/generatorprofile.h index 12e14cc26..8608cc8d8 100644 --- a/src/api/libcellml/generatorprofile.h +++ b/src/api/libcellml/generatorprofile.h @@ -3266,10 +3266,13 @@ class LIBCELLML_EXPORT GeneratorProfile * * @param forDifferentialModel Whether the call to the find root method is * for a differential model, as opposed to an algebraic model. + * @param withExternalVariables Whether the call to the find root method is + * for a model with external variables. * * @return The @c std::string for the call to the find root method. */ - std::string findRootCallString(bool forDifferentialModel) const; + std::string findRootCallString(bool forDifferentialModel, + bool withExternalVariables) const; /** * @brief Set the @c std::string for the call to the find root method. @@ -3280,10 +3283,13 @@ class LIBCELLML_EXPORT GeneratorProfile * * @param forDifferentialModel Whether the call to the find root method is * for a differential model, as opposed to an algebraic model. + * @param withExternalVariables Whether the call to the find root method is + * for a model with external variables. * @param findRootCallString The @c std::string to use for the call to the * find root method. */ void setFindRootCallString(bool forDifferentialModel, + bool withExternalVariables, const std::string &findRootCallString); /** @@ -3293,10 +3299,13 @@ class LIBCELLML_EXPORT GeneratorProfile * * @param forDifferentialModel Whether the call to the find root method is * for a differential model, as opposed to an algebraic model. + * @param withExternalVariables Whether the call to the find root method is + * for a model with external variables. * * @return The @c std::string for the find root method. */ - std::string findRootMethodString(bool forDifferentialModel) const; + std::string findRootMethodString(bool forDifferentialModel, + bool withExternalVariables) const; /** * @brief Set the @c std::string for the find root method. @@ -3311,10 +3320,13 @@ class LIBCELLML_EXPORT GeneratorProfile * * @param forDifferentialModel Whether the call to the find root method is * for a differential model, as opposed to an algebraic model. + * @param withExternalVariables Whether the call to the find root method is + * for a model with external variables. * @param findRootMethodString The @c std::string to use for the find root * method. */ void setFindRootMethodString(bool forDifferentialModel, + bool withExternalVariables, const std::string &findRootMethodString); /** @@ -3324,10 +3336,13 @@ class LIBCELLML_EXPORT GeneratorProfile * * @param forDifferentialModel Whether the call to the NLA solve method is * for a differential model, as opposed to an algebraic model. + * @param withExternalVariables Whether the call to the NLA solve method is + * for a model with external variables. * * @return The @c std::string for the call to the NLA solve method. */ - std::string nlaSolveCallString(bool forDifferentialModel) const; + std::string nlaSolveCallString(bool forDifferentialModel, + bool withExternalVariables) const; /** * @brief Set the @c std::string for the call to the NLA solve method. @@ -3341,10 +3356,13 @@ class LIBCELLML_EXPORT GeneratorProfile * * @param forDifferentialModel Whether the call to the NLA solve method is * for a differential model, as opposed to an algebraic model. + * @param withExternalVariables Whether the call to the NLA solve method is + * for a model with external variables. * @param nlaSolveCallString The @c std::string to use for the call to the * NLA solve method. */ void setNlaSolveCallString(bool forDifferentialModel, + bool withExternalVariables, const std::string &nlaSolveCallString); /** @@ -3354,10 +3372,13 @@ class LIBCELLML_EXPORT GeneratorProfile * * @param forDifferentialModel Whether the call to the objective function * method is for a differential model, as opposed to an algebraic model. + * @param withExternalVariables Whether the call to the objective function + * method is for a model with external variables. * * @return The @c std::string for the objective function method. */ - std::string objectiveFunctionMethodString(bool forDifferentialModel) const; + std::string objectiveFunctionMethodString(bool forDifferentialModel, + bool withExternalVariables) const; /** * @brief Set the @c std::string for the objective function method. @@ -3369,10 +3390,13 @@ class LIBCELLML_EXPORT GeneratorProfile * * @param forDifferentialModel Whether the call to the objective function * method is for a differential model, as opposed to an algebraic model. + * @param withExternalVariables Whether the call to the objective function + * method is for a model with external variables. * @param objectiveFunctionMethodString The @c std::string to use for the * objective function method. */ void setObjectiveFunctionMethodString(bool forDifferentialModel, + bool withExternalVariables, const std::string &objectiveFunctionMethodString); /** diff --git a/src/generator.cpp b/src/generator.cpp index 38d25b7ee..c8ce8d87c 100644 --- a/src/generator.cpp +++ b/src/generator.cpp @@ -755,9 +755,9 @@ void Generator::GeneratorImpl::addExternNlaSolveMethodCode() void Generator::GeneratorImpl::addNlaSystemsCode() { if (modelHasNlas() - && !mProfile->objectiveFunctionMethodString(modelHasOdes()).empty() - && !mProfile->findRootMethodString(modelHasOdes()).empty() - && !mProfile->nlaSolveCallString(modelHasOdes()).empty()) { + && !mProfile->objectiveFunctionMethodString(modelHasOdes(), mModel->hasExternalVariables()).empty() + && !mProfile->findRootMethodString(modelHasOdes(), mModel->hasExternalVariables()).empty() + && !mProfile->nlaSolveCallString(modelHasOdes(), mModel->hasExternalVariables()).empty()) { // Note: only states and algebraic variables can be computed through an NLA system. Constants, computed // constants, and external variables cannot, by definition, be computed through an NLA system. @@ -805,7 +805,7 @@ void Generator::GeneratorImpl::addNlaSystemsCode() } mCode += newLineIfNeeded() - + replace(replace(mProfile->objectiveFunctionMethodString(modelHasOdes()), + + replace(replace(mProfile->objectiveFunctionMethodString(modelHasOdes(), mModel->hasExternalVariables()), "[INDEX]", convertToString(equation->nlaSystemIndex())), "[CODE]", generateMethodBodyCode(methodBody)); @@ -829,7 +829,7 @@ void Generator::GeneratorImpl::addNlaSystemsCode() methodBody += newLineIfNeeded() + mProfile->indentString() - + replace(replace(mProfile->nlaSolveCallString(modelHasOdes()), + + replace(replace(mProfile->nlaSolveCallString(modelHasOdes(), mModel->hasExternalVariables()), "[INDEX]", convertToString(equation->nlaSystemIndex())), "[SIZE]", convertToString(variablesCount)); @@ -850,7 +850,7 @@ void Generator::GeneratorImpl::addNlaSystemsCode() } mCode += newLineIfNeeded() - + replace(replace(replace(mProfile->findRootMethodString(modelHasOdes()), + + replace(replace(replace(mProfile->findRootMethodString(modelHasOdes(), mModel->hasExternalVariables()), "[INDEX]", convertToString(equation->nlaSystemIndex())), "[SIZE]", convertToString(variablesCount)), "[CODE]", generateMethodBodyCode(methodBody)); @@ -1752,9 +1752,9 @@ std::string Generator::GeneratorImpl::generateEquationCode(const AnalyserEquatio break; case AnalyserEquation::Type::NLA: - if (!mProfile->findRootCallString(modelHasOdes()).empty()) { + if (!mProfile->findRootCallString(modelHasOdes(), mModel->hasExternalVariables()).empty()) { res += mProfile->indentString() - + replace(mProfile->findRootCallString(modelHasOdes()), + + replace(mProfile->findRootCallString(modelHasOdes(), mModel->hasExternalVariables()), "[INDEX]", convertToString(equation->nlaSystemIndex())); } diff --git a/src/generatorprofile.cpp b/src/generatorprofile.cpp index b388edeeb..cb57072f1 100644 --- a/src/generatorprofile.cpp +++ b/src/generatorprofile.cpp @@ -307,7 +307,6 @@ void GeneratorProfile::GeneratorProfileImpl::loadProfile(GeneratorProfile::Profi " double *algebraic;\n" " double *externals;\n" "} RootFindingInfo;\n"; - mRootFindingInfoObjectFdmWoevString = "typedef struct {\n" " double voi;\n" " double *states;\n" @@ -328,43 +327,87 @@ void GeneratorProfile::GeneratorProfileImpl::loadProfile(GeneratorProfile::Profi mExternNlaSolveMethodString = "extern void nlaSolve(void (*objectiveFunction)(double *, double *, void *),\n" " double *u, size_t n, void *data);\n"; - mFindRootCallFamString = "findRoot[INDEX](constants, computedConstants, algebraic);\n"; - mFindRootCallFdmString = "findRoot[INDEX](voi, states, rates, constants, computedConstants, algebraic);\n"; - mFindRootMethodFamString = "void findRoot[INDEX](double *constants, double *computedConstants, double *algebraic)\n" - "{\n" - " RootFindingInfo rfi = { constants, computedConstants, algebraic };\n" - " double u[[SIZE]];\n" - "\n" - "[CODE]" - "}\n"; - mFindRootMethodFdmString = "void findRoot[INDEX](double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic)\n" - "{\n" - " RootFindingInfo rfi = { voi, states, rates, constants, computedConstants, algebraic };\n" - " double u[[SIZE]];\n" - "\n" - "[CODE]" - "}\n"; - mNlaSolveCallFamString = "nlaSolve(objectiveFunction[INDEX], u, [SIZE], &rfi);\n"; - mNlaSolveCallFdmString = "nlaSolve(objectiveFunction[INDEX], u, [SIZE], &rfi);\n"; - mObjectiveFunctionMethodFamString = "void objectiveFunction[INDEX](double *u, double *f, void *data)\n" - "{\n" - " double *constants = ((RootFindingInfo *) data)->constants;\n" - " double *computedConstants = ((RootFindingInfo *) data)->computedConstants;\n" - " double *algebraic = ((RootFindingInfo *) data)->algebraic;\n" - "\n" - "[CODE]" - "}\n"; - mObjectiveFunctionMethodFdmString = "void objectiveFunction[INDEX](double *u, double *f, void *data)\n" - "{\n" - " double voi = ((RootFindingInfo *) data)->voi;\n" - " double *states = ((RootFindingInfo *) data)->states;\n" - " double *rates = ((RootFindingInfo *) data)->rates;\n" - " double *constants = ((RootFindingInfo *) data)->constants;\n" - " double *computedConstants = ((RootFindingInfo *) data)->computedConstants;\n" - " double *algebraic = ((RootFindingInfo *) data)->algebraic;\n" - "\n" - "[CODE]" - "}\n"; + + mFindRootCallFamWoevString = "findRoot[INDEX](constants, computedConstants, algebraic);\n"; + mFindRootCallFamWevString = "findRoot[INDEX](constants, computedConstants, algebraic, externals);\n"; + mFindRootCallFdmWoevString = "findRoot[INDEX](voi, states, rates, constants, computedConstants, algebraic);\n"; + mFindRootCallFdmWevString = "findRoot[INDEX](voi, states, rates, constants, computedConstants, algebraic, externals);\n"; + + mFindRootMethodFamWoevString = "void findRoot[INDEX](double *constants, double *computedConstants, double *algebraic)\n" + "{\n" + " RootFindingInfo rfi = { constants, computedConstants, algebraic };\n" + " double u[[SIZE]];\n" + "\n" + "[CODE]" + "}\n"; + mFindRootMethodFamWevString = "void findRoot[INDEX](double *constants, double *computedConstants, double *algebraic, double *externals)\n" + "{\n" + " RootFindingInfo rfi = { constants, computedConstants, algebraic, externals };\n" + " double u[[SIZE]];\n" + "\n" + "[CODE]" + "}\n"; + mFindRootMethodFdmWoevString = "void findRoot[INDEX](double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic)\n" + "{\n" + " RootFindingInfo rfi = { voi, states, rates, constants, computedConstants, algebraic };\n" + " double u[[SIZE]];\n" + "\n" + "[CODE]" + "}\n"; + mFindRootMethodFdmWevString = "void findRoot[INDEX](double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, double *externals)\n" + "{\n" + " RootFindingInfo rfi = { voi, states, rates, constants, computedConstants, algebraic, externals };\n" + " double u[[SIZE]];\n" + "\n" + "[CODE]" + "}\n"; + + mNlaSolveCallFamWoevString = "nlaSolve(objectiveFunction[INDEX], u, [SIZE], &rfi);\n"; + mNlaSolveCallFamWevString = "nlaSolve(objectiveFunction[INDEX], u, [SIZE], &rfi);\n"; + mNlaSolveCallFdmWoevString = "nlaSolve(objectiveFunction[INDEX], u, [SIZE], &rfi);\n"; + mNlaSolveCallFdmWevString = "nlaSolve(objectiveFunction[INDEX], u, [SIZE], &rfi);\n"; + + mObjectiveFunctionMethodFamWoevString = "void objectiveFunction[INDEX](double *u, double *f, void *data)\n" + "{\n" + " double *constants = ((RootFindingInfo *) data)->constants;\n" + " double *computedConstants = ((RootFindingInfo *) data)->computedConstants;\n" + " double *algebraic = ((RootFindingInfo *) data)->algebraic;\n" + "\n" + "[CODE]" + "}\n"; + mObjectiveFunctionMethodFamWevString = "void objectiveFunction[INDEX](double *u, double *f, void *data)\n" + "{\n" + " double *constants = ((RootFindingInfo *) data)->constants;\n" + " double *computedConstants = ((RootFindingInfo *) data)->computedConstants;\n" + " double *algebraic = ((RootFindingInfo *) data)->algebraic;\n" + " double *externals = ((RootFindingInfo *) data)->externals;\n" + "\n" + "[CODE]" + "}\n"; + mObjectiveFunctionMethodFdmWoevString = "void objectiveFunction[INDEX](double *u, double *f, void *data)\n" + "{\n" + " double voi = ((RootFindingInfo *) data)->voi;\n" + " double *states = ((RootFindingInfo *) data)->states;\n" + " double *rates = ((RootFindingInfo *) data)->rates;\n" + " double *constants = ((RootFindingInfo *) data)->constants;\n" + " double *computedConstants = ((RootFindingInfo *) data)->computedConstants;\n" + " double *algebraic = ((RootFindingInfo *) data)->algebraic;\n" + "\n" + "[CODE]" + "}\n"; + mObjectiveFunctionMethodFdmWevString = "void objectiveFunction[INDEX](double *u, double *f, void *data)\n" + "{\n" + " double voi = ((RootFindingInfo *) data)->voi;\n" + " double *states = ((RootFindingInfo *) data)->states;\n" + " double *rates = ((RootFindingInfo *) data)->rates;\n" + " double *constants = ((RootFindingInfo *) data)->constants;\n" + " double *computedConstants = ((RootFindingInfo *) data)->computedConstants;\n" + " double *algebraic = ((RootFindingInfo *) data)->algebraic;\n" + " double *externals = ((RootFindingInfo *) data)->externals;\n" + "\n" + "[CODE]" + "}\n"; + mUArrayString = "u"; mFArrayString = "f"; @@ -764,44 +807,81 @@ void GeneratorProfile::GeneratorProfileImpl::loadProfile(GeneratorProfile::Profi mRootFindingInfoObjectFamWoevString = ""; mRootFindingInfoObjectFamWevString = ""; - mRootFindingInfoObjectFdmWoevString = ""; mRootFindingInfoObjectFdmWevString = ""; mExternNlaSolveMethodString = "\n" "from nlasolver import nla_solve" "\n"; - mFindRootCallFamString = "find_root_[INDEX](constants, computed_constants, algebraic)\n"; - mFindRootCallFdmString = "find_root_[INDEX](voi, states, rates, constants, computed_constants, algebraic)\n"; - mFindRootMethodFamString = "\n" - "def find_root_[INDEX](constants, computed_constants, algebraic):\n" - " u = [nan]*[SIZE]\n" - "\n" - "[CODE]"; - mFindRootMethodFdmString = "\n" - "def find_root_[INDEX](voi, states, rates, constants, computed_constants, algebraic):\n" - " u = [nan]*[SIZE]\n" - "\n" - "[CODE]"; - mNlaSolveCallFamString = "u = nla_solve(objective_function_[INDEX], u, [SIZE], [constants, computed_constants, algebraic])\n"; - mNlaSolveCallFdmString = "u = nla_solve(objective_function_[INDEX], u, [SIZE], [voi, states, rates, constants, computed_constants, algebraic])\n"; - mObjectiveFunctionMethodFamString = "\n" - "def objective_function_[INDEX](u, f, data):\n" - " constants = data[0]\n" - " computed_constants = data[1]\n" - " algebraic = data[2]\n" - "\n" - "[CODE]"; - mObjectiveFunctionMethodFdmString = "\n" - "def objective_function_[INDEX](u, f, data):\n" - " voi = data[0]\n" - " states = data[1]\n" - " rates = data[2]\n" - " constants = data[3]\n" - " computed_constants = data[4]\n" - " algebraic = data[5]\n" - "\n" - "[CODE]"; + + mFindRootCallFamWoevString = "find_root_[INDEX](constants, computed_constants, algebraic)\n"; + mFindRootCallFamWevString = "find_root_[INDEX](constants, computed_constants, algebraic, externals)\n"; + mFindRootCallFdmWoevString = "find_root_[INDEX](voi, states, rates, constants, computed_constants, algebraic)\n"; + mFindRootCallFdmWevString = "find_root_[INDEX](voi, states, rates, constants, computed_constants, algebraic, externals)\n"; + + mFindRootMethodFamWoevString = "\n" + "def find_root_[INDEX](constants, computed_constants, algebraic):\n" + " u = [nan]*[SIZE]\n" + "\n" + "[CODE]"; + mFindRootMethodFamWevString = "\n" + "def find_root_[INDEX](constants, computed_constants, algebraic, externals):\n" + " u = [nan]*[SIZE]\n" + "\n" + "[CODE]"; + mFindRootMethodFdmWoevString = "\n" + "def find_root_[INDEX](voi, states, rates, constants, computed_constants, algebraic):\n" + " u = [nan]*[SIZE]\n" + "\n" + "[CODE]"; + mFindRootMethodFdmWevString = "\n" + "def find_root_[INDEX](voi, states, rates, constants, computed_constants, algebraic, externals):\n" + " u = [nan]*[SIZE]\n" + "\n" + "[CODE]"; + + mNlaSolveCallFamWoevString = "u = nla_solve(objective_function_[INDEX], u, [SIZE], [constants, computed_constants, algebraic])\n"; + mNlaSolveCallFamWevString = "u = nla_solve(objective_function_[INDEX], u, [SIZE], [constants, computed_constants, algebraic, externals])\n"; + mNlaSolveCallFdmWoevString = "u = nla_solve(objective_function_[INDEX], u, [SIZE], [voi, states, rates, constants, computed_constants, algebraic])\n"; + mNlaSolveCallFdmWevString = "u = nla_solve(objective_function_[INDEX], u, [SIZE], [voi, states, rates, constants, computed_constants, algebraic, externals])\n"; + + mObjectiveFunctionMethodFamWoevString = "\n" + "def objective_function_[INDEX](u, f, data):\n" + " constants = data[0]\n" + " computed_constants = data[1]\n" + " algebraic = data[2]\n" + " externals = data[3]\n" + "\n" + "[CODE]"; + mObjectiveFunctionMethodFamWevString = "\n" + "def objective_function_[INDEX](u, f, data):\n" + " constants = data[0]\n" + " computed_constants = data[1]\n" + " algebraic = data[2]\n" + "\n" + "[CODE]"; + mObjectiveFunctionMethodFdmWoevString = "\n" + "def objective_function_[INDEX](u, f, data):\n" + " voi = data[0]\n" + " states = data[1]\n" + " rates = data[2]\n" + " constants = data[3]\n" + " computed_constants = data[4]\n" + " algebraic = data[5]\n" + "\n" + "[CODE]"; + mObjectiveFunctionMethodFdmWevString = "\n" + "def objective_function_[INDEX](u, f, data):\n" + " voi = data[0]\n" + " states = data[1]\n" + " rates = data[2]\n" + " constants = data[3]\n" + " computed_constants = data[4]\n" + " algebraic = data[5]\n" + " externals = data[6]\n" + "\n" + "[CODE]"; + mUArrayString = "u"; mFArrayString = "f"; @@ -2396,79 +2476,151 @@ void GeneratorProfile::setExternNlaSolveMethodString(const std::string &externNl mPimpl->mExternNlaSolveMethodString = externNlaSolveMethodString; } -std::string GeneratorProfile::findRootCallString(bool forDifferentialModel) const +std::string GeneratorProfile::findRootCallString(bool forDifferentialModel, + bool withExternalVariables) const { if (forDifferentialModel) { - return mPimpl->mFindRootCallFdmString; + if (withExternalVariables) { + return mPimpl->mFindRootCallFdmWevString; + } + + return mPimpl->mFindRootCallFdmWoevString; } - return mPimpl->mFindRootCallFamString; + if (withExternalVariables) { + return mPimpl->mFindRootCallFamWevString; + } + + return mPimpl->mFindRootCallFamWoevString; } void GeneratorProfile::setFindRootCallString(bool forDifferentialModel, + bool withExternalVariables, const std::string &findRootCallString) { if (forDifferentialModel) { - mPimpl->mFindRootCallFdmString = findRootCallString; + if (withExternalVariables) { + mPimpl->mFindRootCallFdmWevString = findRootCallString; + } else { + mPimpl->mFindRootCallFdmWoevString = findRootCallString; + } } else { - mPimpl->mFindRootCallFamString = findRootCallString; + if (withExternalVariables) { + mPimpl->mFindRootCallFamWevString = findRootCallString; + } else { + mPimpl->mFindRootCallFamWoevString = findRootCallString; + } } } -std::string GeneratorProfile::findRootMethodString(bool forDifferentialModel) const +std::string GeneratorProfile::findRootMethodString(bool forDifferentialModel, + bool withExternalVariables) const { if (forDifferentialModel) { - return mPimpl->mFindRootMethodFdmString; + if (withExternalVariables) { + return mPimpl->mFindRootMethodFdmWevString; + } + + return mPimpl->mFindRootMethodFdmWoevString; + } + + if (withExternalVariables) { + return mPimpl->mFindRootMethodFamWevString; } - return mPimpl->mFindRootMethodFamString; + return mPimpl->mFindRootMethodFamWoevString; } void GeneratorProfile::setFindRootMethodString(bool forDifferentialModel, + bool withExternalVariables, const std::string &findRootMethodString) { if (forDifferentialModel) { - mPimpl->mFindRootMethodFdmString = findRootMethodString; + if (withExternalVariables) { + mPimpl->mFindRootMethodFdmWevString = findRootMethodString; + } else { + mPimpl->mFindRootMethodFdmWoevString = findRootMethodString; + } } else { - mPimpl->mFindRootMethodFamString = findRootMethodString; + if (withExternalVariables) { + mPimpl->mFindRootMethodFamWevString = findRootMethodString; + } else { + mPimpl->mFindRootMethodFamWoevString = findRootMethodString; + } } } -std::string GeneratorProfile::nlaSolveCallString(bool forDifferentialModel) const +std::string GeneratorProfile::nlaSolveCallString(bool forDifferentialModel, + bool withExternalVariables) const { if (forDifferentialModel) { - return mPimpl->mNlaSolveCallFdmString; + if (withExternalVariables) { + return mPimpl->mNlaSolveCallFdmWevString; + } + + return mPimpl->mNlaSolveCallFdmWoevString; + } + + if (withExternalVariables) { + return mPimpl->mNlaSolveCallFamWevString; } - return mPimpl->mNlaSolveCallFamString; + return mPimpl->mNlaSolveCallFamWoevString; } void GeneratorProfile::setNlaSolveCallString(bool forDifferentialModel, + bool withExternalVariables, const std::string &nlaSolveCallString) { if (forDifferentialModel) { - mPimpl->mNlaSolveCallFdmString = nlaSolveCallString; + if (withExternalVariables) { + mPimpl->mNlaSolveCallFdmWevString = nlaSolveCallString; + } else { + mPimpl->mNlaSolveCallFdmWoevString = nlaSolveCallString; + } } else { - mPimpl->mNlaSolveCallFamString = nlaSolveCallString; + if (withExternalVariables) { + mPimpl->mNlaSolveCallFamWevString = nlaSolveCallString; + } else { + mPimpl->mNlaSolveCallFamWoevString = nlaSolveCallString; + } } } -std::string GeneratorProfile::objectiveFunctionMethodString(bool forDifferentialModel) const +std::string GeneratorProfile::objectiveFunctionMethodString(bool forDifferentialModel, + bool withExternalVariables) const { if (forDifferentialModel) { - return mPimpl->mObjectiveFunctionMethodFdmString; + if (withExternalVariables) { + return mPimpl->mObjectiveFunctionMethodFdmWevString; + } + + return mPimpl->mObjectiveFunctionMethodFdmWoevString; } - return mPimpl->mObjectiveFunctionMethodFamString; + if (withExternalVariables) { + return mPimpl->mObjectiveFunctionMethodFamWevString; + } + + return mPimpl->mObjectiveFunctionMethodFamWoevString; } void GeneratorProfile::setObjectiveFunctionMethodString(bool forDifferentialModel, + bool withExternalVariables, const std::string &objectiveFunctionMethodString) { if (forDifferentialModel) { - mPimpl->mObjectiveFunctionMethodFdmString = objectiveFunctionMethodString; + if (withExternalVariables) { + mPimpl->mObjectiveFunctionMethodFdmWevString = objectiveFunctionMethodString; + } else { + mPimpl->mObjectiveFunctionMethodFdmWoevString = objectiveFunctionMethodString; + } } else { - mPimpl->mObjectiveFunctionMethodFamString = objectiveFunctionMethodString; + if (withExternalVariables) { + mPimpl->mObjectiveFunctionMethodFamWevString = objectiveFunctionMethodString; + } else { + mPimpl->mObjectiveFunctionMethodFamWoevString = objectiveFunctionMethodString; + } } } diff --git a/src/generatorprofile_p.h b/src/generatorprofile_p.h index fda7cf543..0a44b83d0 100644 --- a/src/generatorprofile_p.h +++ b/src/generatorprofile_p.h @@ -227,19 +227,31 @@ struct GeneratorProfile::GeneratorProfileImpl std::string mRootFindingInfoObjectFamWoevString; std::string mRootFindingInfoObjectFamWevString; - std::string mRootFindingInfoObjectFdmWoevString; std::string mRootFindingInfoObjectFdmWevString; std::string mExternNlaSolveMethodString; - std::string mFindRootCallFamString; - std::string mFindRootCallFdmString; - std::string mFindRootMethodFamString; - std::string mFindRootMethodFdmString; - std::string mNlaSolveCallFamString; - std::string mNlaSolveCallFdmString; - std::string mObjectiveFunctionMethodFamString; - std::string mObjectiveFunctionMethodFdmString; + + std::string mFindRootCallFamWoevString; + std::string mFindRootCallFamWevString; + std::string mFindRootCallFdmWoevString; + std::string mFindRootCallFdmWevString; + + std::string mFindRootMethodFamWoevString; + std::string mFindRootMethodFamWevString; + std::string mFindRootMethodFdmWoevString; + std::string mFindRootMethodFdmWevString; + + std::string mNlaSolveCallFamWoevString; + std::string mNlaSolveCallFamWevString; + std::string mNlaSolveCallFdmWoevString; + std::string mNlaSolveCallFdmWevString; + + std::string mObjectiveFunctionMethodFamWoevString; + std::string mObjectiveFunctionMethodFamWevString; + std::string mObjectiveFunctionMethodFdmWoevString; + std::string mObjectiveFunctionMethodFdmWevString; + std::string mUArrayString; std::string mFArrayString; @@ -277,15 +289,13 @@ struct GeneratorProfile::GeneratorProfileImpl std::string mImplementationComputeRatesMethodWevString; std::string mInterfaceComputeVariablesMethodFamWoevString; - std::string mImplementationComputeVariablesMethodFamWoevString; - std::string mInterfaceComputeVariablesMethodFamWevString; - std::string mImplementationComputeVariablesMethodFamWevString; - std::string mInterfaceComputeVariablesMethodFdmWoevString; - std::string mImplementationComputeVariablesMethodFdmWoevString; - std::string mInterfaceComputeVariablesMethodFdmWevString; + + std::string mImplementationComputeVariablesMethodFamWoevString; + std::string mImplementationComputeVariablesMethodFamWevString; + std::string mImplementationComputeVariablesMethodFdmWoevString; std::string mImplementationComputeVariablesMethodFdmWevString; std::string mEmptyMethodString; diff --git a/src/generatorprofilesha1values.h b/src/generatorprofilesha1values.h index 1c6ba04d8..8c6df4ed7 100644 --- a/src/generatorprofilesha1values.h +++ b/src/generatorprofilesha1values.h @@ -24,7 +24,7 @@ namespace libcellml { * The content of this file is generated, do not edit this file directly. * See docs/dev_utilities.rst for further information. */ -static const char C_GENERATOR_PROFILE_SHA1[] = "d3c84f25e69c62eaf1a154bf75d4394185cf7e23"; -static const char PYTHON_GENERATOR_PROFILE_SHA1[] = "06014d14cb0b183d9ba4952c56eb36388da5de28"; +static const char C_GENERATOR_PROFILE_SHA1[] = "f0d3add475025d2d4b805747828dbaf2f1345b2f"; +static const char PYTHON_GENERATOR_PROFILE_SHA1[] = "704a899325e7a0ad40c0275ff5dcd5586ad64bf5"; } // namespace libcellml diff --git a/src/generatorprofiletools.cpp b/src/generatorprofiletools.cpp index c85fe9411..9b4d0086d 100644 --- a/src/generatorprofiletools.cpp +++ b/src/generatorprofiletools.cpp @@ -496,14 +496,22 @@ std::string generatorProfileAsString(const GeneratorProfilePtr &generatorProfile + generatorProfile->rootFindingInfoObjectString(true, false) + generatorProfile->rootFindingInfoObjectString(true, true) + generatorProfile->externNlaSolveMethodString() - + generatorProfile->findRootCallString(false) - + generatorProfile->findRootCallString(true) - + generatorProfile->findRootMethodString(false) - + generatorProfile->findRootMethodString(true) - + generatorProfile->nlaSolveCallString(false) - + generatorProfile->nlaSolveCallString(true) - + generatorProfile->objectiveFunctionMethodString(false) - + generatorProfile->objectiveFunctionMethodString(true) + + generatorProfile->findRootCallString(false, false) + + generatorProfile->findRootCallString(false, true) + + generatorProfile->findRootCallString(true, false) + + generatorProfile->findRootCallString(true, true) + + generatorProfile->findRootMethodString(false, false) + + generatorProfile->findRootMethodString(false, true) + + generatorProfile->findRootMethodString(true, false) + + generatorProfile->findRootMethodString(true, true) + + generatorProfile->nlaSolveCallString(false, false) + + generatorProfile->nlaSolveCallString(false, true) + + generatorProfile->nlaSolveCallString(true, false) + + generatorProfile->nlaSolveCallString(true, true) + + generatorProfile->objectiveFunctionMethodString(false, false) + + generatorProfile->objectiveFunctionMethodString(false, true) + + generatorProfile->objectiveFunctionMethodString(true, false) + + generatorProfile->objectiveFunctionMethodString(true, true) + generatorProfile->uArrayString() + generatorProfile->fArrayString(); diff --git a/tests/bindings/javascript/generatorprofile.test.js b/tests/bindings/javascript/generatorprofile.test.js index 1b728eec3..e3c40bfe4 100644 --- a/tests/bindings/javascript/generatorprofile.test.js +++ b/tests/bindings/javascript/generatorprofile.test.js @@ -840,38 +840,62 @@ describe("GeneratorProfile tests", () => { test("Checking GeneratorProfile.findRootCallString.", () => { const x = new libcellml.GeneratorProfile(libcellml.GeneratorProfile.Profile.C) - x.setFindRootCallString(false, "something") - expect(x.findRootCallString(false)).toBe("something") + x.setFindRootCallString(false, false, "something") + expect(x.findRootCallString(false, false)).toBe("something") - x.setFindRootCallString(true, "something") - expect(x.findRootCallString(true)).toBe("something") + x.setFindRootCallString(false, true, "something") + expect(x.findRootCallString(false, true)).toBe("something") + + x.setFindRootCallString(true, false, "something") + expect(x.findRootCallString(true, false)).toBe("something") + + x.setFindRootCallString(true, true, "something") + expect(x.findRootCallString(true, true)).toBe("something") }); test("Checking GeneratorProfile.findRootMethodString.", () => { const x = new libcellml.GeneratorProfile(libcellml.GeneratorProfile.Profile.C) - x.setFindRootMethodString(false, "something") - expect(x.findRootMethodString(false)).toBe("something") + x.setFindRootMethodString(false, false, "something") + expect(x.findRootMethodString(false, false)).toBe("something") + + x.setFindRootMethodString(false, true, "something") + expect(x.findRootMethodString(false, true)).toBe("something") + + x.setFindRootMethodString(true, false, "something") + expect(x.findRootMethodString(true, false)).toBe("something") - x.setFindRootMethodString(true, "something") - expect(x.findRootMethodString(true)).toBe("something") + x.setFindRootMethodString(true, true, "something") + expect(x.findRootMethodString(true, true)).toBe("something") }); test("Checking GeneratorProfile.nlaSolveCallString.", () => { const x = new libcellml.GeneratorProfile(libcellml.GeneratorProfile.Profile.C) - x.setNlaSolveCallString(false, "something") - expect(x.nlaSolveCallString(false)).toBe("something") + x.setNlaSolveCallString(false, false, "something") + expect(x.nlaSolveCallString(false, false)).toBe("something") - x.setNlaSolveCallString(true, "something") - expect(x.nlaSolveCallString(true)).toBe("something") + x.setNlaSolveCallString(false, true, "something") + expect(x.nlaSolveCallString(false, true)).toBe("something") + + x.setNlaSolveCallString(true, false, "something") + expect(x.nlaSolveCallString(true, false)).toBe("something") + + x.setNlaSolveCallString(true, true, "something") + expect(x.nlaSolveCallString(true, true)).toBe("something") }); test("Checking GeneratorProfile.objectiveFunctionMethodString.", () => { const x = new libcellml.GeneratorProfile(libcellml.GeneratorProfile.Profile.C) - x.setObjectiveFunctionMethodString(false, "something") - expect(x.objectiveFunctionMethodString(false)).toBe("something") + x.setObjectiveFunctionMethodString(false, false, "something") + expect(x.objectiveFunctionMethodString(false, false)).toBe("something") + + x.setObjectiveFunctionMethodString(false, true, "something") + expect(x.objectiveFunctionMethodString(false, true)).toBe("something") + + x.setObjectiveFunctionMethodString(true, false, "something") + expect(x.objectiveFunctionMethodString(true, false)).toBe("something") - x.setObjectiveFunctionMethodString(true, "something") - expect(x.objectiveFunctionMethodString(true)).toBe("something") + x.setObjectiveFunctionMethodString(true, true, "something") + expect(x.objectiveFunctionMethodString(true, true)).toBe("something") }); test("Checking GeneratorProfile.uArrayString.", () => { const x = new libcellml.GeneratorProfile(libcellml.GeneratorProfile.Profile.C) diff --git a/tests/bindings/python/test_generator_profile.py b/tests/bindings/python/test_generator_profile.py index b3bb6ad3a..54befa012 100644 --- a/tests/bindings/python/test_generator_profile.py +++ b/tests/bindings/python/test_generator_profile.py @@ -1738,52 +1738,84 @@ def test_find_root_call_string(self): g = GeneratorProfile() - self.assertEqual('findRoot[INDEX](constants, computedConstants, algebraic);\n', g.findRootCallString(False)) - g.setFindRootCallString(False, GeneratorProfileTestCase.VALUE) - self.assertEqual(GeneratorProfileTestCase.VALUE, g.findRootCallString(False)) + self.assertEqual('findRoot[INDEX](constants, computedConstants, algebraic);\n', g.findRootCallString(False, False)) + g.setFindRootCallString(False, False, GeneratorProfileTestCase.VALUE) + self.assertEqual(GeneratorProfileTestCase.VALUE, g.findRootCallString(False, False)) - self.assertEqual('findRoot[INDEX](voi, states, rates, constants, computedConstants, algebraic);\n', g.findRootCallString(True)) - g.setFindRootCallString(True, GeneratorProfileTestCase.VALUE) - self.assertEqual(GeneratorProfileTestCase.VALUE, g.findRootCallString(True)) + self.assertEqual('findRoot[INDEX](constants, computedConstants, algebraic, externals);\n', g.findRootCallString(False, True)) + g.setFindRootCallString(False, True, GeneratorProfileTestCase.VALUE) + self.assertEqual(GeneratorProfileTestCase.VALUE, g.findRootCallString(False, True)) + + self.assertEqual('findRoot[INDEX](voi, states, rates, constants, computedConstants, algebraic);\n', g.findRootCallString(True, False)) + g.setFindRootCallString(True, False, GeneratorProfileTestCase.VALUE) + self.assertEqual(GeneratorProfileTestCase.VALUE, g.findRootCallString(True, False)) + + self.assertEqual('findRoot[INDEX](voi, states, rates, constants, computedConstants, algebraic, externals);\n', g.findRootCallString(True, True)) + g.setFindRootCallString(True, True, GeneratorProfileTestCase.VALUE) + self.assertEqual(GeneratorProfileTestCase.VALUE, g.findRootCallString(True, True)) def test_find_root_method_string(self): from libcellml import GeneratorProfile g = GeneratorProfile() - self.assertEqual('void findRoot[INDEX](double *constants, double *computedConstants, double *algebraic)\n{\n RootFindingInfo rfi = { constants, computedConstants, algebraic };\n double u[[SIZE]];\n\n[CODE]}\n', g.findRootMethodString(False)) - g.setFindRootMethodString(False, GeneratorProfileTestCase.VALUE) - self.assertEqual(GeneratorProfileTestCase.VALUE, g.findRootMethodString(False)) + self.assertEqual('void findRoot[INDEX](double *constants, double *computedConstants, double *algebraic)\n{\n RootFindingInfo rfi = { constants, computedConstants, algebraic };\n double u[[SIZE]];\n\n[CODE]}\n', g.findRootMethodString(False, False)) + g.setFindRootMethodString(False, False, GeneratorProfileTestCase.VALUE) + self.assertEqual(GeneratorProfileTestCase.VALUE, g.findRootMethodString(False, False)) + + self.assertEqual('void findRoot[INDEX](double *constants, double *computedConstants, double *algebraic, double *externals)\n{\n RootFindingInfo rfi = { constants, computedConstants, algebraic, externals };\n double u[[SIZE]];\n\n[CODE]}\n', g.findRootMethodString(False, True)) + g.setFindRootMethodString(False, True, GeneratorProfileTestCase.VALUE) + self.assertEqual(GeneratorProfileTestCase.VALUE, g.findRootMethodString(False, True)) + + self.assertEqual('void findRoot[INDEX](double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic)\n{\n RootFindingInfo rfi = { voi, states, rates, constants, computedConstants, algebraic };\n double u[[SIZE]];\n\n[CODE]}\n', g.findRootMethodString(True, False)) + g.setFindRootMethodString(True, False, GeneratorProfileTestCase.VALUE) + self.assertEqual(GeneratorProfileTestCase.VALUE, g.findRootMethodString(True, False)) - self.assertEqual('void findRoot[INDEX](double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic)\n{\n RootFindingInfo rfi = { voi, states, rates, constants, computedConstants, algebraic };\n double u[[SIZE]];\n\n[CODE]}\n', g.findRootMethodString(True)) - g.setFindRootMethodString(True, GeneratorProfileTestCase.VALUE) - self.assertEqual(GeneratorProfileTestCase.VALUE, g.findRootMethodString(True)) + self.assertEqual('void findRoot[INDEX](double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, double *externals)\n{\n RootFindingInfo rfi = { voi, states, rates, constants, computedConstants, algebraic, externals };\n double u[[SIZE]];\n\n[CODE]}\n', g.findRootMethodString(True, True)) + g.setFindRootMethodString(True, True, GeneratorProfileTestCase.VALUE) + self.assertEqual(GeneratorProfileTestCase.VALUE, g.findRootMethodString(True, True)) def test_nla_solve_call_string(self): from libcellml import GeneratorProfile g = GeneratorProfile() - self.assertEqual('nlaSolve(objectiveFunction[INDEX], u, [SIZE], &rfi);\n', g.nlaSolveCallString(False)) - g.setNlaSolveCallString(False, GeneratorProfileTestCase.VALUE) - self.assertEqual(GeneratorProfileTestCase.VALUE, g.nlaSolveCallString(False)) + self.assertEqual('nlaSolve(objectiveFunction[INDEX], u, [SIZE], &rfi);\n', g.nlaSolveCallString(False, False)) + g.setNlaSolveCallString(False, False, GeneratorProfileTestCase.VALUE) + self.assertEqual(GeneratorProfileTestCase.VALUE, g.nlaSolveCallString(False, False)) - self.assertEqual('nlaSolve(objectiveFunction[INDEX], u, [SIZE], &rfi);\n', g.nlaSolveCallString(True)) - g.setNlaSolveCallString(True, GeneratorProfileTestCase.VALUE) - self.assertEqual(GeneratorProfileTestCase.VALUE, g.nlaSolveCallString(True)) + self.assertEqual('nlaSolve(objectiveFunction[INDEX], u, [SIZE], &rfi);\n', g.nlaSolveCallString(False, True)) + g.setNlaSolveCallString(False, True, GeneratorProfileTestCase.VALUE) + self.assertEqual(GeneratorProfileTestCase.VALUE, g.nlaSolveCallString(False, True)) + + self.assertEqual('nlaSolve(objectiveFunction[INDEX], u, [SIZE], &rfi);\n', g.nlaSolveCallString(True, False)) + g.setNlaSolveCallString(True, False, GeneratorProfileTestCase.VALUE) + self.assertEqual(GeneratorProfileTestCase.VALUE, g.nlaSolveCallString(True, False)) + + self.assertEqual('nlaSolve(objectiveFunction[INDEX], u, [SIZE], &rfi);\n', g.nlaSolveCallString(True, True)) + g.setNlaSolveCallString(True, True, GeneratorProfileTestCase.VALUE) + self.assertEqual(GeneratorProfileTestCase.VALUE, g.nlaSolveCallString(True, True)) def test_objective_function_method_string(self): from libcellml import GeneratorProfile g = GeneratorProfile() - self.assertEqual('void objectiveFunction[INDEX](double *u, double *f, void *data)\n{\n double *constants = ((RootFindingInfo *) data)->constants;\n double *computedConstants = ((RootFindingInfo *) data)->computedConstants;\n double *algebraic = ((RootFindingInfo *) data)->algebraic;\n\n[CODE]}\n', g.objectiveFunctionMethodString(False)) - g.setObjectiveFunctionMethodString(False, GeneratorProfileTestCase.VALUE) - self.assertEqual(GeneratorProfileTestCase.VALUE, g.objectiveFunctionMethodString(False)) + self.assertEqual('void objectiveFunction[INDEX](double *u, double *f, void *data)\n{\n double *constants = ((RootFindingInfo *) data)->constants;\n double *computedConstants = ((RootFindingInfo *) data)->computedConstants;\n double *algebraic = ((RootFindingInfo *) data)->algebraic;\n\n[CODE]}\n', g.objectiveFunctionMethodString(False, False)) + g.setObjectiveFunctionMethodString(False, False, GeneratorProfileTestCase.VALUE) + self.assertEqual(GeneratorProfileTestCase.VALUE, g.objectiveFunctionMethodString(False, False)) + + self.assertEqual('void objectiveFunction[INDEX](double *u, double *f, void *data)\n{\n double *constants = ((RootFindingInfo *) data)->constants;\n double *computedConstants = ((RootFindingInfo *) data)->computedConstants;\n double *algebraic = ((RootFindingInfo *) data)->algebraic;\n double *externals = ((RootFindingInfo *) data)->externals;\n\n[CODE]}\n', g.objectiveFunctionMethodString(False, True)) + g.setObjectiveFunctionMethodString(False, True, GeneratorProfileTestCase.VALUE) + self.assertEqual(GeneratorProfileTestCase.VALUE, g.objectiveFunctionMethodString(False, True)) + + self.assertEqual('void objectiveFunction[INDEX](double *u, double *f, void *data)\n{\n double voi = ((RootFindingInfo *) data)->voi;\n double *states = ((RootFindingInfo *) data)->states;\n double *rates = ((RootFindingInfo *) data)->rates;\n double *constants = ((RootFindingInfo *) data)->constants;\n double *computedConstants = ((RootFindingInfo *) data)->computedConstants;\n double *algebraic = ((RootFindingInfo *) data)->algebraic;\n\n[CODE]}\n', g.objectiveFunctionMethodString(True, False)) + g.setObjectiveFunctionMethodString(True, False, GeneratorProfileTestCase.VALUE) + self.assertEqual(GeneratorProfileTestCase.VALUE, g.objectiveFunctionMethodString(True, False)) - self.assertEqual('void objectiveFunction[INDEX](double *u, double *f, void *data)\n{\n double voi = ((RootFindingInfo *) data)->voi;\n double *states = ((RootFindingInfo *) data)->states;\n double *rates = ((RootFindingInfo *) data)->rates;\n double *constants = ((RootFindingInfo *) data)->constants;\n double *computedConstants = ((RootFindingInfo *) data)->computedConstants;\n double *algebraic = ((RootFindingInfo *) data)->algebraic;\n\n[CODE]}\n', g.objectiveFunctionMethodString(True)) - g.setObjectiveFunctionMethodString(True, GeneratorProfileTestCase.VALUE) - self.assertEqual(GeneratorProfileTestCase.VALUE, g.objectiveFunctionMethodString(True)) + self.assertEqual('void objectiveFunction[INDEX](double *u, double *f, void *data)\n{\n double voi = ((RootFindingInfo *) data)->voi;\n double *states = ((RootFindingInfo *) data)->states;\n double *rates = ((RootFindingInfo *) data)->rates;\n double *constants = ((RootFindingInfo *) data)->constants;\n double *computedConstants = ((RootFindingInfo *) data)->computedConstants;\n double *algebraic = ((RootFindingInfo *) data)->algebraic;\n double *externals = ((RootFindingInfo *) data)->externals;\n\n[CODE]}\n', g.objectiveFunctionMethodString(True, True)) + g.setObjectiveFunctionMethodString(True, True, GeneratorProfileTestCase.VALUE) + self.assertEqual(GeneratorProfileTestCase.VALUE, g.objectiveFunctionMethodString(True, True)) def test_u_array_string(self): from libcellml import GeneratorProfile diff --git a/tests/coverage/coverage.cpp b/tests/coverage/coverage.cpp index c0ff65534..4e71511c8 100644 --- a/tests/coverage/coverage.cpp +++ b/tests/coverage/coverage.cpp @@ -893,8 +893,10 @@ TEST(Coverage, generator) profile->setInterfaceHeaderString(""); profile->setMaxFunctionString(""); profile->setMinFunctionString(""); - profile->setObjectiveFunctionMethodString(false, ""); - profile->setObjectiveFunctionMethodString(true, ""); + profile->setObjectiveFunctionMethodString(false, false, ""); + profile->setObjectiveFunctionMethodString(false, true, ""); + profile->setObjectiveFunctionMethodString(true, false, ""); + profile->setObjectiveFunctionMethodString(true, true, ""); profile->setSecFunctionString(""); profile->setSechFunctionString(""); profile->setVariableInfoEntryString(""); @@ -904,10 +906,14 @@ TEST(Coverage, generator) profile->setArrayElementSeparatorString(""); profile->setCommentString("xxx"); - profile->setFindRootMethodString(false, ""); - profile->setFindRootMethodString(true, ""); - profile->setObjectiveFunctionMethodString(false, "xxx"); - profile->setObjectiveFunctionMethodString(true, "xxx"); + profile->setFindRootMethodString(false, false, ""); + profile->setFindRootMethodString(false, true, ""); + profile->setFindRootMethodString(true, false, ""); + profile->setFindRootMethodString(true, true, ""); + profile->setObjectiveFunctionMethodString(false, false, "xxx"); + profile->setObjectiveFunctionMethodString(false, true, "xxx"); + profile->setObjectiveFunctionMethodString(true, false, "xxx"); + profile->setObjectiveFunctionMethodString(true, true, "xxx"); profile->setOriginCommentString(""); profile->setVariableInfoEntryString("xxx"); @@ -915,12 +921,18 @@ TEST(Coverage, generator) profile->setArrayElementSeparatorString("xxx"); profile->setExternNlaSolveMethodString(""); - profile->setFindRootMethodString(false, "xxx"); - profile->setFindRootMethodString(true, "xxx"); - profile->setFindRootCallString(false, ""); - profile->setFindRootCallString(true, ""); - profile->setNlaSolveCallString(false, ""); - profile->setNlaSolveCallString(true, ""); + profile->setFindRootMethodString(false, false, "xxx"); + profile->setFindRootMethodString(false, true, "xxx"); + profile->setFindRootMethodString(true, false, "xxx"); + profile->setFindRootMethodString(true, true, "xxx"); + profile->setFindRootCallString(false, false, ""); + profile->setFindRootCallString(false, true, ""); + profile->setFindRootCallString(true, false, ""); + profile->setFindRootCallString(true, true, ""); + profile->setNlaSolveCallString(false, false, ""); + profile->setNlaSolveCallString(false, true, ""); + profile->setNlaSolveCallString(true, false, ""); + profile->setNlaSolveCallString(true, true, ""); generator->implementationCode(); diff --git a/tests/generator/generatorprofile.cpp b/tests/generator/generatorprofile.cpp index c61172e51..1b8071fbf 100644 --- a/tests/generator/generatorprofile.cpp +++ b/tests/generator/generatorprofile.cpp @@ -384,9 +384,13 @@ TEST(GeneratorProfile, defaultMiscellaneousValues) " double *u, size_t n, void *data);\n", generatorProfile->externNlaSolveMethodString()); EXPECT_EQ("findRoot[INDEX](constants, computedConstants, algebraic);\n", - generatorProfile->findRootCallString(false)); + generatorProfile->findRootCallString(false, false)); + EXPECT_EQ("findRoot[INDEX](constants, computedConstants, algebraic, externals);\n", + generatorProfile->findRootCallString(false, true)); EXPECT_EQ("findRoot[INDEX](voi, states, rates, constants, computedConstants, algebraic);\n", - generatorProfile->findRootCallString(true)); + generatorProfile->findRootCallString(true, false)); + EXPECT_EQ("findRoot[INDEX](voi, states, rates, constants, computedConstants, algebraic, externals);\n", + generatorProfile->findRootCallString(true, true)); EXPECT_EQ("void findRoot[INDEX](double *constants, double *computedConstants, double *algebraic)\n" "{\n" " RootFindingInfo rfi = { constants, computedConstants, algebraic };\n" @@ -394,7 +398,15 @@ TEST(GeneratorProfile, defaultMiscellaneousValues) "\n" "[CODE]" "}\n", - generatorProfile->findRootMethodString(false)); + generatorProfile->findRootMethodString(false, false)); + EXPECT_EQ("void findRoot[INDEX](double *constants, double *computedConstants, double *algebraic, double *externals)\n" + "{\n" + " RootFindingInfo rfi = { constants, computedConstants, algebraic, externals };\n" + " double u[[SIZE]];\n" + "\n" + "[CODE]" + "}\n", + generatorProfile->findRootMethodString(false, true)); EXPECT_EQ("void findRoot[INDEX](double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic)\n" "{\n" " RootFindingInfo rfi = { voi, states, rates, constants, computedConstants, algebraic };\n" @@ -402,11 +414,23 @@ TEST(GeneratorProfile, defaultMiscellaneousValues) "\n" "[CODE]" "}\n", - generatorProfile->findRootMethodString(true)); + generatorProfile->findRootMethodString(true, false)); + EXPECT_EQ("void findRoot[INDEX](double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, double *externals)\n" + "{\n" + " RootFindingInfo rfi = { voi, states, rates, constants, computedConstants, algebraic, externals };\n" + " double u[[SIZE]];\n" + "\n" + "[CODE]" + "}\n", + generatorProfile->findRootMethodString(true, true)); + EXPECT_EQ("nlaSolve(objectiveFunction[INDEX], u, [SIZE], &rfi);\n", + generatorProfile->nlaSolveCallString(false, false)); + EXPECT_EQ("nlaSolve(objectiveFunction[INDEX], u, [SIZE], &rfi);\n", + generatorProfile->nlaSolveCallString(false, true)); EXPECT_EQ("nlaSolve(objectiveFunction[INDEX], u, [SIZE], &rfi);\n", - generatorProfile->nlaSolveCallString(false)); + generatorProfile->nlaSolveCallString(true, false)); EXPECT_EQ("nlaSolve(objectiveFunction[INDEX], u, [SIZE], &rfi);\n", - generatorProfile->nlaSolveCallString(true)); + generatorProfile->nlaSolveCallString(true, true)); EXPECT_EQ("void objectiveFunction[INDEX](double *u, double *f, void *data)\n" "{\n" " double *constants = ((RootFindingInfo *) data)->constants;\n" @@ -415,7 +439,29 @@ TEST(GeneratorProfile, defaultMiscellaneousValues) "\n" "[CODE]" "}\n", - generatorProfile->objectiveFunctionMethodString(false)); + generatorProfile->objectiveFunctionMethodString(false, false)); + EXPECT_EQ("void objectiveFunction[INDEX](double *u, double *f, void *data)\n" + "{\n" + " double *constants = ((RootFindingInfo *) data)->constants;\n" + " double *computedConstants = ((RootFindingInfo *) data)->computedConstants;\n" + " double *algebraic = ((RootFindingInfo *) data)->algebraic;\n" + " double *externals = ((RootFindingInfo *) data)->externals;\n" + "\n" + "[CODE]" + "}\n", + generatorProfile->objectiveFunctionMethodString(false, true)); + EXPECT_EQ("void objectiveFunction[INDEX](double *u, double *f, void *data)\n" + "{\n" + " double voi = ((RootFindingInfo *) data)->voi;\n" + " double *states = ((RootFindingInfo *) data)->states;\n" + " double *rates = ((RootFindingInfo *) data)->rates;\n" + " double *constants = ((RootFindingInfo *) data)->constants;\n" + " double *computedConstants = ((RootFindingInfo *) data)->computedConstants;\n" + " double *algebraic = ((RootFindingInfo *) data)->algebraic;\n" + "\n" + "[CODE]" + "}\n", + generatorProfile->objectiveFunctionMethodString(true, false)); EXPECT_EQ("void objectiveFunction[INDEX](double *u, double *f, void *data)\n" "{\n" " double voi = ((RootFindingInfo *) data)->voi;\n" @@ -424,10 +470,11 @@ TEST(GeneratorProfile, defaultMiscellaneousValues) " double *constants = ((RootFindingInfo *) data)->constants;\n" " double *computedConstants = ((RootFindingInfo *) data)->computedConstants;\n" " double *algebraic = ((RootFindingInfo *) data)->algebraic;\n" + " double *externals = ((RootFindingInfo *) data)->externals;\n" "\n" "[CODE]" "}\n", - generatorProfile->objectiveFunctionMethodString(true)); + generatorProfile->objectiveFunctionMethodString(true, true)); EXPECT_EQ("u", generatorProfile->uArrayString()); EXPECT_EQ("f", @@ -960,15 +1007,29 @@ TEST(GeneratorProfile, miscellaneous) generatorProfile->setRootFindingInfoObjectString(false, true, value); generatorProfile->setRootFindingInfoObjectString(true, false, value); generatorProfile->setRootFindingInfoObjectString(true, true, value); + generatorProfile->setExternNlaSolveMethodString(value); - generatorProfile->setFindRootCallString(false, value); - generatorProfile->setFindRootCallString(true, value); - generatorProfile->setFindRootMethodString(false, value); - generatorProfile->setFindRootMethodString(true, value); - generatorProfile->setNlaSolveCallString(false, value); - generatorProfile->setNlaSolveCallString(true, value); - generatorProfile->setObjectiveFunctionMethodString(false, value); - generatorProfile->setObjectiveFunctionMethodString(true, value); + + generatorProfile->setFindRootCallString(false, false, value); + generatorProfile->setFindRootCallString(false, true, value); + generatorProfile->setFindRootCallString(true, false, value); + generatorProfile->setFindRootCallString(true, true, value); + + generatorProfile->setFindRootMethodString(false, false, value); + generatorProfile->setFindRootMethodString(false, true, value); + generatorProfile->setFindRootMethodString(true, false, value); + generatorProfile->setFindRootMethodString(true, true, value); + + generatorProfile->setNlaSolveCallString(false, false, value); + generatorProfile->setNlaSolveCallString(false, true, value); + generatorProfile->setNlaSolveCallString(true, false, value); + generatorProfile->setNlaSolveCallString(true, true, value); + + generatorProfile->setObjectiveFunctionMethodString(false, false, value); + generatorProfile->setObjectiveFunctionMethodString(false, true, value); + generatorProfile->setObjectiveFunctionMethodString(true, false, value); + generatorProfile->setObjectiveFunctionMethodString(true, true, value); + generatorProfile->setUArrayString(value); generatorProfile->setFArrayString(value); @@ -991,30 +1052,28 @@ TEST(GeneratorProfile, miscellaneous) generatorProfile->setImplementationDeleteArrayMethodString(value); generatorProfile->setInterfaceInitialiseVariablesMethodString(false, value); - generatorProfile->setImplementationInitialiseVariablesMethodString(false, value); - generatorProfile->setInterfaceInitialiseVariablesMethodString(true, value); + + generatorProfile->setImplementationInitialiseVariablesMethodString(false, value); generatorProfile->setImplementationInitialiseVariablesMethodString(true, value); generatorProfile->setInterfaceComputeComputedConstantsMethodString(value); generatorProfile->setImplementationComputeComputedConstantsMethodString(value); generatorProfile->setInterfaceComputeRatesMethodString(false, value); - generatorProfile->setImplementationComputeRatesMethodString(false, value); - generatorProfile->setInterfaceComputeRatesMethodString(true, value); + + generatorProfile->setImplementationComputeRatesMethodString(false, value); generatorProfile->setImplementationComputeRatesMethodString(true, value); generatorProfile->setInterfaceComputeVariablesMethodString(false, false, value); - generatorProfile->setImplementationComputeVariablesMethodString(false, false, value); - generatorProfile->setInterfaceComputeVariablesMethodString(false, true, value); - generatorProfile->setImplementationComputeVariablesMethodString(false, true, value); - generatorProfile->setInterfaceComputeVariablesMethodString(true, false, value); - generatorProfile->setImplementationComputeVariablesMethodString(true, false, value); - generatorProfile->setInterfaceComputeVariablesMethodString(true, true, value); + + generatorProfile->setImplementationComputeVariablesMethodString(false, false, value); + generatorProfile->setImplementationComputeVariablesMethodString(false, true, value); + generatorProfile->setImplementationComputeVariablesMethodString(true, false, value); generatorProfile->setImplementationComputeVariablesMethodString(true, true, value); generatorProfile->setEmptyMethodString(value); @@ -1103,15 +1162,29 @@ TEST(GeneratorProfile, miscellaneous) EXPECT_EQ(value, generatorProfile->rootFindingInfoObjectString(false, true)); EXPECT_EQ(value, generatorProfile->rootFindingInfoObjectString(true, false)); EXPECT_EQ(value, generatorProfile->rootFindingInfoObjectString(true, true)); + EXPECT_EQ(value, generatorProfile->externNlaSolveMethodString()); - EXPECT_EQ(value, generatorProfile->findRootCallString(false)); - EXPECT_EQ(value, generatorProfile->findRootCallString(true)); - EXPECT_EQ(value, generatorProfile->findRootMethodString(false)); - EXPECT_EQ(value, generatorProfile->findRootMethodString(true)); - EXPECT_EQ(value, generatorProfile->nlaSolveCallString(false)); - EXPECT_EQ(value, generatorProfile->nlaSolveCallString(true)); - EXPECT_EQ(value, generatorProfile->objectiveFunctionMethodString(false)); - EXPECT_EQ(value, generatorProfile->objectiveFunctionMethodString(true)); + + EXPECT_EQ(value, generatorProfile->findRootCallString(false, false)); + EXPECT_EQ(value, generatorProfile->findRootCallString(false, true)); + EXPECT_EQ(value, generatorProfile->findRootCallString(true, false)); + EXPECT_EQ(value, generatorProfile->findRootCallString(true, true)); + + EXPECT_EQ(value, generatorProfile->findRootMethodString(false, false)); + EXPECT_EQ(value, generatorProfile->findRootMethodString(false, true)); + EXPECT_EQ(value, generatorProfile->findRootMethodString(true, false)); + EXPECT_EQ(value, generatorProfile->findRootMethodString(true, true)); + + EXPECT_EQ(value, generatorProfile->nlaSolveCallString(false, false)); + EXPECT_EQ(value, generatorProfile->nlaSolveCallString(false, true)); + EXPECT_EQ(value, generatorProfile->nlaSolveCallString(true, false)); + EXPECT_EQ(value, generatorProfile->nlaSolveCallString(true, true)); + + EXPECT_EQ(value, generatorProfile->objectiveFunctionMethodString(false, false)); + EXPECT_EQ(value, generatorProfile->objectiveFunctionMethodString(false, true)); + EXPECT_EQ(value, generatorProfile->objectiveFunctionMethodString(true, false)); + EXPECT_EQ(value, generatorProfile->objectiveFunctionMethodString(true, true)); + EXPECT_EQ(value, generatorProfile->uArrayString()); EXPECT_EQ(value, generatorProfile->fArrayString()); diff --git a/tests/resources/coverage/generator/model.c b/tests/resources/coverage/generator/model.c index 7560c1283..f5a5cb554 100644 --- a/tests/resources/coverage/generator/model.c +++ b/tests/resources/coverage/generator/model.c @@ -403,6 +403,7 @@ void objectiveFunction0(double *u, double *f, void *data) double *constants = ((RootFindingInfo *) data)->constants; double *computedConstants = ((RootFindingInfo *) data)->computedConstants; double *algebraic = ((RootFindingInfo *) data)->algebraic; + double *externals = ((RootFindingInfo *) data)->externals; algebraic[0] = u[0]; algebraic[1] = u[1]; @@ -411,9 +412,9 @@ void objectiveFunction0(double *u, double *f, void *data) f[1] = algebraic[0]-algebraic[1]-(computedConstants[197]+computedConstants[198]); } -void findRoot0(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic) +void findRoot0(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, double *externals) { - RootFindingInfo rfi = { voi, states, rates, constants, computedConstants, algebraic }; + RootFindingInfo rfi = { voi, states, rates, constants, computedConstants, algebraic, externals }; double u[2]; u[0] = algebraic[0]; @@ -650,5 +651,5 @@ void computeRates(double voi, double *states, double *rates, double *constants, void computeVariables(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable) { externals[0] = externalVariable(voi, states, rates, constants, computedConstants, algebraic, externals, 0); - findRoot0(voi, states, rates, constants, computedConstants, algebraic); + findRoot0(voi, states, rates, constants, computedConstants, algebraic, externals); } diff --git a/tests/resources/coverage/generator/model.implementation.out b/tests/resources/coverage/generator/model.implementation.out index 3f78260f6..e08d72c8b 100644 --- a/tests/resources/coverage/generator/model.implementation.out +++ b/tests/resources/coverage/generator/model.implementation.out @@ -162,6 +162,7 @@ void objectiveFunction0(double *u, double *f, void *data) double *constants = ((RootFindingInfo *) data)->constants; double *computedConstants = ((RootFindingInfo *) data)->computedConstants; double *algebraic = ((RootFindingInfo *) data)->algebraic; + double *externals = ((RootFindingInfo *) data)->externals; algebraic[0] = u[0]; algebraic[1] = u[1]; @@ -170,9 +171,9 @@ void objectiveFunction0(double *u, double *f, void *data) f[1] = algebraic[0]-algebraic[1]-(computedConstants[197]+computedConstants[198]); } -void findRoot0(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic) +void findRoot0(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, double *externals) { - RootFindingInfo rfi = { voi, states, rates, constants, computedConstants, algebraic }; + RootFindingInfo rfi = { voi, states, rates, constants, computedConstants, algebraic, externals }; double u[2]; u[0] = algebraic[0]; @@ -409,5 +410,5 @@ void computeRates(double voi, double *states, double *rates, double *constants, void computeVariables(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable) { externals[0] = externalVariable(voi, states, rates, constants, computedConstants, algebraic, externals, 0); - findRoot0(voi, states, rates, constants, computedConstants, algebraic); + findRoot0(voi, states, rates, constants, computedConstants, algebraic, externals); } diff --git a/tests/resources/coverage/generator/model.modified.profile.c b/tests/resources/coverage/generator/model.modified.profile.c index a539d5704..ad04e9ad0 100644 --- a/tests/resources/coverage/generator/model.modified.profile.c +++ b/tests/resources/coverage/generator/model.modified.profile.c @@ -403,6 +403,7 @@ void objectiveFunction0(double *u, double *f, void *data) double *constants = ((RootFindingInfo *) data)->constants; double *computedConstants = ((RootFindingInfo *) data)->computedConstants; double *algebraic = ((RootFindingInfo *) data)->algebraic; + double *externals = ((RootFindingInfo *) data)->externals; algebraic[0] = u[0]; algebraic[1] = u[1]; @@ -411,9 +412,9 @@ void objectiveFunction0(double *u, double *f, void *data) f[1] = algebraic[0]-algebraic[1]-(computedConstants[197]+computedConstants[198]); } -void findRoot0(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic) +void findRoot0(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, double *externals) { - RootFindingInfo rfi = { voi, states, rates, constants, computedConstants, algebraic }; + RootFindingInfo rfi = { voi, states, rates, constants, computedConstants, algebraic, externals }; double u[2]; u[0] = algebraic[0]; @@ -650,5 +651,5 @@ void computeRates(double voi, double *states, double *rates, double *constants, void computeVariables(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, double *externals, ExternalVariable externalVariable) { externals[0] = externalVariable(voi, states, rates, constants, computedConstants, algebraic, externals, 0); - findRoot0(voi, states, rates, constants, computedConstants, algebraic); + findRoot0(voi, states, rates, constants, computedConstants, algebraic, externals); } diff --git a/tests/resources/coverage/generator/model.modified.profile.py b/tests/resources/coverage/generator/model.modified.profile.py index a953afffa..f6a8f403f 100644 --- a/tests/resources/coverage/generator/model.modified.profile.py +++ b/tests/resources/coverage/generator/model.modified.profile.py @@ -373,6 +373,7 @@ def objective_function_0(u, f, data): constants = data[3] computed_constants = data[4] algebraic = data[5] + externals = data[6] algebraic[0] = u[0] algebraic[1] = u[1] @@ -381,13 +382,13 @@ def objective_function_0(u, f, data): f[1] = algebraic[0]-algebraic[1]-(computed_constants[197]+computed_constants[198]) -def find_root_0(voi, states, rates, constants, computed_constants, algebraic): +def find_root_0(voi, states, rates, constants, computed_constants, algebraic, externals): u = [nan]*2 u[0] = algebraic[0] u[1] = algebraic[1] - u = nla_solve(objective_function_0, u, 2, [voi, states, rates, constants, computed_constants, algebraic]) + u = nla_solve(objective_function_0, u, 2, [voi, states, rates, constants, computed_constants, algebraic, externals]) algebraic[0] = u[0] algebraic[1] = u[1] @@ -614,4 +615,4 @@ def compute_rates(voi, states, rates, constants, computed_constants, algebraic, def compute_variables(voi, states, rates, constants, computed_constants, algebraic, externals, external_variable): externals[0] = external_variable(voi, states, rates, constants, computed_constants, algebraic, externals, 0) - find_root_0(voi, states, rates, constants, computed_constants, algebraic) + find_root_0(voi, states, rates, constants, computed_constants, algebraic, externals) diff --git a/tests/resources/coverage/generator/model.out b/tests/resources/coverage/generator/model.out index 6391e30e4..1d349599c 100644 --- a/tests/resources/coverage/generator/model.out +++ b/tests/resources/coverage/generator/model.out @@ -99,6 +99,7 @@ void objectiveFunction0(double *u, double *f, void *data) double *constants = ((RootFindingInfo *) data)->constants; double *computedConstants = ((RootFindingInfo *) data)->computedConstants; double *algebraic = ((RootFindingInfo *) data)->algebraic; + double *externals = ((RootFindingInfo *) data)->externals; algebraic[0] = u[0]; algebraic[1] = u[1]; @@ -107,9 +108,9 @@ void objectiveFunction0(double *u, double *f, void *data) f[1] = algebraic[0]-algebraic[1]-(computedConstants[197]+computedConstants[198]); } -void findRoot0(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic) +void findRoot0(double voi, double *states, double *rates, double *constants, double *computedConstants, double *algebraic, double *externals) { - RootFindingInfo rfi = { voi, states, rates, constants, computedConstants, algebraic }; + RootFindingInfo rfi = { voi, states, rates, constants, computedConstants, algebraic, externals }; double u[2]; u[0] = algebraic[0]; diff --git a/tests/resources/coverage/generator/model.py b/tests/resources/coverage/generator/model.py index 1fff7c331..06e4823cf 100644 --- a/tests/resources/coverage/generator/model.py +++ b/tests/resources/coverage/generator/model.py @@ -373,6 +373,7 @@ def objective_function_0(u, f, data): constants = data[3] computed_constants = data[4] algebraic = data[5] + externals = data[6] algebraic[0] = u[0] algebraic[1] = u[1] @@ -381,13 +382,13 @@ def objective_function_0(u, f, data): f[1] = algebraic[0]-algebraic[1]-(computed_constants[197]+computed_constants[198]) -def find_root_0(voi, states, rates, constants, computed_constants, algebraic): +def find_root_0(voi, states, rates, constants, computed_constants, algebraic, externals): u = [nan]*2 u[0] = algebraic[0] u[1] = algebraic[1] - u = nla_solve(objective_function_0, u, 2, [voi, states, rates, constants, computed_constants, algebraic]) + u = nla_solve(objective_function_0, u, 2, [voi, states, rates, constants, computed_constants, algebraic, externals]) algebraic[0] = u[0] algebraic[1] = u[1] @@ -614,4 +615,4 @@ def compute_rates(voi, states, rates, constants, computed_constants, algebraic, def compute_variables(voi, states, rates, constants, computed_constants, algebraic, externals, external_variable): externals[0] = external_variable(voi, states, rates, constants, computed_constants, algebraic, externals, 0) - find_root_0(voi, states, rates, constants, computed_constants, algebraic) + find_root_0(voi, states, rates, constants, computed_constants, algebraic, externals) diff --git a/tests/resources/generator/algebraic_eqn_with_one_non_isolated_unknown/model.py b/tests/resources/generator/algebraic_eqn_with_one_non_isolated_unknown/model.py index 0e3d3346d..7d7cc6c89 100644 --- a/tests/resources/generator/algebraic_eqn_with_one_non_isolated_unknown/model.py +++ b/tests/resources/generator/algebraic_eqn_with_one_non_isolated_unknown/model.py @@ -44,6 +44,7 @@ def objective_function_0(u, f, data): constants = data[0] computed_constants = data[1] algebraic = data[2] + externals = data[3] algebraic[0] = u[0] diff --git a/tests/resources/generator/algebraic_system_with_three_linked_unknowns/model.py b/tests/resources/generator/algebraic_system_with_three_linked_unknowns/model.py index 64d958922..fbea6af5a 100644 --- a/tests/resources/generator/algebraic_system_with_three_linked_unknowns/model.py +++ b/tests/resources/generator/algebraic_system_with_three_linked_unknowns/model.py @@ -43,6 +43,7 @@ def objective_function_0(u, f, data): constants = data[0] computed_constants = data[1] algebraic = data[2] + externals = data[3] algebraic[0] = u[0] algebraic[1] = u[1] diff --git a/tests/resources/generator/algebraic_system_with_various_dependencies/model.not.ordered.py b/tests/resources/generator/algebraic_system_with_various_dependencies/model.not.ordered.py index 9398a2d15..e0fce8b03 100644 --- a/tests/resources/generator/algebraic_system_with_various_dependencies/model.not.ordered.py +++ b/tests/resources/generator/algebraic_system_with_various_dependencies/model.not.ordered.py @@ -46,6 +46,7 @@ def objective_function_0(u, f, data): constants = data[0] computed_constants = data[1] algebraic = data[2] + externals = data[3] algebraic[2] = u[0] algebraic[1] = u[1] diff --git a/tests/resources/generator/algebraic_system_with_various_dependencies/model.ordered.py b/tests/resources/generator/algebraic_system_with_various_dependencies/model.ordered.py index 780f9aac8..62bfe3cd5 100644 --- a/tests/resources/generator/algebraic_system_with_various_dependencies/model.ordered.py +++ b/tests/resources/generator/algebraic_system_with_various_dependencies/model.ordered.py @@ -46,6 +46,7 @@ def objective_function_0(u, f, data): constants = data[0] computed_constants = data[1] algebraic = data[2] + externals = data[3] algebraic[0] = u[0] algebraic[1] = u[1]