COPASI API  4.40.278
COptProblem Class Reference

#include <COptProblem.h>

Inheritance diagram for COptProblem:
[legend]

Classes

struct  sCounter
 

Public Member Functions

COptItemaddOptConstraint (const CCommonName &objectCN)
 
COptItemaddOptItem (const CCommonName &objectCN)
 
C_FLOAT64 adjustForIntervals (C_FLOAT64 *pValue, const C_FLOAT64 &min, const C_FLOAT64 &max)
 
bool adjustStartValue (COptItem &optItem)
 
bool adjustStartValuesForIntervals ()
 
virtual bool calculate ()
 
virtual bool calculateStatistics (const C_FLOAT64 &factor=1.0e-003, const C_FLOAT64 &resolution=1.0e-009)
 
virtual void calculateValue () override
 
virtual bool checkFunctionalConstraints ()
 
bool checkIntervals ()
 
virtual bool checkParametricConstraints ()
 
 COptProblem (const COptProblem &src, const CDataContainer *pParent)
 
 COptProblem (const CTaskEnum::Task &type=CTaskEnum::Task::optimization, const CDataContainer *pParent=NO_PARENT)
 
virtual bool elevateChildren () override
 
C_FLOAT64 evalMinimizeIntervals (const C_FLOAT64 &value)
 
const unsigned C_INT32geFailedConstraintCounter () const
 
const bool & getCalculateStatistics () const
 
const C_FLOAT64getCalculateValue () const
 
const unsigned C_INT32getConstraintEvaluations () const
 
const std::vector< COptItem * > & getConstraintList () const
 
CVectorCore< C_FLOAT64 * > & getContainerVariables (const bool &algorithmOrder=false) const
 
const sCountergetCounters () const
 
const C_FLOAT64getExecutionTime () const
 
const unsigned C_INT32getFailedEvaluationsExc () const
 
const unsigned C_INT32getFailedEvaluationsNaN () const
 
const unsigned C_INT32getFunctionEvaluations () const
 
const std::string getObjectiveFunction ()
 
COptItemgetOptConstraint (const size_t &index)
 
size_t getOptConstraintSize () const
 
COptItemgetOptItem (const size_t &index)
 
const std::vector< COptItem * > & getOptItemList (const bool &algorithmOrder=false) const
 
size_t getOptItemSize () const
 
const bool & getRandomizeStartValues () const
 
const C_FLOAT64getSolutionValue () const
 
const CVector< C_FLOAT64 > & getSolutionVariables (const bool &algorithmOrder=false) const
 
virtual CCopasiTaskgetSubTask () const override
 
CTaskEnum::Task getSubtaskType () const
 
virtual void * getValuePointer () const override
 
const CVector< C_FLOAT64 > & getVariableGradients () const
 
size_t getVariableSize () const
 
void incrementCounters (const sCounter &increment)
 
virtual bool initialize () override
 
virtual bool initializeSubtaskBeforeOutput ()
 
const bool & maximize () const
 
virtual void print (std::ostream *ostream) const override
 
virtual void printResult (std::ostream *ostream) const override
 
void randomizeStartValues ()
 
void rememberStartValues ()
 
bool removeOptConstraint (const size_t &index)
 
bool removeOptItem (const size_t &index)
 
void reset ()
 
void resetCounters ()
 
virtual bool restore (const bool &updateModel) override
 
void setCalculateStatistics (const bool &calculate)
 
virtual bool setCallBack (CProcessReportLevel callBack) override
 
void setMaximize (const bool &maximize)
 
bool setObjectiveFunction (const std::string &infix)
 
void setParameters (const CVectorCore< C_FLOAT64 > &parameters)
 
void setRandomizeStartValues (const bool &randomize)
 
virtual bool setSolution (const C_FLOAT64 &value, const CVector< C_FLOAT64 > &variables, const bool &algorithmOrder=false)
 
CCommonName setSubtaskType (const CTaskEnum::Task &subtaskType)
 
bool swapOptItem (const size_t &iFrom, const size_t &iTo)
 
virtual ~COptProblem ()
 
- Public Member Functions inherited from CCopasiProblem
 CCopasiProblem (const CCopasiProblem &src, const CDataContainer *pParent)
 
virtual void clearCallBack ()
 
CCopasiProblemcopy () const
 
const CProcessReportLevelgetCallBack () const
 
CMathContainergetMathContainer () const
 
const CTaskEnum::TaskgetType () const
 
void setMathContainer (CMathContainer *pContainer)
 
virtual bool setModel (CModel *model)
 
virtual ~CCopasiProblem ()
 
- Public Member Functions inherited from CCopasiParameterGroup
bool addGroup (const std::string &name)
 
void addParameter (CCopasiParameter *pParameter)
 
bool addParameter (const CCopasiParameter &parameter)
 
bool addParameter (const std::string &name, const CCopasiParameter::Type type, const CCopasiParameter::UserInterfaceFlag &flag=CCopasiParameter::UserInterfaceFlag::All)
 
template<class CType >
bool addParameter (const std::string &name, const CCopasiParameter::Type type, const CType &value, const CCopasiParameter::UserInterfaceFlag &flag=CCopasiParameter::UserInterfaceFlag::All)
 
virtual bool applyData (const CData &data, CUndoData::CChangeSet &changes)
 
CCopasiParameterGroupassertGroup (const std::string &name, const CCopasiParameter::UserInterfaceFlag &flag=CCopasiParameter::UserInterfaceFlag::All)
 
template<class CType >
CType * assertParameter (const std::string &name, const CCopasiParameter::Type type, const CType &defaultValue, const CCopasiParameter::UserInterfaceFlag &flag=CCopasiParameter::UserInterfaceFlag::All)
 
index_iterator beginIndex () const
 
const_name_iterator beginName () const
 
 CCopasiParameterGroup (const CCopasiParameterGroup &src, const CDataContainer *pParent=NULL)
 
 CCopasiParameterGroup (const std::string &name, const CDataContainer *pParent=NO_PARENT, const std::string &objectType="ParameterGroup")
 
void clear ()
 
