Flag for testing available model before allowing solution and explicit checking JSON keys for metric updates
Change-Id: Ib2bc4b5273159077e3eaa7786cc2c846110791d0
This commit is contained in:
parent
5c67c7c7e0
commit
8d8ed80c50
@ -195,6 +195,11 @@ void AMPLSolver::DefineProblem(const Solver::OptimisationProblem & TheProblem,
|
|||||||
SetAMPLParameter( ConstantName,
|
SetAMPLParameter( ConstantName,
|
||||||
ConstantRecord.at( InitialConstantValue ) );
|
ConstantRecord.at( InitialConstantValue ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Finally, the problem has been defined and the flag is set to allow
|
||||||
|
// the search for solutions for this problem.
|
||||||
|
|
||||||
|
ProblemUndefined = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -225,6 +230,10 @@ void AMPLSolver::DataFileUpdate( const DataFileMessage & TheDataFile,
|
|||||||
void AMPLSolver::SolveProblem(
|
void AMPLSolver::SolveProblem(
|
||||||
const ApplicationExecutionContext & TheContext, const Address TheRequester )
|
const ApplicationExecutionContext & TheContext, const Address TheRequester )
|
||||||
{
|
{
|
||||||
|
// There is nothing to do if the application model is missing.
|
||||||
|
|
||||||
|
if( ProblemUndefined ) return;
|
||||||
|
|
||||||
// Setting the metric values one by one. In the setting of NebulOuS a metric
|
// Setting the metric values one by one. In the setting of NebulOuS a metric
|
||||||
// is either a numerical value or a string. Vectors are currently not
|
// is either a numerical value or a string. Vectors are currently not
|
||||||
// supported as values.
|
// supported as values.
|
||||||
@ -356,6 +365,7 @@ AMPLSolver::AMPLSolver( const std::string & TheActorName,
|
|||||||
Solver( Actor::GetAddress().AsString() ),
|
Solver( Actor::GetAddress().AsString() ),
|
||||||
ProblemFileDirectory( ProblemPath ),
|
ProblemFileDirectory( ProblemPath ),
|
||||||
ProblemDefinition( InstallationDirectory ),
|
ProblemDefinition( InstallationDirectory ),
|
||||||
|
ProblemUndefined( true ),
|
||||||
DefaultObjectiveFunction(), VariablesToConstants()
|
DefaultObjectiveFunction(), VariablesToConstants()
|
||||||
{
|
{
|
||||||
RegisterHandler( this, &LSolver::DataFileUpdate );
|
RegisterHandler( this, &LSolver::DataFileUpdate );
|
||||||
|
@ -153,6 +153,14 @@ protected:
|
|||||||
VariableName = "Variable",
|
VariableName = "Variable",
|
||||||
InitialConstantValue = "Value";
|
InitialConstantValue = "Value";
|
||||||
|
|
||||||
|
// Finally, no solution will be produced unless the problem has been
|
||||||
|
// defined. A flag is therefore set by the message handler indicating
|
||||||
|
// that the problem has been defined.
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
bool ProblemUndefined;
|
||||||
|
|
||||||
// The AMPL problem file can contain many objective functions, but can be
|
// The AMPL problem file can contain many objective functions, but can be
|
||||||
// solved only for one objective function at the time. The name of the
|
// solved only for one objective function at the time. The name of the
|
||||||
// default objective function is therefore stored together with the model
|
// default objective function is therefore stored together with the model
|
||||||
@ -160,8 +168,6 @@ protected:
|
|||||||
// label is not provided with the optimisation problem message, an
|
// label is not provided with the optimisation problem message, an
|
||||||
// invalid argument exception will be thrown.
|
// invalid argument exception will be thrown.
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
std::string DefaultObjectiveFunction;
|
std::string DefaultObjectiveFunction;
|
||||||
|
|
||||||
// To set the constant values to the right variable values, the mapping
|
// To set the constant values to the right variable values, the mapping
|
||||||
|
@ -142,10 +142,10 @@ void MetricUpdater::UpdateMetricValue(
|
|||||||
|
|
||||||
if( MetricValues.contains( TheTopic ) )
|
if( MetricValues.contains( TheTopic ) )
|
||||||
{
|
{
|
||||||
MetricValues.at( TheTopic ) = TheMetricValue[ NebulOuS::ValueLabel ];
|
MetricValues.at( TheTopic ) = TheMetricValue.at( NebulOuS::ValueLabel );
|
||||||
|
|
||||||
ValidityTime = std::max( ValidityTime,
|
ValidityTime = std::max( ValidityTime,
|
||||||
TheMetricValue[ NebulOuS::TimePoint ].get< Solver::TimePointType >() );
|
TheMetricValue.at( NebulOuS::TimePoint ).get< Solver::TimePointType >() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user