Opened 9 years ago

Last modified 7 years ago

#3931 new enhancement

Do not generate stupid equations

Reported by: Martin Sjölund Owned by: Lennart Ochel
Priority: high Milestone: Future
Component: Initialization Version:
Keywords: Cc: Francesco Casella

Description

Simple initialization equations can be handled by the init.xml-file instead of requiring GCC to link things and executing code at run-time. Take a simple model like:

model M
  Real r(fixed=false, start=0);
initial equation
  r = 1;
equation
  der(r) = 1;
end M;

Yields

/*
 equation index: 2
 type: SIMPLE_ASSIGN
 r = 1.0
 */
void M_eqFunction_2(DATA *data, threadData_t *threadData)
{
  TRACE_PUSH
  const int equationIndexes[2] = {1,2};
  data->localData[0]->realVars[0] /* r STATE(1) */ = 1.0;
  TRACE_POP
}

Even using fixed=true, we get a function generated:

/*
 equation index: 2
 type: SIMPLE_ASSIGN
 r = $_start(r)
 */
void M_eqFunction_2(DATA *data, threadData_t *threadData)
{
  TRACE_PUSH
  const int equationIndexes[2] = {1,2};
  data->localData[0]->realVars[0] /* r STATE(1) */ = data->modelData->realVarsData[0].attribute /* r */.start;
  TRACE_POP
}

These should both be avoided, keeping the start-value from the XML-file if nothing is given.

Change History (1)

comment:1 by Martin Sjölund, 7 years ago

This is still not resolved :(

Note: See TracTickets for help on using tickets.