virtual void createUndoData (CUndoData &undoData, const CUndoData::Type &type, const CData &oldData=CData(), const CCore::Framework &framework=CCore::Framework::ParticleNumbers) const
 
index_iterator endIndex () const
 
const_name_iterator endName () const
 
CCopasiParameterGroupgetElementTemplates ()
 
const CCopasiParameterGroupgetElementTemplates () const
 
CCopasiParameterGroupgetGroup (const size_t &index)
 
const CCopasiParameterGroupgetGroup (const size_t &index) const
 
CCopasiParameterGroupgetGroup (const std::string &name)
 
const CCopasiParameterGroupgetGroup (const std::string &name) const
 
virtual size_t getIndex (const CDataObject *pObject) const
 
size_t getIndex (const std::string &name) const
 
std::string getKey (const size_t &index) const
 
std::string getKey (const std::string &name) const
 
virtual const std::string & getName (const size_t &index) const
 
virtual const CObjectInterfacegetObject (const CCommonName &cn) const
 
CCopasiParametergetParameter (const size_t &index)
 
const CCopasiParametergetParameter (const size_t &index) const
 
CCopasiParametergetParameter (std::string name)
 
const CCopasiParametergetParameter (std::string name) const
 
CCopasiParameter::Type getType (const size_t &index) const
 
CCopasiParameter::Type getType (const std::string &name) const
 
std::string getUniqueParameterName (const CCopasiParameter *pParameter) const
 
template<class CType >
CType & getValue (const size_t &index)
 
template<class CType >
const CType & getValue (const size_t &index) const
 
template<class CType >
CType & getValue (const std::string &name)
 
template<class CType >
const CType & getValue (const std::string &name) const
 
bool haveTemplate () const
 
virtual CUndoObjectInterfaceinsert (const CData &data)
 
CCopasiParameterGroupoperator= (const CCopasiParameterGroup &rhs)
 
virtual bool remove (CDataObject *pObject)
 
bool removeParameter (CCopasiParameter *pParameter)
 
bool removeParameter (const size_t &index)
 
bool removeParameter (const std::string &name)
 
virtual void setUserInterfaceFlag (const UserInterfaceFlag &flag)
 
template<class CType >
bool setValue (const size_t &index, const CType &value)
 
template<class CType >
bool setValue (const std::string &name, const CType &value)
 
size_t size (const UserInterfaceFlag &require=UserInterfaceFlag::None, const UserInterfaceFlag &exclude=UserInterfaceFlag::None) const
 
bool swap (const size_t &iFrom, const size_t &iTo)
 
bool swap (index_iterator &from, index_iterator &to)
 
virtual CData toData () const
 
virtual void updateIndex (const size_t &index, const CUndoObjectInterface *pUndoObject)
 
virtual ~CCopasiParameterGroup ()
 
- Public Member Functions inherited from CCopasiParameter
 CCopasiParameter (const CCopasiParameter &src, const CDataContainer *pParent)
 
 CCopasiParameter (const std::string &name, const Type &type, const void *pValue=NULL, const CDataContainer *pParent=NO_PARENT, const std::string &objectType="Parameter")
 
virtual CCommonName getCN () const override
 
template<class CType >
const CType & getDefault () const
 
virtual const std::string & getKey () const override
 
virtual std::string getObjectDisplayName () const override
 
const CCopasiParameter::TypegetType () const
 
const UserInterfaceFlaggetUserInterfaceFlag () const
 
template<class CType >
std::vector< std::pair< CType, CType > > & getValidValues ()
 
template<class CType >
const std::vector< std::pair< CType, CType > > & getValidValues () const
 
void * getValidValuesPointer () const
 
template<class CType >
CType & getValue ()
 
template<class CType >
const CType & getValue () const
 
CDataObjectgetValueReference () const
 
bool hasValidValues () const
 
bool isBasic () const
 
bool isDefault () const
 
bool isEditable () const
 
bool isUnsupported () const
 
bool isValidValue (const bool &value) const
 
bool isValidValue (const C_FLOAT64 &value) const
 
bool isValidValue (const C_INT32 &value) const
 
bool isValidValue (const CCommonName &value) const
 
template<class CType >
bool isValidValue (const CType &) const
 
bool isValidValue (const std::string &value) const
 
bool isValidValue (const std::vector< CCopasiParameter * > &value) const
 
bool isValidValue (const unsigned C_INT32 &value) const
 
CCopasiParameteroperator= (const CCopasiParameter &rhs)
 
template<class CType >
bool setDefault (const CType &defaultValue)
 
bool setDefault (const std::vector< CCopasiParameter * > &defaultValue)
 
virtual bool setObjectParent (const CDataContainer *pParent) override
 
template<class CType , class Enum >
bool setValidValues (const CEnumAnnotation< CType, Enum > &validValues)
 
template<class CType >
bool setValidValues (const std::vector< std::pair< CType, CType > > &validValues)
 
template<class CType >
bool setValue (const CType &value)
 
bool setValue (const std::vector< CCopasiParameter * > &value)
 
virtual ~CCopasiParameter ()
 
- Public Member Functions inherited from CDataContainer
virtual bool add (CDataObject *pObject, const bool &adopt=true)
 
virtual bool appendDeletedDependentData (CUndoData &undoData) const
 
 CDataContainer (const CDataContainer &src, const CDataContainer *pParent)
 
 CDataContainer (const std::string &name, const CDataContainer *pParent=NO_PARENT, const std::string &type="CN", const CFlags< Flag > &flag=CFlags< Flag >::None)
 
virtual std::string getChildObjectUnits (const CDataObject *pObject) const
 
void getDescendants (CDataObject::DataObjectSet &descendants, const bool &recursive=false) const
 
virtual objectMapgetObjects ()
 
virtual const objectMapgetObjects () const
 
virtual const std::string getUnits () const override
 
virtual const CDataObjectgetValueObject () const override
 
void objectRenamed (CDataObject *pObject, const std::string &oldName)
 
virtual ~CDataContainer ()
 
- Public Member Functions inherited from CDataObject
void addIssue (const CIssue &issue)
 
void addReference (const CDataContainer *pReference)
 
 CDataObject (const CDataObject &src, const CDataContainer *pParent=NULL)
 
