There is a bug in omnet++ when recording boolean params as scalars, It
seems that omnet is trying to get their doublevalue instead of their
boolvalue.
How to reproduce:
Modify omnet++ 4.1b2 tictioc example so section Tictoc01 looks like this:
[Config Tictoc1]
network = Tictoc1
**.param-record-as-scalar = true
sim-time-limit = 1s
(The last two lines were added)
Compile and run the simulation, at the end it will show a dialog
complaining about trying to get the doublevalue of a boolean param.
Workaround:
--- src/sim/ccomponent.cc 2010-03-08 12:31:56.000000000 +0100
+++ /tmp/omnetpp-4.1b2/src/sim/ccomponent.cc 2010-01-27
18:33:51.000000000 +0100
@@ -236,10 +236,7 @@
throw cRuntimeError(this, "cannot record non-numeric
parameter `%s' as an output scalar", par(i).getName());
if (par(i).isVolatile() &&
(par(i).doubleValue()!=par(i).doubleValue() ||
par(i).doubleValue()!=par(i).doubleValue()))
throw cRuntimeError(this, "recording volatile
parameter `%s' that contains a non-constant value (probably a random
variate) as an output scalar -- recorded value is probably just a
meaningless random number", par(i).getName());
- if (par(i).getType() == cPar::BOOL)
- recordScalar(par(i).getName(), par(i).boolValue());
- else
- recordScalar(par(i).getName(), par(i).doubleValue());
//XXX mark value specially (as being a "param") in the file?
+ recordScalar(par(i).getName(), par(i).doubleValue());
//XXX mark value specially (as being a "param") in the file?
}
}
}
Please note this is not a complete solution: think of volatile boolean
params for example.
A cPar::isBoolean() method will be nice.
PS: Is this mailing list the right place to send omnet++ bug reports
like this one?
--
Alberto Cortés
Telematic Engineering Dept. at UC3M
A recordScalar(cPar) method may be even better :)
Sorry, I confuse the original-file with the patch-file in the above
patch report, "-" should be "+" and and vice versa
Andras
--
You received this message because you are subscribed to the Google Groups
"omnetpp" group.
To post to this group, send email to omn...@googlegroups.com.
To unsubscribe from this group, send email to
omnetpp+u...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/omnetpp?hl=en.
By the way, I agree with the " //XXX the following checks should
probably produce a WARNING not an error"
PS:
I made more changes to ccomponent::recordParametersAsScalars(): I
would like to use "**.param-record-as-scalar = true" in my ini file
(that is, just save all the params for future reference). But some
params are strings or XML so they can't be saved in the scalar file.
Right now the simulation is giving an error, I modified
ccomponent::recordParametersAsScalars() to also ignore these
non-recordable params (an additional warning is probably also nice).
I'm aware that launching an error is more correct, so this is probably
a patch you would not like to see in the vanilla omnet, but here it is
anyway:
--- /tmp/omnetpp-4.1b2/src/sim/ccomponent.cc 2010-01-27
18:33:51.000000000 +0100
+++ src/sim/ccomponent.cc 2010-03-08 13:11:15.000000000 +0100
@@ -231,8 +231,12 @@
{
if (ev.getConfig()->getAsBool(par(i).getFullPath().c_str(),
CFGID_PARAM_RECORD_AS_SCALAR, false))
{
+ if (par(i).getType() == cPar::STRING)
+ continue; // don't record params of type string as
they are not scalars
+ if (par(i).getType() == cPar::XML)
+ continue; // don't record params of type xml as they
are not scalars
//XXX the following checks should probably produce a
WARNING not an error
if (!par(i).isNumeric())
throw cRuntimeError(this, "cannot record non-numeric
parameter `%s' as an output scalar", par(i).getName());
if (par(i).isVolatile() &&
(par(i).doubleValue()!=par(i).doubleValue() ||
par(i).doubleValue()!=par(i).doubleValue()))
throw cRuntimeError(this, "recording volatile
parameter `%s' that contains a non-constant value (probably a random
variate) as an output scalar -- recorded value is probably just a
meaningless random number", par(i).getName());
I was not sure about long params, so I haven't address them in this patch.
My 2 cents: It will be nice to always save all non-volatile params,
right from the beginning of the simulation, in its own output file
(not related to the scalar output file so strings and other param
types can easily be dumped into this new file).
By saying "always save all non-volatile params, right from the beginning of
the simulation", do you mean log all changes to the parameters during
simulation? Or that params would be recorded automatically when the
simulation starts?
I mean that params would be recorded automatically when the simulation starts.
I'm thinking of a way to have along with your output data, all the
input data used to generate that run (the params, the random seed...
anything that is easy to record, is not in the ned models and is not
volatile). But then again, I am an omnet newbie, maybe it just don't
make any sense :)
Nice, happy to be of help.
> By saying "always save all non-volatile params, right from the beginning of
> the simulation", do you mean log all changes to the parameters during
> simulation? Or that params would be recorded automatically when the
> simulation starts?
I mean that params would be recorded automatically when the simulation
starts (only once).
I'm thinking of a way to have along with your output data, all the
input data used to generate that run (the params, the random seed...
anything that is easy to record, is not in the ned models and is not
volatile). But then again, I am an omnet newbie, maybe it just don't
make any sense :)
>