KappaTools icon indicating copy to clipboard operation
KappaTools copied to clipboard

Archive file, illegal Kappa, counters, weird kinetics

Open hmedina opened this issue 5 years ago • 3 comments

The following code runs and produces an inputs file. The inputs file contains illegal kappa statements (according to the UI and CL version of KaSim), and suggest kinetics that I did not expect.

Model:

%agent: ~9(c{=1 / +=5})
~9(c{=1}) -> ~9(c{+=1}) @ 1.0
~9(c{=1 / +=1}) @ 1
%init: 5 ~9()
%mod: [E] > 1 do $STOP ;

Inputs file generated:

// "uuid" : "240934166"
%def: "seed" "259177778"
%def: "dumpIfDeadlocked" "true"
%def: "maxConsecutiveClash" "2"
%def: "progressBarSize" "60"
%def: "progressBarSymbol" "#"
%def: "plotPeriod" "1" "t.u."
%def: "outputFileName" "data.csv"


%agent: ~9(c{=1/+=5})

%plot: [T]
~9(c{=1/+=1}),  @ 1.
~9(c{=1/+=1}),  @ 1

/*0*/%mod: (|~9(c{=6})| = 1) do $PRINTF "
Counter c of agent ~9 reached maximum
"; $STOP "counter_perturbation.ka"; repeat [false]
/*1*/%mod: ([E] > 1) do $STOP ; repeat [false]

%init: 5 ~9(c{=1})

%mod: [E] = 2 do $STOP;

Remarks:

  1. Line 14, why the comma after the agent?
  2. Line 15, idem
  3. Lines 17-19, why the line-breaks? If line-breaks, shouldn't they be outside the quoted string?
  4. How did a counter reach the maximum value of 5, if it started at 1 and there were two +1 events?
  5. Why do we have line 20, and line 24?
  6. Line 24, shouldn't it also have a /*\d*/ annotation? What's the rationale for annotating some perturbations but not others with a number?

hmedina avatar Mar 22 '19 19:03 hmedina

In the end:

  • 1 obvious bug
  • 1 space for improvement
  • 1 ugly (now always) useless safeguard
  1. it is a bug
  2. it is the same bug
  3. Ioana wanted the error message in case of safe guard violation to be printed on a new line (not after the ### This is perfectly OK and achieve by making the message start by a \n ...
  4. This is a generic safe guard systematically added as we didn't statically checked counter overflows at the time (Now, Jerome static analysis came to our rescue :-) ). It ensures that the model stop if/when it becomes non sense. It is indeed useless in this case.
  5. Line 24 not a real perturbation. It is what is added at the end of the simulation to specify when the simulation actually stopped. In this case, simulation stopped because of line 20 (but it could have been because of the -l argument of the command line or a Ctrl-c, ...) so 24 is redondant. We might detect this case and not print the safe but useless stopping condition.
  6. See above :-)

pirbo avatar Apr 11 '19 12:04 pirbo

Re: point 3 gotcha. That said, the GUI complains about newlines in double-quoted strings. So should it be escaped somehow..?

MWE that makes the GUI complain:

%mod: [true] do $PRINTF "
foo foo foo
";

Re: point 4, maybe you should invoke @feret so he actually comes to the rescue..?

Re: point 5-6, if the goal is for the archive file to be a record of what happened, then it should include the input model as well as what actually happened, so I guess it should include both. Maybe a bit of documentation is warranted, so a user knows what to expect when going over such a file, specially as they are generated by default.

hmedina avatar Apr 11 '19 23:04 hmedina

Right "multi lines" are indeed forbidden... I've fixed the perturbation generated for counters...

pirbo avatar Apr 19 '19 08:04 pirbo