COPASI API
4.16.103
|
#include <sstream>
#include "compare_utilities.h"
#include "sbml/math/ASTNode.h"
#include "sbml/Model.h"
#include "CNormalBase.h"
#include "CNormalFraction.h"
#include "CNormalFunction.h"
#include "CNormalSum.h"
#include "CNormalProduct.h"
#include "CNormalLogical.h"
#include "CNormalLogicalItem.h"
#include "CNormalChoice.h"
#include "CNormalChoiceLogical.h"
#include "CNormalGeneralPower.h"
#include "CNormalItemPower.h"
#include "CNormalItem.h"
#include "CNormalTranslation.h"
#include "ConvertToCEvaluationNode.h"
#include "copasi/utilities/CCopasiTree.h"
#include "copasi/function/CFunctionDB.h"
#include "copasi/function/CFunction.h"
#include "copasi/function/CFunctionParameters.h"
#include "copasi/function/CFunctionParameter.h"
#include "copasi/function/CEvaluationTree.h"
#include "copasi/function/CEvaluationNode.h"
#include "copasi/function/CEvaluationNodeObject.h"
#include "copasi/sbml/ConverterASTNode.h"
#include "sbml/FunctionDefinition.h"
#include "copasi/model/CChemEq.h"
#include "copasi/model/CChemEqElement.h"
#include "copasi/model/CModel.h"
#include "copasi/model/CModelValue.h"
#include "copasi/utilities/CCopasiParameter.h"
Go to the source code of this file.
Functions | |
bool | are_equal (const CNormalFraction *pLHS, const CNormalFraction *pRHS) |
bool | contains_necessary_mass_action_elements (const CCopasiVector< CChemEqElement > &elements, const CNormalProduct *pProduct, const CModel *pModel) |
ASTNode * | create_expression (const ASTNode *pSource, const ListOfFunctionDefinitions *pFunctions) |
CNormalFraction * | create_normalform (const ASTNode *pSource) |
CNormalFraction * | create_simplified_normalform (const ASTNode *pSource) |
ASTNode * | expand_function_call (const ASTNode *pCall, const ListOfFunctionDefinitions *pFunctions) |
CEvaluationNode * | expand_function_call (const CEvaluationNodeCall *pCall, CFunctionDB *pFunctionDB) |
ASTNode * | expand_function_calls (const ASTNode *pNode, const ListOfFunctionDefinitions *pFunctions) |
CEvaluationNode * | expand_function_calls (const CEvaluationNode *pNode, CFunctionDB *pFunctionDB) |
bool | is_mass_action (const CNormalFraction *pFrac, const CModel *pModel, const CChemEq *pChemEq) |
void | normalize_variable_names (CNormalBase *pBase, std::map< std::string, std::string > &variableMap) |
ASTNode * | replace_ARCCOSH (const ASTNode *pChild) |
ASTNode * | replace_ARCCSCH (const ASTNode *pChild) |
ASTNode * | replace_ARCSECH (const ASTNode *pChild) |
ASTNode * | replace_ARCSINH (const ASTNode *pChild) |
ASTNode * | replace_ARCTANH (const ASTNode *pChild) |
ASTNode * | replace_COSH (const ASTNode *pChild) |
ASTNode * | replace_COT (const ASTNode *pChild) |
ASTNode * | replace_COTH (const ASTNode *pChild) |
ASTNode * | replace_CSC (const ASTNode *pChild) |
ASTNode * | replace_CSCH (const ASTNode *pChild) |
ASTNode * | replace_SEC (const ASTNode *pChild) |
ASTNode * | replace_SECH (const ASTNode *pChild) |
ASTNode * | replace_SINH (const ASTNode *pChild) |
ASTNode * | replace_TANH (const ASTNode *pChild) |
ASTNode * | replace_variable_names (const ASTNode *pNode, const std::map< std::string, const ASTNode * > &argumentMap) |
CEvaluationNode * | replace_variable_names (const CEvaluationNode *pNode, const std::map< std::string, const CEvaluationNode * > &argumentMap) |
bool are_equal | ( | const CNormalFraction * | pLHS, |
const CNormalFraction * | pRHS | ||
) |
This method takes two normalforms and normalizes the variable names in both expressions. Afterwards the two expressions are compared. If they are equal true is returned.
Definition at line 223 of file compare_utilities.cpp.
References normalize_variable_names().
Referenced by stress_test::normalizeAndSimplifyExpressions(), and stress_test::run().
bool contains_necessary_mass_action_elements | ( | const CCopasiVector< CChemEqElement > & | elements, |
const CNormalProduct * | pProduct, | ||
const CModel * | pModel | ||
) |
Returns true if the CNormalProduct contains objects fro all elements in the elements vector with the correct stoichiometry plut one item that represents the mass action kinetic parameter. This method i sused in is_mass_action once for the substrates and if the reaction is reversible once for the products.
Definition at line 1215 of file compare_utilities.cpp.
References CCopasiVector< T >::begin(), CCopasiVector< T >::end(), CNormalProduct::getItemPowers(), CNormalItem::getName(), CCopasiObject::getObjectParent(), CNormalItem::getType(), CCopasiObject::isReference(), CNormalItemPower::ITEM, CCopasiDataModel::ObjectFromName(), CCopasiVector< T >::remove(), CCopasiVector< T >::size(), and CNormalItem::VARIABLE.
Referenced by is_mass_action().
ASTNode* create_expression | ( | const ASTNode * | pSource, |
const ListOfFunctionDefinitions * | pFunctions | ||
) |
Creates an expanded expression from the given expression. This method expands all function calls. On failure NULL is returned, otherwise an expanded copy of the original node is returned.
Definition at line 72 of file compare_utilities.cpp.
References expand_function_calls(), and pResult.
Referenced by CSBMLExporter::convertASTTreeToLevel1(), and stress_test::normalizeAndSimplifyExpressions().
CNormalFraction* create_normalform | ( | const ASTNode * | pSource | ) |
This method converts a given ASTNode into a CNormalFraction. The resulting normalform is not necessarily simplified.
Definition at line 497 of file compare_utilities.cpp.
References CEvaluationNodeVariable::ANY, createNormalRepresentation(), and CEvaluationTree::fromAST().
CNormalFraction* create_simplified_normalform | ( | const ASTNode * | pSource | ) |
This method converts a given ASTNode into a CNormalFraction. The expression is simplified in the process to create the "final" normalform.
Definition at line 445 of file compare_utilities.cpp.
References CEvaluationNodeVariable::ANY, CEvaluationTree::fromAST(), and CNormalTranslation::normAndSimplifyReptdly().
Referenced by stress_test::normalizeAndSimplifyExpressions(), and stress_test::normalizeAndSimplifyFunctionDefinitions().
ASTNode* expand_function_call | ( | const ASTNode * | pCall, |
const ListOfFunctionDefinitions * | pFunctions | ||
) |
This method expands the given function call. On failure NULL is returned, otherwise on expression of the expanded function call is returned.
Definition at line 143 of file compare_utilities.cpp.
References pResult, and replace_variable_names().
Referenced by expand_function_calls().
CEvaluationNode* expand_function_call | ( | const CEvaluationNodeCall * | pCall, |
CFunctionDB * | pFunctionDB | ||
) |
This method expands the given function call. On failure NULL is returned, otherwise on expression of the expanded function call is returned.
Definition at line 1062 of file compare_utilities.cpp.
References CEvaluationNode::copyBranch(), CFunctionDB::findFunction(), CCopasiNode< _Data >::getChild(), CEvaluationNodeCall::getData(), CCopasiObject::getObjectName(), CEvaluationTree::getRoot(), CCopasiNode< _Data >::getSibling(), CFunction::getVariables(), pResult, replace_variable_names(), and CFunctionParameters::size().
ASTNode* expand_function_calls | ( | const ASTNode * | pNode, |
const ListOfFunctionDefinitions * | pFunctions | ||
) |
This method expands the function calls in the given expression. On failure NULL is returned, otherwise a copy of the original node is returned where all function calls have been expanded.
Definition at line 84 of file compare_utilities.cpp.
References expand_function_call(), expand_function_calls(), pResult, and ConverterASTNode::shallowCopy().
Referenced by create_expression(), expand_function_calls(), stress_test::normalizeAndSimplifyFunctionDefinitions(), stress_test::normalizeFunctionDB(), and test_compare_utilities::test_copasi_function_expansion().
CEvaluationNode* expand_function_calls | ( | const CEvaluationNode * | pNode, |
CFunctionDB * | pFunctionDB | ||
) |
This method expands the function calls in the given expression. On failure NULL is returned, otherwise a copy of the original node is returned where all function calls have been expanded.
Definition at line 1005 of file compare_utilities.cpp.
References CCopasiNode< _Data >::addChild(), CEvaluationNode::copyNode(), expand_function_call(), expand_function_calls(), CCopasiNode< _Data >::getChild(), CCopasiNode< _Data >::getSibling(), and pResult.
bool is_mass_action | ( | const CNormalFraction * | pFrac, |
const CModel * | pModel, | ||
const CChemEq * | pChemEq | ||
) |
This function determines if a given kinetic law represents a constant flux reaction. bool isConstantFlux(const ASTNode* pNode,bool singleCompartment); This function determines if a given kinetic law represents an irreversible mass action kinetics. bool isIrevMassAction(const ASTNode* pNode,const std::vector<std::pair<std::string,double> >& substrates); This function determines if a given kinetic law represents an reversible mass action kinetics. bool isRevMassAction(const ASTNode* pNode,const std::vector<std::pair<std::string,double> >& substrates,const std::vector<std::pair<std::string,double> >& products); Returns true if the given CNormalFraction represents a mass action kinetics for the provided chemical equation.
Definition at line 1134 of file compare_utilities.cpp.
References C_FLOAT64, CNormalFraction::checkDenominatorOne(), contains_necessary_mass_action_elements(), CNormalSum::getFractions(), CNormalFraction::getNumerator(), CChemEq::getProducts(), CNormalSum::getProducts(), CChemEq::getReversibility(), and CChemEq::getSubstrates().
void normalize_variable_names | ( | CNormalBase * | pBase, |
std::map< std::string, std::string > & | variableMap | ||
) |
This method normalizes the variable names in a given normalform expression. The first variable found in the expression is named "variable1", the second "variable2" and so on.
Definition at line 245 of file compare_utilities.cpp.
References CNormalFraction::checkDenominatorOne(), CNormalLogical::cleanSetOfSets(), CNormalLogical::getAndSets(), CNormalLogical::getChoices(), CNormalChoice::getCondition(), CNormalFraction::getDenominator(), CNormalChoice::getFalseExpression(), CNormalFunction::getFraction(), CNormalSum::getFractions(), CNormalItemPower::getItem(), CNormalProduct::getItemPowers(), CNormalLogicalItem::getLeft(), CNormalGeneralPower::getLeft(), CNormalItem::getName(), CNormalFraction::getNumerator(), CNormalSum::getProducts(), CNormalLogicalItem::getRight(), CNormalGeneralPower::getRight(), CNormalChoice::getTrueExpression(), CNormalItem::getType(), normalize_variable_names(), CNormalLogical::setAndSets(), CNormalLogical::setChoices(), CNormalSum::setFractions(), CNormalProduct::setItemPowers(), CNormalItem::setName(), CNormalSum::setProducts(), and CNormalItem::VARIABLE.
Referenced by are_equal(), and normalize_variable_names().
ASTNode* replace_ARCCOSH | ( | const ASTNode * | pChild | ) |
This function replaces a call to ARCCOSH by log(X + sqrt(X-1) * sqrt(X+1))
Definition at line 827 of file compare_utilities.cpp.
References pResult.
Referenced by CSBMLExporter::replaceL1IncompatibleNodes().
ASTNode* replace_ARCCSCH | ( | const ASTNode * | pChild | ) |
This function replaces a call to ARCCSCH by log(sqrt(1+ (1/ (X^2)))+(1/X))
Definition at line 962 of file compare_utilities.cpp.
References pResult.
Referenced by CSBMLExporter::replaceL1IncompatibleNodes().
ASTNode* replace_ARCSECH | ( | const ASTNode * | pChild | ) |
This function replaces a call to ARCSECH by log(sqrt((1/X)-1) * sqrt(1+(1/X)) + 1/X)
Definition at line 905 of file compare_utilities.cpp.
References pResult.
Referenced by CSBMLExporter::replaceL1IncompatibleNodes().
ASTNode* replace_ARCSINH | ( | const ASTNode * | pChild | ) |
This function replaces a call to ARCSINH by log(X + sqrt(X^2 + 1))
Definition at line 793 of file compare_utilities.cpp.
References pResult.
Referenced by CSBMLExporter::replaceL1IncompatibleNodes().
ASTNode* replace_ARCTANH | ( | const ASTNode * | pChild | ) |
This function replaces a call to ARCTANH by 1/2 * (log(1+X) - log(1-X))
Definition at line 869 of file compare_utilities.cpp.
References pResult.
Referenced by CSBMLExporter::replaceL1IncompatibleNodes().
ASTNode* replace_COSH | ( | const ASTNode * | pChild | ) |
This function replaces a call to COSH by (e^X+e^(-X))/2
Definition at line 639 of file compare_utilities.cpp.
References pResult.
Referenced by CSBMLExporter::replaceL1IncompatibleNodes().
ASTNode* replace_COT | ( | const ASTNode * | pChild | ) |
This function replaces a call to COT by COS/SIN.
Definition at line 590 of file compare_utilities.cpp.
References pResult.
Referenced by CSBMLExporter::replaceL1IncompatibleNodes().
ASTNode* replace_COTH | ( | const ASTNode * | pChild | ) |
This function replaces a call to COTH by (e^X+e^(-X))/(e^X-e^(-X))
Definition at line 758 of file compare_utilities.cpp.
References pResult.
Referenced by CSBMLExporter::replaceL1IncompatibleNodes().
ASTNode* replace_CSC | ( | const ASTNode * | pChild | ) |
This function replaces a call to CSC by 1/SIN.
Definition at line 569 of file compare_utilities.cpp.
References pResult.
Referenced by CSBMLExporter::replaceL1IncompatibleNodes().
ASTNode* replace_CSCH | ( | const ASTNode * | pChild | ) |
This function replaces a call to CSCH by 2/(e^X-e^(-X))
Definition at line 730 of file compare_utilities.cpp.
References pResult.
Referenced by CSBMLExporter::replaceL1IncompatibleNodes().
ASTNode* replace_SEC | ( | const ASTNode * | pChild | ) |
This function replaces a call to SEC by 1/COS.
Definition at line 548 of file compare_utilities.cpp.
References pResult.
Referenced by CSBMLExporter::replaceL1IncompatibleNodes().
ASTNode* replace_SECH | ( | const ASTNode * | pChild | ) |
This function replaces a call to SECH by 2/(e^X+e^(-X))
Definition at line 702 of file compare_utilities.cpp.
References pResult.
Referenced by CSBMLExporter::replaceL1IncompatibleNodes().
ASTNode* replace_SINH | ( | const ASTNode * | pChild | ) |
This function replaces a call to SINH by (e^X-e^(-X))/2.
Definition at line 611 of file compare_utilities.cpp.
References pResult.
Referenced by CSBMLExporter::replaceL1IncompatibleNodes().
ASTNode* replace_TANH | ( | const ASTNode * | pChild | ) |
This function replaces a call to TANH by (e^X-e^(-X))/(e^X+e^(-X))
Definition at line 667 of file compare_utilities.cpp.
References pResult.
Referenced by CSBMLExporter::replaceL1IncompatibleNodes().
ASTNode* replace_variable_names | ( | const ASTNode * | pNode, |
const std::map< std::string, const ASTNode * > & | argumentMap | ||
) |
Definition at line 177 of file compare_utilities.cpp.
References pResult, replace_variable_names(), and ConverterASTNode::shallowCopy().
Referenced by expand_function_call(), and replace_variable_names().
CEvaluationNode* replace_variable_names | ( | const CEvaluationNode * | pNode, |
const std::map< std::string, const CEvaluationNode * > & | argumentMap | ||
) |
Definition at line 1100 of file compare_utilities.cpp.
References CCopasiNode< _Data >::addChild(), CEvaluationNode::copyNode(), CCopasiNode< _Data >::getChild(), CCopasiNode< _Data >::getData(), CCopasiNode< _Data >::getSibling(), pResult, and replace_variable_names().