virtual void destruct () override
 
virtual const CDataObjectgetDataObject () const override
 
CDataContainergetObjectAncestor (const std::string &type) const
 
CDataModelgetObjectDataModel () const
 
const CObjectInterfacegetObjectFromCN (const CCommonName &cn) const
 
const std::string & getObjectName () const
 
CDataContainergetObjectParent () const
 
const std::string & getObjectType () const
 
virtual const CObjectInterface::ObjectSetgetPrerequisites () const override
 
virtual const CValiditygetValidity () const override
 
bool hasFlag (const Flag &flag) const
 
virtual bool isPrerequisiteForContext (const CObjectInterface *pObject, const CCore::SimulationContextFlag &context, const CObjectInterface::ObjectSet &changedObjects) const override
 
bool prerequisitsContains (const DataObjectSet &objects) const
 
void removeIssue (const CIssue &issue)
 
void removeReference (const CDataContainer *pReference)
 
bool setObjectName (const std::string &name)
 
void validityChanged (const CValidity &changedValidity) override
 
void validityRemoved (const CValidity &changedValidity)
 
virtual ~CDataObject ()
 
- Public Member Functions inherited from CObjectInterface
 CObjectInterface ()
 
 CObjectInterface (const CObjectInterface &src)
 
virtual ~CObjectInterface ()
 
- Public Member Functions inherited from CUndoObjectInterface
 CUndoObjectInterface ()
 
 CUndoObjectInterface (const CUndoObjectInterface &src)
 
bool generateUuid ()
 
const xg::Guid & getUuid () const
 
bool setUuid (const std::string &uuid)
 
bool setUuid (const xg::Guid &uuid)
 
virtual ~CUndoObjectInterface ()
 

Static Public Attributes

static const CTaskEnum::Task ValidSubtasks []
 
- Static Public Attributes inherited from CCopasiParameter
static const CEnumAnnotation< std::string, TypeTypeName
 
static const CEnumAnnotation< std::string, TypeXMLType
 
- Static Public Attributes inherited from CDataContainer
static const CObjectInterface::ContainerList EmptyList
 

Protected Member Functions

virtual void updateContainer (const bool &update)
 
- Protected Member Functions inherited from CCopasiProblem
 CCopasiProblem (const CCopasiProblem &src)
 
 CCopasiProblem (const CTaskEnum::Task &type, const CDataContainer *pParent)
 
virtual void signalMathContainerChanged ()
 
- Protected Member Functions inherited from CCopasiParameterGroup
 CCopasiParameterGroup ()
 
- Protected Member Functions inherited from CCopasiParameter
 CCopasiParameter (const CCopasiParameter &src)
 
- Protected Member Functions inherited from CDataContainer
template<class CType >
CDataMatrixReference< CType > * addMatrixReference (const std::string &name, CType &reference, const CFlags< Flag > &flag=CFlags< Flag >::None)
 
template<class CType >
CDataObjectReference< CType > * addObjectReference (const std::string &name, CType &reference, const CFlags< Flag > &flag=CFlags< Flag >::None)
 
template<class CType >
CDataVectorReference< CType > * addVectorReference (const std::string &name, CType &reference, const CFlags< Flag > &flag=CFlags< Flag >::None)
 
 CDataContainer (const CDataContainer &src)
 
void initObjects ()
 
- Protected Member Functions inherited from CDataObject
 CDataObject ()
 
 CDataObject (const std::string &name, const CDataContainer *pParent=static_cast< CDataContainer * >((void *) 0), const std::string &type="CN", const CFlags< Flag > &flag=CFlags< Flag >::None)
 

Protected Attributes

std::set< COptItem * > mAdjustedItems
 
C_FLOAT64 mCalculateValue
 
CVector< C_FLOAT64 * > mContainerVariables
 
CVector< C_FLOAT64 * > mContainerVariablesAlgorithm
 
sCounter mCounters
 
size_t mCountInfluencingIntervals
 
CCopasiTimer mCPUTime
 
CVector< C_FLOAT64mGradient
 
bool mHaveStatistics
 
size_t mhCounter
 
size_t mhSolutionValue
 
CCore::CUpdateSequence mInitialRefreshSequence
 
C_FLOAT64 mMinInterval
 
std::map< COptItem *, size_t > mOptItem2Index
 
std::vector< COptItem * > mOptItemAlgorithm
 
CVector< C_FLOAT64mOriginalVariables
 
C_FLOAT64mpAdjust
 
std::vector< COptItem * > * mpConstraintItems
 
CCopasiParameterGroupmpGrpConstraints
 
CCopasiParameterGroupmpGrpItems
 
CMathExpressionmpMathObjectiveExpression
 
CExpressionmpObjectiveExpression
 
std::vector< COptItem * > * mpOptItems
 
bool * mpParmCalculateStatistics
 
bool * mpParmMaximize
 
std::string * mpParmObjectiveExpression
 
bool * mpParmRandomizeStartValues
 
std::string * mpParmSubTaskCN
 
CCopasiTaskmpSubTask
 
CCopasiTaskmpSubTaskSrc
 
C_FLOAT64 mSolutionValue
 
CVector< C_FLOAT64mSolutionVariables
 
CVector< C_FLOAT64mSolutionVariablesAlgorithm
 
bool mStoreResults
 
CCore::CUpdateSequence mUpdateConstraints
 
CCore::CUpdateSequence mUpdateIntervals
 
CCore::CUpdateSequence mUpdateObjectiveFunction
 
C_FLOAT64 mWorstValue
 
- Protected Attributes inherited from CCopasiProblem
CMathContainermpContainer
 
CReportmpReport
 
CProcessReportLevel mProcessReport
 
- Protected Attributes inherited from CCopasiParameter
std::string mKey
 
void * mpDefault
 
void * mpValidValues
 
void * mpValue
 
CDataObjectmpValueReference
 
UserInterfaceFlag mUserInterfaceFlag
 
- Protected Attributes inherited from CDataContainer
objectMap mObjects
 
- Protected Attributes inherited from CDataObject
ObjectSet mPrerequisits
 
std::set< CDataContainer * > mReferences
 
