This optimizes rxode2 code for computer evaluation by only calculating redundant expressions once.
Arguments
- x
rxode2 model that can be accessed by rxNorm
- msg
This is the name of type of object that rxode2 is optimizing that will in the message when optimizing. For example "model" will produce the following message while optimizing the model:
finding duplicate expressions in model...
- chunkLines
Integer; when positive (the default is 40), a model longer than this many lines is optimized in contiguous cost-balanced chunks of roughly this many lines instead of in a single pass;
0always optimizes the whole model at once. Chunking amortizes the strongly superlinear cost of normalizing a large machine-generated model, which is what dominates the optimization of a sensitivity- or Jacobian-augmented model. Subexpressions are then shared only within a chunk, so the result is an equivalent model – the same states, parameters, solution and errors – carrying more temporaries. A chunk is a fragment, so if any chunk fails to optimize the whole model is optimized instead.- parallel
Integer; number of
miraidaemons used to optimize the chunks in parallel, used only when the model is chunked. It carries the same semantics asrxControl(cores=):0(the default) means the rxode2 thread settingrxCores()(setRxThreads(),OMP_THREAD_LIMIT);1runs the chunks serially. It is capped by the number of chunks and byrxCores(), so it will not oversubscribe. An existingmiraidaemon pool is used as-is and left running; otherwise a pool is started for the call and shut down when it returns, and only when the model splits into at least 4 chunks, where the parallel win covers the startup.
