Opened 12 years ago
Last modified 3 years ago
#1931 assigned defect
Do not scalarize vector equations
Reported by: | Martin Sjölund | Owned by: | Jens Frenkel |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Frontend | Version: | |
Keywords: | Cc: | Jens Frenkel |
Description
We should not scalarize equations, so we can reduce the number of function calls performed (here f is called once for each element in the matrix):
model M function f input Real r1,r2; output Real o[2] := {r1,r2}; end f; Real rtime = time; Real r[:,:](each start = 1.5) = f(rtime,2:3); end M; model N M m; end N;
With a better frontend, we can generate this flat code:
function M.f input Real r1; input Real r2; output Real[2] o = {r1, r2}; end M.f; class N Real m.rtime = time; Real m.r[1,1](start = 1.5); Real m.r[1,2](start = 1.5); Real m.r[2,1](start = 1.5); Real m.r[2,2](start = 1.5); equation m.r = {M.f(m.rtime, 2.0), M.f(m.rtime, 3.0)}; end N;
Attachments (2)
Change History (24)
comment:1 by , 12 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 12 years ago
by , 12 years ago
comment:3 by , 12 years ago
For parameters, some simulations start to spin for infinity. Others return 0 instead of calculating the parameter value. I have attached the diff so Jens can have a look.
These are some of the simulations that failed:
./simulation/libraries/msl32/Modelica.Blocks.Examples.BooleanNetwork1.mos ./simulation/libraries/msl32/Modelica.Blocks.Examples.Filter.mos ./simulation/libraries/msl32/Modelica.Blocks.Examples.FilterWithDifferentiation.mos ./simulation/libraries/msl32/Modelica.Blocks.Examples.FilterWithRiseTime.mos ./simulation/libraries/msl32/Modelica.Blocks.Examples.IntegerNetwork1.mos ./simulation/libraries/msl32/Modelica.Blocks.Examples.Interaction1.mos ./simulation/libraries/msl32/Modelica.Blocks.Examples.InverseModel.mos ./simulation/libraries/msl32/Modelica.Blocks.Examples.LogicalNetwork1.mos ./simulation/libraries/msl32/Modelica.Blocks.Examples.PID_Controller.mos ./simulation/libraries/msl32/Modelica.Blocks.Examples.RealNetwork1.mos ./simulation/libraries/msl32/Modelica.Blocks.Examples.ShowLogicalSources.mos ./simulation/libraries/msl32/Modelica.Electrical.Digital.Examples.MUX2x1.mos ./simulation/libraries/msl32/Modelica.Electrical.Machines.Examples.Transformers.AsymmetricalLoad.mos ./simulation/libraries/msl32/Modelica.Electrical.Machines.Examples.Transformers.TransformerTestbench.mos ./simulation/libraries/msl32/Modelica.Fluid.Examples.DrumBoiler.DrumBoiler.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Constraints.ConstrainRevoluteJoint.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Constraints.ConstrainSphericalJoint.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Constraints.ConstrainUniversalJoint.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Elementary.DoublePendulumInitTip.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Elementary.DoublePendulum.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Elementary.ForceAndTorque.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Elementary.FreeBody.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Elementary.HeatLosses.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Elementary.InitSpringConstant.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Elementary.LineForceWithTwoMasses.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Elementary.Pendulum.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Elementary.PendulumWithSpringDamper.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Elementary.PointGravity.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Elementary.PointGravityWithPointMasses2.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Elementary.PointGravityWithPointMasses.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Elementary.RollingWheel.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Elementary.RollingWheelSetDriving.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Elementary.RollingWheelSetPulling.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Elementary.SpringDamperSystem.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Elementary.SpringMassSystem.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Elementary.SpringWithMass.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Elementary.ThreeSprings.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Loops.Engine1a.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Loops.Engine1b_analytic.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Loops.Engine1b.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Loops.Fourbar1.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Loops.Fourbar2.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Loops.Fourbar_analytic.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Loops.PlanarLoops_analytic.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Rotational3DEffects.ActuatedDrive.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Rotational3DEffects.GearConstraint.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Rotational3DEffects.GyroscopicEffects.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Rotational3DEffects.MovingActuatedDrive.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Systems.RobotR3.Components.GearType2.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Systems.RobotR3.Components.MechanicalStructure.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Systems.RobotR3.Components.PathPlanning1.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Systems.RobotR3.Components.PathPlanning6.mos ./simulation/libraries/msl32/Modelica.Mechanics.MultiBody.Examples.Systems.RobotR3.oneAxis.mos ./simulation/libraries/msl32/Modelica.Mechanics.Rotational.Examples.CoupledClutches.mos ./simulation/libraries/msl32/Modelica.Mechanics.Rotational.Examples.Friction.mos ./simulation/libraries/msl32/Modelica.Mechanics.Rotational.Examples.HeatLosses.mos ./simulation/libraries/msl32/Modelica.Mechanics.Rotational.Examples.LossyGearDemo1.mos ./simulation/libraries/msl32/Modelica.Mechanics.Rotational.Examples.LossyGearDemo2.mos ./simulation/libraries/msl32/Modelica.Mechanics.Rotational.Examples.LossyGearDemo3.mos ./simulation/libraries/msl32/Modelica.Mechanics.Rotational.Examples.SimpleGearShift.mos ./simulation/libraries/msl32/Modelica.Mechanics.Translational.Examples.Brake.mos ./simulation/libraries/msl32/Modelica.Mechanics.Translational.Examples.Friction.mos ./simulation/libraries/msl32/Modelica.Mechanics.Translational.Examples.HeatLosses.mos ./simulation/libraries/msl32/Modelica.Media.Examples.MoistAir.mos ./simulation/libraries/msl32/Modelica.Media.Examples.TestOnly.FlueGas.mos ./simulation/libraries/msl32/Modelica.Media.Examples.Tests.MediaTestModels.Water.ConstantPropertyLiquidWater.mos ./simulation/libraries/msl32/Modelica.Thermal.HeatTransfer.Examples.Motor.mos ./simulation/modelica/algorithms-functions/AlgorithmForInClass.mos ./simulation/modelica/algorithms-functions/Interpolation.mos ./simulation/modelica/arrays/PolynomialEvaluatorA.mos ./simulation/modelica/arrays/PolynomialEvaluatorB.mos ./simulation/modelica/built-in-functions/MeasureTime.mos ./simulation/modelica/connectors/StepAdvanced.mos ./simulation/modelica/msl22/blockssources.mos ./simulation/modelica/msl22/IdealGearBrake.mos ./simulation/modelica/others/DiscreteVectorStateSpace.mos ./simulation/modelica/others/nonConstantIndex.mos ./simulation/modelica/others/Random.mos ./simulation/modelica/others/Riccati.mos ./simulation/modelica/others/Table2d.mos
comment:4 by , 12 years ago
Owner: | changed from | to
---|
comment:5 by , 12 years ago
I guess the problem is that if parameter bindings are moved to initial equations the parameters should be fixed=false, otherwise the initial system became overconstrained.
Another idea is to add a new Equationtype "PARAMETER_EQUATION(cr,exp,source)". This equation could be moved directly to the parameter system and used in the simulation runtime to calculate the parameter value. Then it is maybe also easier to simplify equations like
CriticalDamping.x_start = {0.0, 0.0, 0.0}
comment:6 by , 12 years ago
Owner: | changed from | to
---|
comment:9 by , 10 years ago
Milestone: | 1.9.1 → 1.9.2 |
---|
This ticket was not closed for 1.9.1, which has now been released. It was batch modified for milestone 1.9.2 (but maybe an empty milestone was more appropriate; feel free to change it).
comment:10 by , 10 years ago
Milestone: | 1.9.2 → 1.9.3 |
---|
Milestone changed to 1.9.3 since 1.9.2 was released.
comment:15 by , 8 years ago
Milestone: | 1.11.0 → 1.12.0 |
---|
Milestone moved to 1.12.0 due to 1.11.0 already being released.
comment:16 by , 7 years ago
Component: | Frontend → New Instantiation |
---|---|
Milestone: | 1.12.0 → 2.0.0 |
@perost, can you give another look at this issue?
comment:17 by , 7 years ago
Component: | New Instantiation → Frontend |
---|---|
Milestone: | 2.0.0 → 1.13.0 |
I thought with the cse module, this would have been resolved for parameters but it's not; the parameter equations are still called multiple times. The problem can be fixed either in the frontend (moving the equations and setting fixed=false like we do for records); in the backend (by performing some CSE); or both (by introducing an equation kind that is treated like having set fixed=false even though we have fixed=true set)
comment:19 by , 5 years ago
Milestone: | 1.14.0 → 1.16.0 |
---|
Releasing 1.14.0 which is stable and has many improvements w.r.t. 1.13.2. This issue is rescheduled to 1.16.0
comment:21 by , 4 years ago
Milestone: | 1.17.0 → 1.18.0 |
---|
Retargeted to 1.18.0 because of 1.17.0 timed release.
Fixed for variables in r13830. Will look into also making this possible for parameter bindings.