- Protected Attributes inherited from CObjectInterface
CValidity mValidity
 

Private Member Functions

void initializeParameter ()
 
void initObjects ()
 

Static Private Attributes

static C_FLOAT64 MissingValue
 

Friends

std::ostream & operator<< (std::ostream &os, const COptProblem &o)
 

Additional Inherited Members

- Public Types inherited from CCopasiParameterGroup
typedef CDataObjectMap::const_type_iterator< CCopasiParameterconst_name_iterator
 
typedef std::vector< CCopasiParameter * > elements
 
typedef elements::iterator index_iterator
 
typedef CDataObjectMap::type_iterator< CCopasiParametername_iterator
 
- Public Types inherited from CCopasiParameter
enum class  eUserInterfaceFlag { editable , basic , unsupported , __SIZE }
 
enum class  Type {
  DOUBLE = 0 , UDOUBLE , INT , UINT ,
  BOOL , GROUP , STRING , CN ,
  KEY , FILE , EXPRESSION , INVALID ,
  __SIZE
}
 
typedef CFlags< eUserInterfaceFlagUserInterfaceFlag
 
- Public Types inherited from CDataContainer
typedef CDataObjectMap objectMap
 
- Public Types inherited from CDataObject
typedef std::set< const CDataObject * > DataObjectSet
 
enum  Flag {
  Container , Vector , Matrix , NameVector ,
  Reference , ValueBool , ValueInt , ValueInt64 ,
  ValueDbl , NonUniqueName , StaticString , ValueString ,
  Separator , DisplayName , ModelEntity , Array ,
  DataModel , Root , Gui , __SIZE
}
 
- Public Types inherited from CObjectInterface
typedef std::vector< const CDataContainer * > ContainerList
 
typedef std::set< const CObjectInterface * > ObjectSet
 
- Static Public Member Functions inherited from CCopasiParameter
static void allocateValidValues (const Type &type, void *&pValidValues)
 
static void allocateValue (const Type &type, void *&pValue)
 
static void assignValue (const Type &type, void *&pValue, const void *pNewValue)
 
static void deleteValidValues (const Type &type, void *&pValidValues)
 
static void deleteValue (const Type &type, void *&pValue)
 
static CCopasiParameterfromData (const CData &data, CUndoObjectInterface *pParent)
 
- Static Public Member Functions inherited from CDataContainer
static CDataContainerfromData (const CData &data, CUndoObjectInterface *pParent)
 
- Static Public Member Functions inherited from CDataObject
static CDataObjectfromData (const CData &data, CUndoObjectInterface *pParent)
 
static void sanitizeObjectName (std::string &name)
 
- Static Public Member Functions inherited from CObjectInterface
static const CDataObjectDataObject (const CObjectInterface *pInterface)
 
static CObjectInterfaceGetObjectFromCN (const ContainerList &listOfContainer, const CCommonName &objName)
 
- Static Public Member Functions inherited from CUndoObjectInterface
template<class CType >
static CType * fromData (const CData &, CUndoObjectInterface *)
 

Constructor & Destructor Documentation

◆ COptProblem() [1/2]

COptProblem::COptProblem ( const CTaskEnum::Task type = CTaskEnum::Task::optimization,
const CDataContainer pParent = NO_PARENT 
)

Default constructor

Parameters
constCTaskEnum::Task & type (default: optimization)
constCDataContainer * pParent (default: NULL)

References initializeParameter(), and initObjects().

◆ COptProblem() [2/2]

COptProblem::COptProblem ( const COptProblem src,
const CDataContainer pParent 
)

Copy constructor.

Parameters
constCOptProblem & src
constCDataContainer * pParent (default: NULL)

References initializeParameter(), and initObjects().

◆ ~COptProblem()

COptProblem::~COptProblem ( )
virtual

Destructor

References mpSubTask, and pdelete.

Member Function Documentation

◆ addOptConstraint()

COptItem & COptProblem::addOptConstraint ( const CCommonName objectCN)

Add an optimization constraint to the problem.

Parameters
constCCommonName & objectCN
Returns
COptItem optItemAdded

References CCopasiParameterGroup::addParameter(), CDataObject::getObjectDataModel(), mpGrpConstraints, and COptItem::setObjectCN().

◆ addOptItem()

COptItem & COptProblem::addOptItem ( const CCommonName objectCN)

Add an optimization item to the problem.

Parameters
constCCommonName & objectCN
Returns
COptItem optItemAdded

References CCopasiParameterGroup::addParameter(), CDataObject::getObjectDataModel(), mpGrpItems, and COptItem::setObjectCN().

◆ adjustForIntervals()

C_FLOAT64 COptProblem::adjustForIntervals ( C_FLOAT64 pValue,
const C_FLOAT64 min,
const C_FLOAT64 max 
)

Adjust the value so that all intervals are >= 0

Parameters
C_FLOAT64* pValue
constC_FLOAT64 & min
constC_FLOAT64 & max
Returns
C_FLOAT64 adjusted (NaN if not adjustable)

References C_FLOAT64, evalMinimizeIntervals(), CBrent::findMinimum(), max, min, and mpAdjust.

Referenced by adjustStartValue().

◆ adjustStartValue()

◆ adjustStartValuesForIntervals()

bool COptProblem::adjustStartValuesForIntervals ( )

◆ calculate()

bool COptProblem::calculate ( void  )
virtual

Do the calculating based on CalculateVariables and fill CalculateResults with the results.

Returns
bool continue

calculate() decides whether the problem is a steady state problem or a trajectory problem based on whether the pointer to that type of problem is null or not. It then calls the process() method for that type of problem. Currently process takes ofstream& as a parameter but it will change so that process() takes no parameters.

Reimplemented in CFitProblem, and CRealProblem.

References CMathContainer::applyUpdateSequence(), COptProblem::sCounter::Counter, COptProblem::sCounter::FailedCounterException, COptProblem::sCounter::FailedCounterNaN, CCopasiMessage::getLastMessage(), CCopasiTask::getProblem(), CCopasiTask::getType(), CCopasiTask::initialize(), mCalculateValue, mCounters, mhCounter, mInitialRefreshSequence, CCopasiProblem::mpContainer, mpMathObjectiveExpression, mpParmMaximize, CCopasiProblem::mProcessReport, mpSubTask, mStoreResults, mUpdateObjectiveFunction, CCopasiTask::NO_OUTPUT, CCopasiTask::ONLY_TIME_SERIES, pdelete, CCopasiTask::process(), CProcessReportLevel::progressItem(), CTaskEnum::timeCourse, and CMathExpression::value().

