Hi,
I found the following code to simulate a system in the template class
systemmodel.cpp:
// Simulate from the system model
template
SystemModel
void * sampling_args)
{
assert(_systemWithoutInputs == false);
_SystemPdf->ConditionalArgumentSet(0,x);
_SystemPdf->ConditionalArgumentSet(1,u);
Sample
_SystemPdf->SampleFrom(Simulated, sampling_method,sampling_args);
T result = Simulated.ValueGet();
return result;
}
and
// Get State Size
template
SystemModel
{
return _SystemPdf->DimensionGet();
}
I wonder if this code is correct for a discrete pdf. Since the dimension of a
discretepdf was defined as the number of states, a sample with size equal to
the number of states will be created, while IMHO we need just a sample with
dimension 1.
Tinne
_______________________________________________
I hereby promise not to top-post on the
BFL mailing list
BFL [..] ...
http://lists.mech.kuleuven.be/mailman/listinfo/bfl
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
Simulating a discrete system model
> I found the following code to simulate a system in the template class T::Simulate (const T& x, const T& u, int sampling_method, Simulated(StateSizeGet()); int::StateSizeGet() const
> systemmodel.cpp:
>
> // Simulate from the system model
> template
> SystemModel
> void * sampling_args)
> {
> assert(_systemWithoutInputs == false);
> _SystemPdf->ConditionalArgumentSet(0,x);
> _SystemPdf->ConditionalArgumentSet(1,u);
> Sample
> _SystemPdf->SampleFrom(Simulated, sampling_method,sampling_args);
> T result = Simulated.ValueGet();
> return result;
> }
>
> and
> // Get State Size
> template
> SystemModel
> {
> return _SystemPdf->DimensionGet();
> }
>
> I wonder if this code is correct for a discrete pdf. Since the dimension of a
> discretepdf was defined as the number of states, a sample with size equal to
> the number of states will be created, while IMHO we need just a sample with
> dimension 1.
AFAIS this will work due to the template specialisation mechanism used
in sample.h and sample.cpp, e.g.
// constructor Sample::Sample (unsigned int dimension)
template
{};
template <> inline::Sample (unsigned int dimension)
Sample
: Value(dimension)
{};
// Template Specialisation for T = int::DimensionGet() const
template <> inline unsigned int
Sample
{
return 1;
};
However, a quick svn praise on that file points out it has been edited
by several people, and its code seems to have arrived in a very
inconsistent state to me (see e.g. the doxygen comments for the
constructor that are not correct anymore :-(
Seems like this is worth another bugzilla report...
Klaas
_______________________________________________
I hereby promise not to top-post on the
BFL mailing list
BFL [..] ...
http://lists.mech.kuleuven.be/mailman/listinfo/bfl
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm