Represents an inversion parameter (range, scaling, conditions) More...
#include <Parameter.h>
Public Member Functions | |
void | addCondition (AbstractCondition *c) |
uint | checksum () const |
void | conditionDiagnostic () const |
void | getGridLimits (int &min, int &max) const |
void | getGridLimits (double &min, double &max) const |
void | getLimits (double &min, double &max) const |
void | getRectangularLimits (double &min, double &max) const |
int | gridCount () const |
int | gridValue () const |
int | gridValue (double val) const |
void | humanInfo () const |
bool | initGrid () |
bool | isFixed () const |
bool | isFussy () const |
bool | isOk () const |
bool | isOkDebug () const |
bool | isOkDebugVerbose () const |
double | maximum () const |
double | minimum () const |
const QString & | name () const |
Parameter () | |
double | realValue () const |
double | realValue (int val) const |
double | realValue (double val) const |
void | setFussy (bool f) |
void | setGridValue (int val) |
void | setGridValue (double val) |
void | setMaximum (double m) |
void | setMinimum (double m) |
void | setName (QString name) |
void | setPrecision (double p) |
void | setRealValue (double val) |
bool | setRealValue (QDataStream &s) |
void | setScale (ParameterGrid::Scale s) |
void | setUnit (QString unit) |
const QString & | unit () const |
virtual | ~Parameter () |
Protected Member Functions | |
virtual XMLMember | xml_member (XML_MEMBER_ARGS) |
virtual bool | xml_setProperty (XML_SETPROPERTY_ARGS) |
virtual const QString & | xml_tagName () const |
virtual void | xml_writeProperties (XML_WRITEPROPERTIES_ARGS) const |
Static Protected Attributes | |
static const QString | xmlParamTag = "Param" |
Represents an inversion parameter (range, scaling, conditions)
A parameter may be qualified as 'fussy'. If so, each time the value of the parameter is changed, a validation of the model can be achieved by re-implementing NaModel::isCurrentModelOk() which returns true by default. If NaModel::isCurrentModelOk() returns false, a new value is randomly generated.
{
_value=0.5;
_fussy=false;
}
DinverCore::Parameter::~Parameter | ( | ) | [virtual] |
{ }
void DinverCore::Parameter::addCondition | ( | AbstractCondition * | c | ) |
Do not call this function directly, use the general RealSpace::addCondition() instead. This function is called by RealSpace::addCondition() to initialize the list of condition that include this parameter.
References DinverCore::AbstractCondition::indexOf(), and TRACE.
Referenced by DinverCore::RealSpace::addCondition().
{ TRACE; int index=c->indexOf(this); if(index>-1) { _conditions.append(ParamCondition( c, index) ); } }
uint DinverCore::Parameter::checksum | ( | ) | const |
Return a number that uniquely identify this parameter and the attached conditions
References DinverCore::qHash(), and TRACE.
{ TRACE; uint sum=0; sum += qHash(_name); sum += qHash(_unit); for(QVector<ParamCondition>::const_iterator it=_conditions.begin(); it!=_conditions.end(); ++it) { sum+=it->checksum(); } return sum; }
void DinverCore::Parameter::conditionDiagnostic | ( | ) | const |
Print a diagnostic of this parameter: does it fit will all conditions?
References QGpCoreTools::endl(), getLimits(), getRectangularLimits(), isFixed(), and TRACE.
Referenced by DinverCore::RealSpace::conditionDiagnostic().
{ TRACE; double min, max; getRectangularLimits(min, max); getLimits(min, max); if(isFixed()) { App::stream() << " " << _name << ": " << _value << "=" << min << endl; } else { App::stream() << " " << _name << ": " << min << " < " << _value << " < " << max << endl; if(_value<=min || _value>=max) { App::stream() << " ---> BAD CONDITION!" << endl; } } }
void DinverCore::Parameter::getGridLimits | ( | int & | min, |
int & | max | ||
) | const [inline] |
References getLimits(), DinverCore::ParameterGrid::getLimits(), and getRectangularLimits().
Referenced by DinverCore::AbstractForward::firstModel(), DinverCore::ImportanceSampling::generate(), and DinverCore::Neighborhood::setVolumes().
{ double dmin, dmax; getRectangularLimits(dmin, dmax); getLimits(dmin, dmax); _grid.getLimits(min, max, dmin, dmax); }
void DinverCore::Parameter::getGridLimits | ( | double & | min, |
double & | max | ||
) | const [inline] |
References getLimits(), DinverCore::ParameterGrid::getLimits(), and getRectangularLimits().
{ double dmin, dmax; getRectangularLimits(dmin, dmax); getLimits(dmin, dmax); _grid.getLimits(min, max, dmin, dmax); }
void DinverCore::Parameter::getLimits | ( | double & | min, |
double & | max | ||
) | const [inline] |
All values of other parameters are assumed to be set correctly. This function returns the admissible range for this parameter given the current value of all the other parameters.
Referenced by conditionDiagnostic(), getGridLimits(), isOk(), and isOkDebug().
{ for(QVector<ParamCondition>::const_iterator it=_conditions.begin(); it!=_conditions.end(); ++it) { it->getLimits(min, max); } }
void DinverCore::Parameter::getRectangularLimits | ( | double & | min, |
double & | max | ||
) | const [inline] |
References maximum(), and minimum().
Referenced by DinverCore::RealSpace::adjustRanges(), conditionDiagnostic(), getGridLimits(), isOk(), isOkDebug(), isOkDebugVerbose(), main(), and DinverCore::RealSpace::setVariableParameters().
int DinverCore::Parameter::gridCount | ( | ) | const [inline] |
Referenced by DinverCore::AbstractForward::firstModel(), and DinverCore::GeneratorModels::setScaledModels().
{return _grid.count();}
int DinverCore::Parameter::gridValue | ( | ) | const [inline] |
Referenced by DinverCore::ModelSet::add(), and DinverCore::GridSnoop::optimization().
{return _grid.gridValue(_value);}
int DinverCore::Parameter::gridValue | ( | double | val | ) | const [inline] |
{return _grid.gridValue(val);}
void DinverCore::Parameter::humanInfo | ( | ) | const |
Stream out information about parameter and its condition in a human readable format
References DinverCore::ParameterGrid::count(), QGpCoreTools::endl(), isFixed(), maximum(), minimum(), and TRACE.
Referenced by DinverCore::RealSpace::humanInfo().
{ TRACE; if(isFixed()) { App::stream() << " " << _name << "=" << minimum() << " " << _unit << endl; } else { App::stream() << " " << minimum() << " < " << _name << " < " << maximum() << " " << _unit << "(" << _grid.count() << " bins)" << endl; } for(QVector<ParamCondition>::const_iterator it=_conditions.begin(); it!=_conditions.end(); ++it) { it->humanInfo(); } }
bool DinverCore::Parameter::initGrid | ( | ) | [inline] |
bool DinverCore::Parameter::isFixed | ( | ) | const [inline] |
bool DinverCore::Parameter::isFussy | ( | ) | const [inline] |
Referenced by DinverCore::ImportanceSampling::generate().
{return _fussy;}
bool DinverCore::Parameter::isOk | ( | ) | const [inline] |
References getLimits(), getRectangularLimits(), and isFixed().
Referenced by DinverCore::RealSpace::isOk().
{ double min, max; getRectangularLimits(min, max); getLimits(min, max); if(isFixed()) { return (_value>=min && _value<=max); } else { return (_value>min && _value<max); } }
bool DinverCore::Parameter::isOkDebug | ( | ) | const [inline] |
References getLimits(), getRectangularLimits(), and isFixed().
Referenced by DinverCore::RealSpace::isOkDebug().
{ double min, max; getRectangularLimits(min, max); getLimits(min, max); if(isFixed()) { if(_value>=min && _value<=max) return true; printf(" %lg <= %lg <= %lg ? oh nooo!\n",min,_value,max); } else { if(_value>min && _value<max) return true; printf(" %lg < %lg < %lg ? oh nooo!\n",min,_value,max); } return false; }
bool DinverCore::Parameter::isOkDebugVerbose | ( | ) | const |
References getRectangularLimits(), and isFixed().
{ double min, max; getRectangularLimits(min, max); printf("rectangular limits: %10lg %10lg\n", min, max); // Get limits for(int i=0; i<_conditions.count(); i++) { _conditions.at(i).getLimits(min, max); printf("condition %3i : %10lg %10lg\n", i, min, max); } if(isFixed()) { if(_value>=min && _value<=max) return true; printf(" %lg <= %lg <= %lg ? oh nooo!\n",min,_value,max); } else { if(_value>min && _value<max) return true; printf(" %lg < %lg < %lg ? oh nooo!\n",min,_value,max); } return false; }
double DinverCore::Parameter::maximum | ( | ) | const [inline] |
Referenced by DinverCore::SimpleCondition::adjustRanges(), getRectangularLimits(), humanInfo(), and xml_writeProperties().
{return _grid.maximum();}
double DinverCore::Parameter::minimum | ( | ) | const [inline] |
Referenced by DinverCore::SimpleCondition::adjustRanges(), getRectangularLimits(), humanInfo(), and xml_writeProperties().
{return _grid.minimum();}
const QString& DinverCore::Parameter::name | ( | ) | const [inline] |
Referenced by DinverCore::RealSpace::addParameter(), DinverCore::RealSpace::adjustRanges(), DinverCore::SimpleCondition::humanInfo(), main(), DinverCore::RealSpace::parameter(), DinverCore::RealSpace::printModel(), NAModelsPlotProperties::setParameterList(), NAModelsPlot::setParamX(), NAModelsPlot::setParamY(), setRealValue(), and DinverCore::RealSpace::setVariableParameters().
{return _name;}
double DinverCore::Parameter::realValue | ( | ) | const [inline] |
Referenced by DinverCore::ReportWriter::addModel(), DinverCore::AbstractForward::copyValues(), DinverCore::SimpleCondition::getLimits(), DinverCore::AbstractForward::misfit(), DinverDCCore::TargetList::misfit(), DinverCore::PdfCurve::printCumulative(), DinverCore::RealSpace::printModel(), DinverDCCore::ParamLayer::setFinalDepths(), DinverDCCore::ParamLayer::setFinalProfileValuesParam(), setRealValue(), DinverCore::Neighborhood::variableParameterValue(), and DinverCore::ModelRepository::variableParameterValue().
{return _value;}
double DinverCore::Parameter::realValue | ( | int | val | ) | const [inline] |
{return _grid.realValue(val);}
double DinverCore::Parameter::realValue | ( | double | val | ) | const [inline] |
{return _grid.realValue(val);}
void DinverCore::Parameter::setFussy | ( | bool | f | ) | [inline] |
Referenced by DinverDCCore::ParamLayer::depthToParam().
{_fussy=f;}
void DinverCore::Parameter::setGridValue | ( | int | val | ) | [inline] |
Referenced by DinverCore::ModelRepository::createModel(), DinverCore::AbstractForward::firstModel(), DinverCore::ImportanceSampling::generate(), DinverCore::GridSnoop::optimization(), DinverCore::Neighborhood::optimization(), DinverCore::Neighborhood::setThreadCount(), StackWeights::setWeights(), and DinverCore::ModelRepository::start().
{_value=realValue(val);}
void DinverCore::Parameter::setGridValue | ( | double | val | ) | [inline] |
{_value=realValue(val);}
void DinverCore::Parameter::setMaximum | ( | double | m | ) | [inline] |
Referenced by DinverCore::RealSpace::addParameter(), DinverCore::SimpleCondition::adjustRanges(), DinverCore::dinver_set_range(), DinverCore::dinver_set_range_(), DinverDCCore::GroundParameter::GroundParameter(), DinverCore::RealSpace::setVariableParameters(), and xml_setProperty().
{_grid.setMaximum(m);}
void DinverCore::Parameter::setMinimum | ( | double | m | ) | [inline] |
Referenced by DinverCore::RealSpace::addParameter(), DinverCore::SimpleCondition::adjustRanges(), DinverCore::dinver_set_range(), DinverCore::dinver_set_range_(), DinverDCCore::GroundParameter::GroundParameter(), DinverCore::RealSpace::setVariableParameters(), and xml_setProperty().
{_grid.setMinimum(m);}
void DinverCore::Parameter::setName | ( | QString | name | ) | [inline] |
Referenced by DinverCore::RealSpace::addParameter(), and DinverDCCore::GroundParameter::GroundParameter().
{_name=name;}
void DinverCore::Parameter::setPrecision | ( | double | p | ) | [inline] |
DinverCore::Parameter::setRealValue | ( | double | val | ) | [inline] |
Set the real value of the parameter, defined() flag is automatically set to true.
Referenced by DinverCore::SimpleCondition::adjustRanges(), DinverCore::AbstractForward::copyValues(), DinverCore::ModelSet::importModelsFromAscii(), DinverCore::ModelSet::importModelsFromReport(), main(), outputModel(), reportMode(), DinverDCGui::GroundModelViewer::saveAsReport(), setRealValue(), StackWeights::setUniformWeights(), and DinverCore::RealSpace::setVariableParameters().
{_value=val;}
bool DinverCore::Parameter::setRealValue | ( | QDataStream & | s | ) |
Set the real value of the parameter from a binary stream(report). Returns true if the value can set properly. Failure may occur for fixed parameters when the constant value is not the same as the one of the stream.
References QGpCoreTools::endl(), isFixed(), name(), realValue(), setRealValue(), and QGpCoreTools::tr().
void DinverCore::Parameter::setScale | ( | ParameterGrid::Scale | s | ) | [inline] |
void DinverCore::Parameter::setUnit | ( | QString | unit | ) | [inline] |
Referenced by DinverCore::RealSpace::addParameter(), and DinverDCCore::GroundParameter::GroundParameter().
{_unit=unit;}
const QString& DinverCore::Parameter::unit | ( | ) | const [inline] |
Referenced by DinverCore::RealSpace::printModel(), NAModelsPlotProperties::setParameterList(), NAModelsPlot::setParamX(), and NAModelsPlot::setParamY().
{return _unit;}
XMLMember DinverCore::Parameter::xml_member | ( | XML_MEMBER_ARGS | ) | [protected, virtual] |
Re-implement this function to offer XML restore (children and properties) support to your class.
From tag and map (with contains the attibute value) return a unique identifier under the format of a XMLMember. XMLMember is initialized with 3 types of contructors:
Map of attributes can be inspected in this way (can be achived also in xml_setProperty()):
static const QString tmp("childrenName"); XMLRestoreAttributeIterator it=map.find(tmp); if(it!=map.end()) { // found attribute "childrenName" }
If the map of attributes is not used:
Q_UNUSED(attributes); if(tag=="x1") return XMLMember(0); else if(tag=="y1") return XMLMember(1); else if(tag=="x2") return XMLMember(2); else if(tag=="y2") return XMLMember(3); else return XMLMember(XMLMember::Unknown);
Arithmetic operations + and - apply to XMLMember to avoid confusion of property id numbers between inherited objects. Offset 3 corresponds to the number of properties defined in this object.
if(tag=="anInteger") return XMLMember(0); else if(tag=="aString") return XMLMember(1); else if(tag=="aDouble") return XMLMember(2); return AbstractLine::xml_member(tag, attributes, context)+3;
For the arguments of this function use Macro XML_MEMBER_ARGS.
Reimplemented from QGpCoreTools::XMLClass.
References TRACE.
bool DinverCore::Parameter::xml_setProperty | ( | XML_SETPROPERTY_ARGS | ) | [protected, virtual] |
Re-implement this function to offer XML restore properties support to your class.
From memberID set the corresponding property with value content. The map of attributes is given as a supplementary information (not useful in all cases).
For a general case:
Q_UNUSED(attributes); double val=content.toDouble(); switch (memberID) { case 0: _x1=val; return true; case 1: _y1=val; return true; case 2: _x2=val; return true; case 3: _y2=val; return true; default: return false; }
For classes inheriting other classes (see also xml_member())
switch (memberID) { case 0: _anInteger=content.toString(); return true; case 1: _aString=content.toInt(); return true; case 2: _aDouble=content.toDouble(); return true; default: return AbstractLine::xml_setProperty(memberID-3, map, content);
For the arguments of this function use Macro XML_SETPROPERTY_ARGS.
Reimplemented from QGpCoreTools::XMLClass.
References setMaximum(), setMinimum(), and TRACE.
{ TRACE; Q_UNUSED(tag); Q_UNUSED(attributes); Q_UNUSED(context); switch (memberID) { case 0: setMinimum(content.toDouble()); return true; case 1: setMaximum(content.toDouble()); return true; case 2: _name=content.toString(); return true; case 3: _unit=content.toString(); return true; default: return false; } }
virtual const QString& DinverCore::Parameter::xml_tagName | ( | ) | const [inline, protected, virtual] |
Implements QGpCoreTools::XMLClass.
{return xmlParamTag;}
void DinverCore::Parameter::xml_writeProperties | ( | XML_WRITEPROPERTIES_ARGS | ) | const [protected, virtual] |
Reimplemented from QGpCoreTools::XMLClass.
References maximum(), minimum(), TRACE, and QGpCoreTools::XMLClass::writeProperty().
{ TRACE; Q_UNUSED(context); writeProperty(s, "name", _name); writeProperty(s, "unit", _unit); writeProperty(s, "min", minimum()); writeProperty(s, "max", maximum()); }
const QString DinverCore::Parameter::xmlParamTag = "Param" [static, protected] |