Referenced by calculateStatistics(), COptMethodPS::evaluate(), COptMethod::objectiveValue(), and setCalculateStatistics().

◆ calculateStatistics()

bool COptProblem::calculateStatistics ( const C_FLOAT64 factor = 1.0e-003,
const C_FLOAT64 resolution = 1.0e-009 
)
virtual

◆ calculateValue()

void COptProblem::calculateValue ( )
overridevirtual

Calculate the objects value.

Reimplemented from CDataObject.

References C_FLOAT64, mMinInterval, and mpOptItems.

◆ checkFunctionalConstraints()

bool COptProblem::checkFunctionalConstraints ( )
virtual

◆ checkIntervals()

bool COptProblem::checkIntervals ( )

Check whether all item intervals are valid.

Returns
bool valid

References CMathContainer::applyUpdateSequence(), mMinInterval, CCopasiProblem::mpContainer, and mUpdateIntervals.

Referenced by adjustStartValuesForIntervals().

◆ checkParametricConstraints()

bool COptProblem::checkParametricConstraints ( )
virtual

Check whether all parameters are within their boundaries.

Returns
bool within

References mpOptItems.

Referenced by COptMethod::reflect().

◆ elevateChildren()

◆ evalMinimizeIntervals()

C_FLOAT64 COptProblem::evalMinimizeIntervals ( const C_FLOAT64 value)

Calculate the RMS of the interval size for items which have invalid intervals

Parameters
constC_FLOAT64 & value
Returns
C_FLOAT64 minInterval

References CMathContainer::applyUpdateSequence(), C_FLOAT64, mAdjustedItems, mpAdjust, CCopasiProblem::mpContainer, and SQRT_EPSILON.

Referenced by adjustForIntervals().

◆ geFailedConstraintCounter()

const unsigned C_INT32 & COptProblem::geFailedConstraintCounter ( ) const

Retrieve the counter of failed Constraint Evaluations

Returns
const unsigned C_INT32 & failedConstraintCounter

References COptProblem::sCounter::FailedConstraintCounter, and mCounters.

◆ getCalculateStatistics()

const bool & COptProblem::getCalculateStatistics ( ) const

Retrieve whether we have to calculate statistics

Returns
const bool & maximize

References mpParmCalculateStatistics.

◆ getCalculateValue()

const C_FLOAT64 & COptProblem::getCalculateValue ( ) const

Retrieve the result of a calculation

References mCalculateValue.

Referenced by COptMethodPS::evaluate(), and COptMethod::objectiveValue().

◆ getConstraintEvaluations()

const unsigned C_INT32 & COptProblem::getConstraintEvaluations ( ) const

Retrieve the constraint evaluation counter.

Returns
const unsigned C_INT32 & constraintCounter

References COptProblem::sCounter::ConstraintCounter, and mCounters.

◆ getConstraintList()

const std::vector< COptItem * > & COptProblem::getConstraintList ( ) const

Retrieve the list of constraints.

Returns
const std::vector< COptItem * > & constraintList

References mpConstraintItems.

◆ getContainerVariables()

CVectorCore< C_FLOAT64 * > & COptProblem::getContainerVariables ( const bool &  algorithmOrder = false) const

Retrieve the update methods for the variables for calculation.

Parameters
constbool & algorithmOrder (default: false)
Returns
const std::vector< UpdateMethod * > & updateMethods

References mContainerVariables, and mContainerVariablesAlgorithm.

Referenced by COptMethodPS::create(), and COptMethodPS::move().

◆ getCounters()

const COptProblem::sCounter & COptProblem::getCounters ( ) const

Retrieve the internal counter

Returns
const sCounter & counter

References mCounters.

Referenced by COptMethodPS::evaluate(), and COptMethodSS::localmin().

◆ getExecutionTime()

const C_FLOAT64 & COptProblem::getExecutionTime ( ) const

Retrieve the objective function.

Returns
const C_FLOAT64 & executionTime

References CCopasiTimer::getElapsedTimeSeconds(), and mCPUTime.

◆ getFailedEvaluationsExc()

const unsigned C_INT32 & COptProblem::getFailedEvaluationsExc ( ) const

Retrieve the counter of failed Evaluations (Exception)

Returns
const unsigned C_INT32 & failedEvaluationsExc

References COptProblem::sCounter::FailedCounterException, and mCounters.

◆ getFailedEvaluationsNaN()

const unsigned C_INT32 & COptProblem::getFailedEvaluationsNaN ( ) const

Retrieve the counter of failed Evaluations (NaN)

Returns
const unsigned C_INT32 & failedEvaluationsNaN

References COptProblem::sCounter::FailedCounterNaN, and mCounters.

◆ getFunctionEvaluations()

const unsigned C_INT32 & COptProblem::getFunctionEvaluations ( ) const

Retrieve the evaluation counter.

Returns
const unsigned C_INT32 & functionEvaluations

References COptProblem::sCounter::Counter, and mCounters.

◆ getObjectiveFunction()

const std::string COptProblem::getObjectiveFunction ( )

Retrieve the objective function.

Returns
const std::string infix.

References CEvaluationTree::getInfix(), mpObjectiveExpression, mpParmObjectiveExpression, and CExpression::updateInfix().

◆ getOptConstraint()

COptItem & COptProblem::getOptConstraint ( const size_t &  index)

Retrieve the 'index' optimization constraint.

Parameters
constsize_t & index
Returns
COptItem optItem

◆ getOptConstraintSize()

size_t COptProblem::getOptConstraintSize ( ) const

Retrieve the number of optimization constraints.

Returns
const size_t size

References mpGrpConstraints, and CCopasiParameterGroup::size().

◆ getOptItem()

COptItem & COptProblem::getOptItem ( const size_t &  index)

Retrieve the 'index' optimization item.

Parameters
constsize_t & index
Returns
COptItem optItem

◆ getOptItemList()

const std::vector< COptItem * > & COptProblem::getOptItemList ( const bool &  algorithmOrder = false) const

Retrieve the list of optimization parameters.

Parameters
constbool & algorithmOrder (default: false)
Returns
const std::vector< COptItem * > & optItemList

References mOptItemAlgorithm, and mpOptItems.

Referenced by ResultData::appliesTo(), ResultData::applyToModelStateFromOptTask(), COptMethodPS::create(), COptMethodSS::localmin(), COptMethodPS::move(), ResultData::setOptItemStartValues(), and ResultData::updateFitItemsFromOptItems().

◆ getOptItemSize()

size_t COptProblem::getOptItemSize ( ) const

Retrieve the number of optimization items.

Returns
const size_t size

References mpGrpItems, and CCopasiParameterGroup::size().

Referenced by ResultData::appliesTo().

◆ getRandomizeStartValues()

const bool & COptProblem::getRandomizeStartValues ( ) const

Retrieve whether we have to calculate statistics

Returns
const bool & randomize

References mpParmRandomizeStartValues.

◆ getSolutionValue()

const C_FLOAT64 & COptProblem::getSolutionValue ( ) const

Retrieve the result for the solution

References mSolutionValue.

Referenced by COptMethodSS::localmin().

◆ getSolutionVariables()

const CVector< C_FLOAT64 > & COptProblem::getSolutionVariables ( const bool &  algorithmOrder = false) const

Retrieve the solution variables

Parameters
constbool & algorithmOrder (default: false)

References mSolutionVariables, and mSolutionVariablesAlgorithm.

Referenced by COptMethodSS::localmin().

◆ getSubTask()

CCopasiTask * COptProblem::getSubTask ( ) const
overridevirtual

Retrieve the optional sub task

Returns
CCopasiTask* * pSubTask

Reimplemented from CCopasiProblem.

References CDataObject::getObjectAncestor(), CObjectInterface::GetObjectFromCN(), and mpParmSubTaskCN.

Referenced by initializeSubtaskBeforeOutput().

◆ getSubtaskType()

CTaskEnum::Task COptProblem::getSubtaskType ( ) const

Retrieve the subtask type

Returns
CTaskEnum::Task subtaskType

References CCopasiTask::getType(), mpSubTask, and CTaskEnum::UnsetTask.

◆ getValuePointer()

void * COptProblem::getValuePointer ( ) const
overridevirtual

Retrieve a pointer to the value of the object

Reimplemented from CCopasiParameter.

References C_FLOAT64, and mMinInterval.

◆ getVariableGradients()

const CVector< C_FLOAT64 > & COptProblem::getVariableGradients ( ) const

Retrieve the gradients for each solution variable.

Returns
const CVector< C_FLOAT64 > & variableGradients

References mGradient.

◆ getVariableSize()

size_t COptProblem::getVariableSize ( ) const

Retrieve the size of the variable vectors.

Returns
size_t VariableSize

◆ incrementCounters()

◆ initialize()

bool COptProblem::initialize ( )
overridevirtual

Do all necessary initialization so that calls to calculate will be successful. This is called once from CCopasiTask::process()

Returns
bool success

Reimplemented from CCopasiProblem.

Reimplemented in CFitProblem.

References COptItem::addDependentItem(), CMathDependencyGraph::addObject(), adjustStartValuesForIntervals(), C_FLOAT64, CMathUpdateSequence::clear(), CCopasiParameterGroup::clear(), CExpression::compile(), CCore::Default, CCopasiMessage::ERROR, CEvaluationTree::getInfix(), CMathContainer::getInitialDependencies(), CMathContainer::getInitialStateObjects(), CCopasiTask::getMethod(), CDataObject::getObjectParent(), CObjectInterface::getPrerequisites(), CMathExpression::getPrerequisites(), CCopasiTask::getReport(), CMathContainer::getSimulationUpToDateObjects(), CMathContainer::getStateObjects(), CReport::getStream(), CCopasiMethod::getSubType(), CMathContainer::getTransientDependencies(), CMathDependencyGraph::getUpdateSequence(), CEvaluationTree::mapObjectNodes(), mContainerVariables, mContainerVariablesAlgorithm, MCOptimization, mCounters, mCountInfluencingIntervals, mCPUTime, mInitialRefreshSequence, MissingValue, mOptItem2Index, mOptItemAlgorithm, mOriginalVariables, mpConstraintItems, CCopasiProblem::mpContainer, mpMathObjectiveExpression, mpObjectiveExpression, mpOptItems, mpParmMaximize, CCopasiProblem::mpReport, CDataObject::mPrerequisits, mpSubTask, mpSubTaskSrc, mSolutionValue, mSolutionVariables, mSolutionVariablesAlgorithm, mUpdateConstraints, mUpdateIntervals, mUpdateObjectiveFunction, mWorstValue, pdelete, CVector< CType >::resize(), CCopasiTimer::start(), CTaskEnum::Statistics, CCore::UpdateMoieties, and CCopasiMessage::WARNING.

Referenced by COptMethodSS::initialize(), CFitProblem::initialize(), and COptTask::initialize().

◆ initializeParameter()

◆ initializeSubtaskBeforeOutput()

bool COptProblem::initializeSubtaskBeforeOutput ( )
virtual

◆ initObjects()

◆ maximize()

const bool & COptProblem::maximize ( ) const

Check whether we have to maximize

Returns
const bool & maximize

References mpParmMaximize.

Referenced by setMaximize().

◆ print()

void COptProblem::print ( std::ostream *  ostream) const
overridevirtual

This is the output method for any object. The default implementation provided with CDataObject uses the ostream operator<< of the object to print the object.To override this default behavior one needs to reimplement the virtual print function.

Parameters
std::ostream* ostream

Reimplemented from CCopasiProblem.

Reimplemented in CFitProblem.

◆ printResult()

void COptProblem::printResult ( std::ostream *  ostream) const
overridevirtual

This is the output method for any result of a problem. The default implementation provided with CCopasiProblem. Does only print "Not implemented." To override this default behavior one needs to reimplement the virtual printResult function.

Parameters
std::ostream* ostream

Reimplemented from CCopasiProblem.

Reimplemented in CFitProblem.

References C_FLOAT64, COptProblem::sCounter::Counter, CCopasiTimer::getElapsedTime(), CCopasiTimeVariable::getMilliSeconds(), CCopasiTimeVariable::getSeconds(), CCopasiTimeVariable::LL2String(), mCounters, mCPUTime, mpOptItems, mSolutionValue, mSolutionVariables, and CVectorCore< CType >::size().

◆ randomizeStartValues()

void COptProblem::randomizeStartValues ( )

◆ rememberStartValues()

void COptProblem::rememberStartValues ( )

Remember the start values;

References mpOptItems.

Referenced by COptTask::process(), and CFitTask::process().

◆ removeOptConstraint()

bool COptProblem::removeOptConstraint ( const size_t &  index)

Remove an optimization constraint.

Parameters
constsize_t & index
Returns
bool success

References mpGrpConstraints, and CCopasiParameterGroup::removeParameter().

◆ removeOptItem()

bool COptProblem::removeOptItem ( const size_t &  index)

Remove an optimization items.

Parameters
constsize_t & index
Returns
bool success

References mpGrpItems, and CCopasiParameterGroup::removeParameter().

◆ reset()

void COptProblem::reset ( )

Reset counters and objective value.

References mCounters, mpParmMaximize, and mSolutionValue.

Referenced by COptMethodSS::localmin(), and setCallBack().

◆ resetCounters()

void COptProblem::resetCounters ( )

Resets the internal counter

References mCounters.

Referenced by COptMethodPS::evaluate(), COptMethodSS::localmin(), and COptTask::process().

◆ restore()

◆ setCalculateStatistics()

void COptProblem::setCalculateStatistics ( const bool &  calculate)

Set whether we have to calculate statistics

Parameters
constbool & calculate

References calculate(), and mpParmCalculateStatistics.

Referenced by COptMethodSS::initialize().

◆ setCallBack()

bool COptProblem::setCallBack ( CProcessReportLevel  callBack)
overridevirtual

◆ setMaximize()

void COptProblem::setMaximize ( const bool &  maximize)

Set whether we have to maximize the objective function

Parameters
constbool & maximize

References maximize(), and mpParmMaximize.

◆ setObjectiveFunction()

bool COptProblem::setObjectiveFunction ( const std::string &  infix)

Set optimization function

Parameters
conststd::string & infix
Returns
bool success

References mpObjectiveExpression, mpParmObjectiveExpression, and CExpression::setInfix().

Referenced by elevateChildren().

◆ setParameters()

void COptProblem::setParameters ( const CVectorCore< C_FLOAT64 > &  parameters)

Set parameters for which calculations and checks will be performed

Parameters
constCVectorCore< C_FLOAT64 > & parameters

References CVectorCore< CType >::begin(), C_FLOAT64, CVectorCore< CType >::end(), mContainerVariables, and CVectorCore< CType >::size().

Referenced by COptMethod::objectiveValue().

◆ setRandomizeStartValues()

void COptProblem::setRandomizeStartValues ( const bool &  randomize)

Set whether we have to randomize start values

Parameters
constbool & randomize

References mpParmRandomizeStartValues.

Referenced by COptMethodSS::initialize().

◆ setSolution()

bool COptProblem::setSolution ( const C_FLOAT64 value,
const CVector< C_FLOAT64 > &  variables,
const bool &  algorithmOrder = false 
)
virtual

Set the solution.

Parameters
constC_FLOAT64 & value
constCVector< C_FLOAT64 > & variables
constbool & algorithmOrder (default: false)
Returns
bool continue;

Reimplemented in CFitProblem.

References CVectorCore< CType >::begin(), C_FLOAT64, mhSolutionValue, mOptItem2Index, mOptItemAlgorithm, mpParmMaximize, CCopasiProblem::mProcessReport, mSolutionValue, mSolutionVariables, mSolutionVariablesAlgorithm, CProcessReportLevel::progressItem(), and CVectorCore< CType >::size().

Referenced by CFitProblem::setSolution().

◆ setSubtaskType()

◆ swapOptItem()

bool COptProblem::swapOptItem ( const size_t &  iFrom,
const size_t &  iTo 
)

Swap two optimization items.

Parameters
constsize_t & iFrom
constsize_t & iTo
Returns
bool success

References mpGrpItems, and CCopasiParameterGroup::swap().

◆ updateContainer()

void COptProblem::updateContainer ( const bool &  update)
protectedvirtual

Do all necessary restore procedures for the container is in the same state as before or the new state if update is true.

Parameters
constbool & update

Reimplemented in CFitProblem.

References CVectorCore< CType >::array(), C_FLOAT64, mContainerVariables, mOriginalVariables, mSolutionValue, mSolutionVariables, mWorstValue, and CVectorCore< CType >::size().

Referenced by CFitProblem::createParameterSets(), restore(), and CFitProblem::updateContainer().

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const COptProblem o 
)
friend

Output stream operator

Parameters
ostream& os
constCOptProblem & A
Returns
ostream & os

Member Data Documentation

◆ mAdjustedItems

std::set< COptItem * > COptProblem::mAdjustedItems
protected

The set of COptItems which intervals are adjusted

Referenced by adjustStartValue(), and evalMinimizeIntervals().

◆ mCalculateValue

C_FLOAT64 COptProblem::mCalculateValue
protected

◆ mContainerVariables

CVector< C_FLOAT64 * > COptProblem::mContainerVariables
mutableprotected

◆ mContainerVariablesAlgorithm

CVector< C_FLOAT64 * > COptProblem::mContainerVariablesAlgorithm
mutableprotected

◆ mCounters

◆ mCountInfluencingIntervals

size_t COptProblem::mCountInfluencingIntervals
protected

Number of items influencing intervals

Referenced by adjustStartValuesForIntervals(), and initialize().

◆ mCPUTime

◆ mGradient

CVector< C_FLOAT64 > COptProblem::mGradient
protected

◆ mHaveStatistics

bool COptProblem::mHaveStatistics
protected

Indicates whether the statistics have been calculated for the current result

Referenced by calculateStatistics(), CFitProblem::calculateStatistics(), CFitProblem::initialize(), and CFitProblem::printResult().

◆ mhCounter

size_t COptProblem::mhCounter
protected

Handle of "Function Evaluations" process report item

Referenced by calculate(), CFitProblem::calculate(), CFitProblem::calculateCrossValidation(), incrementCounters(), and setCallBack().

◆ mhSolutionValue

size_t COptProblem::mhSolutionValue
protected

Handle of "Best Value" process report item

Referenced by setCallBack(), and setSolution().

◆ mInitialRefreshSequence

CCore::CUpdateSequence COptProblem::mInitialRefreshSequence
protected

A vector of refresh methods which need to be called update all initial values which depend on the optimization items.

Referenced by calculate(), calculateStatistics(), CFitProblem::createParameterSets(), initialize(), and restore().

◆ MissingValue

C_FLOAT64 COptProblem::MissingValue
staticprivate

Referenced by initialize().

◆ mMinInterval

C_FLOAT64 COptProblem::mMinInterval
protected

The value of the smallest interval

Referenced by calculateValue(), checkIntervals(), and getValuePointer().

◆ mOptItem2Index

std::map< COptItem *, size_t > COptProblem::mOptItem2Index
protected

Referenced by initialize(), and setSolution().

◆ mOptItemAlgorithm

std::vector< COptItem * > COptProblem::mOptItemAlgorithm
protected

◆ mOriginalVariables

CVector< C_FLOAT64 > COptProblem::mOriginalVariables
protected

A vector of solution variables

Referenced by initialize(), and updateContainer().

◆ mpAdjust

C_FLOAT64* COptProblem::mpAdjust
protected

A pointer to the value to be adjusted to create valid intervals

Referenced by adjustForIntervals(), and evalMinimizeIntervals().

◆ mpConstraintItems

◆ mpGrpConstraints

CCopasiParameterGroup* COptProblem::mpGrpConstraints
protected

A pointer to the value of the CCopasiParameter holding the OptimizationConstraints

Referenced by CFitProblem::addFitConstraint(), addOptConstraint(), elevateChildren(), getOptConstraintSize(), initializeParameter(), and removeOptConstraint().

◆ mpGrpItems

CCopasiParameterGroup* COptProblem::mpGrpItems
protected

A pointer to the value of the CCopasiParameterGroup holding the OptimizationItems

Referenced by CFitProblem::addFitItem(), addOptItem(), elevateChildren(), getOptItemSize(), initializeParameter(), removeOptItem(), and swapOptItem().

◆ mpMathObjectiveExpression

CMathExpression* COptProblem::mpMathObjectiveExpression
protected

The objective function which should be minimized or maximized.

Referenced by calculate(), and initialize().

◆ mpObjectiveExpression

CExpression* COptProblem::mpObjectiveExpression
protected

The objective function which should be minimized or maximized.

Referenced by getObjectiveFunction(), initialize(), and setObjectiveFunction().

◆ mpOptItems

◆ mpParmCalculateStatistics

bool* COptProblem::mpParmCalculateStatistics
protected

◆ mpParmMaximize

bool* COptProblem::mpParmMaximize
protected

◆ mpParmObjectiveExpression

std::string* COptProblem::mpParmObjectiveExpression
protected

A pointer to the value of the CCopasiParameter holding the infix expression of the objective function

Referenced by elevateChildren(), getObjectiveFunction(), initializeParameter(), CFitProblem::initializeParameter(), and setObjectiveFunction().

◆ mpParmRandomizeStartValues

bool* COptProblem::mpParmRandomizeStartValues
protected

A pointer to the value of the CCopasiParameter holding Randomize Start Values

Referenced by getRandomizeStartValues(), initializeParameter(), randomizeStartValues(), and setRandomizeStartValues().

◆ mpParmSubTaskCN

std::string* COptProblem::mpParmSubTaskCN
protected

A pointer to the value of the CCopasiParameter holding the CN for the subtask

Referenced by elevateChildren(), getSubTask(), initializeParameter(), CFitProblem::initializeParameter(), and setSubtaskType().

◆ mpSubTask

CCopasiTask* COptProblem::mpSubTask
mutableprotected

Pointer to the subtask to be used in the optimization

Referenced by calculate(), getSubtaskType(), initialize(), initializeSubtaskBeforeOutput(), restore(), setCallBack(), and ~COptProblem().

◆ mpSubTaskSrc

CCopasiTask* COptProblem::mpSubTaskSrc
protected

Pointer to the source of the subtask to be used in the optimization

Referenced by initialize(), and initializeSubtaskBeforeOutput().

◆ mSolutionValue

◆ mSolutionVariables

◆ mSolutionVariablesAlgorithm

CVector< C_FLOAT64 > COptProblem::mSolutionVariablesAlgorithm
protected

◆ mStoreResults

bool COptProblem::mStoreResults
protected

◆ mUpdateConstraints

CCore::CUpdateSequence COptProblem::mUpdateConstraints
protected

A vector of refresh methods which need to be called retrieve the values of constraints.

Referenced by checkFunctionalConstraints(), and initialize().

◆ mUpdateIntervals

CCore::CUpdateSequence COptProblem::mUpdateIntervals
protected

A vector of refresh methods which need to be called retrieve the values of constraints.

Referenced by checkIntervals(), and initialize().

◆ mUpdateObjectiveFunction

CCore::CUpdateSequence COptProblem::mUpdateObjectiveFunction
protected

A vector of refresh methods which need to be called retrieve the value of the objective function.

Referenced by calculate(), and initialize().

◆ mWorstValue

◆ ValidSubtasks

const CTaskEnum::Task COptProblem::ValidSubtasks
static
Initial value:

The methods which can be selected for performing this task.

File name: COptProblem.cpp

Programmer: Yongqun He Contact email: yohe@.nosp@m.vt.e.nosp@m.du Purpose: This is the source file of the COptProblem class. It specifies the optimization problem with its own members and functions. It's used by COptAlgorithm class and COptimization class


The documentation for this class was generated from the following files: