Representing constraints

This forum contains all archives from the SD Mailing list (go to http://www.systemdynamics.org/forum/ for more information). This is here as a read-only resource, please post any SD related questions to the SD Discussion forum.
Michael Evans
Junior Member
Posts: 6
Joined: Fri Mar 29, 2002 3:39 am

Representing constraints

Post by Michael Evans »

Niall Palfreyman asks if there is any way for SD software to represent
mutual dependancies, for example where you dont wish to specify which
variables are dependant or independant in advance. He focusses on the ideal
gas equation PV = NkT, where P,V and T are variables and N,k are constants.

In SD terms a set of mutual dependancies could be naively imagined as group
of variables related by a closed loop of connectors, ie variable x depends
on variables y and z which themselves depend on x. I say naively because in
fact you cant do it; iThink for example gives a message "Sorry, but that
would create a circular connection". The reason for this, I believe, goes
back to last years debate on rate-dependant rates: A rate cannot be
directly dependant on another rate, you need an intermediate stock to
physically measure a rate of change, hence all simple closed loops that
might lead to a rate-dependant rate error have been proscribed from SD
methodology.

The solution then is to go ahead and create intermediate stocks from which
you can measure proxy rates of change that feedback into mutually dependant
flows. This complicates matters a bit because you generally have to
differentiate your equations into the corresponding rates of change of each
variable and then integrate them back together as stocks, but yes, you can
do it.

The trouble is, compared to a nice neat set of connected variables, this
generally looks incredibly messy, even for something as simple as the
deterministic ideal gas law PV=NkT; you wouldnt teach a class of
undergraduates with it and live to tell the tale. It would be simpler to
set up three different models, each with agreed dependant and independant
variables to represent chosen experimental arrangements. Niall, If you
still want to do it the hard way I can send you a model, which relies on
the learning gleaned from another recent SD debate by breaking the
complexity into sectors.

If I can presume to guess a deeper level in Nialls question, and leaving
aside the debate about rate-dependant rates for the moment, can we ask if
it is possible to construct a closed loop of variables without an
intervening stock, say by writing your own software or doing it by hand?
The answer is yes, you can do it by making educated guesses until you find
a set of mutually interdependant values that satisfy all the constraints of
the equations. You can speed up and automate this process by iteration
techniques, for instance using the iteration tool in MS-Excel, so long as
you can construct iterative forms of the equations. With a bit of practice
its usually possible.

Ive applied this technique many times in hydrology and open channel
hydraulics, and have never encountered a situation where rate-dependant
rates lead to an actual error in the solution. Engineering techniques often
cut through the theory and do it anyway, and why not? Just dont stop
iterating until the guess is within reasonable tolerances.

To implement this in SD would require a major software rethink to allow
iteration within each time step, in a sense a set of imaginary (non-real)
calculations that once solved allow the simulation to display a solution
and move to the next time step. I wont be in a position to think about
that until I finish my PhD, God willing.

Regards,

Michael Evans
Centre for Ecological Economics and Water Policy Research
University of New England
Armidale, NSW Australia 2351
Ph + 61 2 6773 3744
Fax 2 6773 3237
mevans@metz.une.edu.au
Niall Palfreyman
Senior Member
Posts: 56
Joined: Fri Mar 29, 2002 3:39 am

Representing constraints

Post by Niall Palfreyman »

Brian J Barry wrote:

> Set up three stocks, Pressure, Volume and Temperature. Stipulate
> appropriate initial values. Each stock should have a single flow
> controlling up or down exponential adjustment. Formula for this
> flow - which, for Pressure, might be called Adjusting Pressure
> would be:
> AdjustingPressure = (NewPressure-Pressure) / PressureAdjustingTime

Thanks for the neat formulation Barry. I guess thats about the simplest
that would do it. In fact, from the point of view of getting a
demonstration going its perfect - thanks very much. However I also have
two problems with doing it this way:

a. This would require a long simulation time, since it incorporates 2
timescales: the pressure adjustment time and the volume and temperature
variation times.

b. I have to admit that it also reflects the actual physics, in which
the variables adjust to each other in finite time. Still I have a
sneaking feeling that there must be (nonquantum) instances where
variables need to to adjust instantaneously to each other. How about
maybe a loop of inextensible string which forms the perimeter P of a
rectangle with width W and height H? I can adjust either W or H, but
only subject to the constraint 2(W+H)=P.

OK, in writing that Ive realised that in the end a constraint must
always represent an idealised situation in which a dynamic (in your case
the adjustment; in mine the strings extensibility) is assumed
instantaneous. On reflection I also realise that Einsteins problem with
quantum theory lay precisely in the fact that its (currently) the only
area of physics which actually claims that such an instantaneous process
corresponds to nature.

On the other hand (returning to point (a) above), in modelling we
frequently decide to work with a particular timescale for computational
reasons. We represent a slowly changing variable with a constant
converter, or we represent a very fast dependency with a connector,
instead of a flow. So might it not be advantageous in some circumstances
if we could specify a constraint between converters? Im thinking of
something like variable binding which was used in the language Prolog to
support such mutual dependencies. Are there any real-world problems out
there for which such a modelling tool might be useful?

George Simpson wrote:
> This seems pretty easy to do... Perhaps I misunderstand the question.

<smile> I think maybe I misunderstand your suggestion, George. How do I
combine the three converters into a unique value for the third (unheld)
variable?

Oh, and thanks very much to everyone who answered - youve given me
plenty to mull over.

Cheers,
Niall Palfreyman.
From: Niall Palfreyman <
niall.palfreyman@fh-weihenstephan.de>
Niall Palfreyman
Senior Member
Posts: 56
Joined: Fri Mar 29, 2002 3:39 am

Representing constraints

Post by Niall Palfreyman »

Im fascinated by the answers that have been coming in to my question.
Theyre showing me that the idea I have niggling at the back of my mind
is very different from the main thrust of SD thinking. Whether the idea
is actually _useful_ is, of course, another issue again :-). I will try
once more now to voice the idea, if only to achieve some clarity for
myself, and then I promise Ill drop it.

What I like about SD is that it enables me to explore the nature of
physical and biological systems from a contextual perspective.
The main direction of my work for the last 20 years has been the
attempt to reclaim the relevance of context in the sciences. Over and
over again it is the case that science isolates (ie, decontextualises)
an aspect of the world and then reifies it into a "thing". See, for
example, the concept of a "gene", which is very difficult to pin down in
abstraction from its context. So, in brief: my purpose in modelling is
usually not necessarily to look for causal feedback in nature, but
rather to find ways of incorporating context into models of natural
phenomena.

John Sterman wrote:
> The key point is this: The gas law as stated in PV = NkT is an
> equilibrium relationship and not a dynamical system.

Tom Fiddaman wrote:
> Having two things on the LHS of an equation is causally weird anyway...

You bet. However my intention is not necessarily to look for _causal_
explanations (although clearly I too have certain minimal causal
expectations), but rather to look for _contextualised_ explanations. I
love the fact that SD explains behaviour by reference to causal feedback
between a "thing" and its context. However that doesnt mean that all
contextual explanations can be formulated causally.

The idea niggling at me arose from a wish two years ago to model quantum
mechanics (QM) as a means of teaching students about the workings of a
quantum computer. In QM there is a principle called the Pauli Exclusion
Principle, which states, for example, that two electrons in one orbital
of an atom can never be observed in the same state: if one electron is
spinning clockwise, then the other is spinning counterclockwise. Until I
measure the spin of one electron, the state of both is defined only up
to a probability distribution over the two spin directions: both
electrons are simultaneously in a genuine mixture of the two states. Now
imagine you remove one of the electrons off to Alpha Centauri - both
electrons are still in a mixture of states. Then I measure the spin of
my electron here on Earth and find it to be clockwise. In that instant I
genuinely change the state of your electron on Alpha Centauri: you can
now only measure the state "counterclockwise". I have affected your
world non-causally by making use of the Exclusion Principle constraint.
This is not an "equilibrium relationship", but a genuinely instantaneous
and mutual interaction.

Now, it may be that QM is the only place where such interactions can
happen, but that doesnt mean that they might not be a useful modelling
tool. Im thinking of a cloud chamber simulation which I constructed
recently in Stella. There I made the modelling assumption that the
electrostatic interaction between two bodies is instantaneous and mutual
- Ive never seen a Newtonian model that didnt make this assumption. If
the timescale of the interaction propagation is much smaller than the
timescale of the resulting dynamics, then this is a completely sensible
_computational_ assumption.

Im also thinking of a recent case where I wanted the number of
individuals in a population to remain equal to 100. If the number of
Altruists in the population rose, then the number of Selfists had to go
down accordingly. This is obviously not a physical constraint, but it
was computationally desirable. In both this and the previous case I
worked it by having the two constrained variables controlled by a third
computation which calculated both variables in such a way as to satisfy
their constraints. But it was not straightforward to do.

So Im asking myself the following question:

Am I alone (and therefore possibly wrong) in thinking that acausal (ie,
instantaneous and mutual) interaction might be a useful modelling tool,
or are there really situations out there which also require, at least as
a computational assumption, that two or more variables are constrained
together acausally?

Id really love to know the answer.

Best wishes,
Niall Palfreyman.
From: Niall Palfreyman <
niall.palfreyman@fh-weihenstephan.de>
Michael Evans
Junior Member
Posts: 6
Joined: Fri Mar 29, 2002 3:39 am

Representing constraints

Post by Michael Evans »

As with others replying to this query I have felt the need to check that I
have understood it. Thanks Niall for that clarification, I feel on safer
ground that I have not spoken at random. No, you are not alone in thinking
that "acausal (ie, instantaneous and mutual) interaction might be a useful
modelling tool". I for one agree that there are "situations out there which
also require, at least as a computational assumption, that two or more
variables are constrained together acausally", and not only as a separate
equilibrium calculation but as part of a dynamic model.

Firstly clarifying my own earlier comments in case of further
misunderstanding: I mentioned that Stella/ithink produces a message warning
of a circular connection; I did not mean to imply that this is an error
message, rather that such circular connections are disallowed by SD
methodology. Thanks to John Sterman for a far clearer explanation as to
why: Without an intermediate stock, a closed circular connection cannot
simulate a realistic dynamic (as distinct from equilibrium) relationship.

I also said that a model of the ideal gas equation showing the full 3-way
dependancy of P, V and T was incredibly messy compared to a set of 3 models
each with a chosen independant variable. That wasnt meant to imply that a
simpler model is necessarily better, but simply more communicable to a
class of students. I now wonder whether it is in fact realistic to divorce
an empirical relationship such as the gas law from a particular
experimental setup, such as a choice between controlling the temperature or
the pressure of the gas, which necessarily selects that variable as
independant. So a 3-way dependancy model may be insufficiently specified
and therefore not very useful in the lab. We also didnt mention the first
law (of thermodynamics), which you really need to make sense of gases.

Nevertheless as Niall has pointed out there are useful mathematical
relationships in a range of applications that imply an instantaneous,
algebraic parity between real variables, and not just so that they add up
to give the correct answer. In the case of quantum mechanics that parity
emerges not only from the underlying complex number theory, but from the
experimental fact that coupled wave functions collapse to a real-world
solution essentially at the same time.

In most cases though, ie outside the complex-number quantum world, theory
that relies on an instantaneous apportionment of variables reflects an
equilibrium rather than a dynamic relationship. The cases I referred to in
hydrology and hydraulics are in fact equilibrium solutions which find an
envelope of worst case values for purposes of design safety. So in a sense
the argument that these cases are inappropriate to SD is valid. However,
all too often these empirical relationships are the best we have at a given
level of detail. As John Sterman points out, the gas law could be replaced
by a more complex statistical, molecular or atomic treatment at any level
of detail, but would that be useful to a practitioner trying to teach
thermodynamics to freshmen?

It would in fact help to have learning tools that teach the intuitively
dynamic behaviour of gases, despite the methodological conflict with the
equilibrium nature of the theory. There are many other cases where a
dynamic model might usefully rely on inputs or outputs based on
best-approximation equilibrium relationships. Flood safety for instance,
would mingle the dynamic movement of a flood wave with a simple and
conservative equilibrium estimate of flood height. You can do better, but
not in a way which is simple enough for effected stakeholders to understand
while remaining methodologically acceptable (technically correct) to
specialists.

So yes, an SD tool that allows such instantaneous closed-loop relationships
to coexist with dynamic stock-flow loop relationships would be a very handy
tool indeed.

As to whether we have such tools in SD already, I must say that the
iterative methods I suggested in my last post sound very much like the
SIMULTANEOUS and FIND ZERO functions (Vensim) mentioned by Tom Fiddaman. I
wasnt aware of these functions, having made my choice with Stella/ithink.
Can anyone advise if Stella/ithink (and other software) provides tools
capable of doing optimisation or finding zero values within each time step
before moving on to the next time step? This would go some way to answering
Nialls question in the affirmative, and would be a great help to me also.

Regards and thanks for the learning

Michael Evans
University of New England
Armidale, NSW 2351, Australia
Ph + 61 2 6773 3744
Fax 2 6773 3237
mevans@metz.une.edu.au
Yaman Barlas
Member
Posts: 44
Joined: Fri Mar 29, 2002 3:39 am

Representing constraints

Post by Yaman Barlas »

I would submit that this whole notion of constraint is "in the eye of
beholder." Any given sd model can be seen full of constraints, if one
chooses to do so.

- All flow and auxilary equations can be seen as constraints (assuming for
the moment that we are talking about equality constraints - I will come to
inequality constraints below). Nialls last example quoted below
illustrates this fact nicely: In such a population model, one could
represent the Altruits by a STOCK with its in and out flows and if we want
the "constraint" that the total population must be 100, then we simply write
Selfists = 100 - Altruists. (An auxiliary equation representing a
"constraint").
- But if we wanted the total population remain not exactly equal but <= 100,
then Selfists would be a STOCK as well. Now, the flow variables must be
carefully coordinated such that they never allow the total of the two stocks
to be >100. This could be done by MIN functions or better by smooth effect
functions that "constrain" the flows as needed. (An example of using
inequalty constraints in sd).
- STOCK equations are also constraints. They are DYNAMIC constraints that
relate stocks and flows.
- As a matter of fact, if we did an optimization on a sd model using some
sort of "objective function" like minimizing total inventory cost, then,
except the newly added objective function equation(s), ALL equations in the
original sd model would be called "constraints" in the optimization
algorithm. (But keep in mind that for an optimization problem to exist, the
set of constraints must NOT have a unique solution, else the optimization
objective would be meaningless. ie. the number of variables must be more
than the number of independent constraints, or some must be inequality
constraints).
- I sum, sd models can and do represent constraints, but must do so in a way
consistent with the philosophy and methodology.
- Finally, perhaps most importantly: the fact that a sd model is a "causal"
one does NOT mean that every single equation must correspond to some
philosophically undisputable causality. The principle of causality in sd is
much more "reasonable" than that: it means that if possible, equations must
correspond to well-established operational causalities and at definitely no
equation must contradict an obvious, well known causality. In this sense,
DELAY formulations are typically non-causal, but are often used as
approximations as long as they do not contradict some otherwise known
causalities. So the to answer Nialls question: " are there really
situations out there which also require that two or more variables are
constrained together acausally?" is "yes, sometimes." As the above "Selfists
= 100- Altruists" and most delay formulations illustrate. (PS. Graham, is
this last item somewhat related to your PS question: "what makes SD unique
and how do we preserve that while avoiding insularity?")
best to all,
Yaman barlas
From: yaman barlas <
ybarlas@boun.edu.tr>

---------------------------------------------------------------------------
Yaman Barlas, Ph.D.
Professor, Industrial Engineering Dept.
Bogazici University,
80815 Bebek, Istanbul, TURKEY
http://www.ie.boun.edu.tr/~barlas
SESDYN Group: http://www.ie.boun.edu.tr/labs/sesdyn/
-----------------------------------------------------------------------------
"geoff coyle"
Senior Member
Posts: 94
Joined: Fri Mar 29, 2002 3:39 am

Representing constraints

Post by "geoff coyle" »

Yes, as Bob says, there are easy ways to do this (they are in the SD texts).
Ill go into some detail.

> O1(n+1) + O2(n+1) <= S(n)

First point is that the above is dimensionally invalid. S must be in [units]
while O1 ands O2 are in [units/week] (or other time unit. [ ] denotes the
dimensions of).

In DYNAMO notation (the closest thing we have to formal mathematics in SD),
one can write, for a single outflow

L STOCK.K=STOCK.J+DT*(IN.JK-OUT1.JK)
R OUT1.KL=f(......)

Such an equation can permit STOCK to go negative. The reasons may lie in an
incorrect formulation for OUT1 (such as dimensional invalidity) or elsewhere
in the model and should be carefully investigated. If, however, it is
legitimately possible for STOCK to be negative, the WRONG way to cure it is
to write

L STOCK.K=MAX(0,STOCK.J+DT*(IN.JK-OUT1.JK))

as that interferes with the causal processes at work.

The Correct formulation is to write:

R OUT1.KL=MIN(f(......), STOCK.K/DT)

this being one of the three exceptions to having DT on the right-hand-side
of a rate or auxiliary equation (It is, of course, a cardinal error to have
DT on the RHS of a rate or auxiliary as, to do so, confuses the causal
processes at work in the system, with DT which is a purely artificial
construct, the only purpose of which is to get equations to run on a
computer)

For two outflows, there are several possibilities. The wrong one is to write

R OUT1.KL=MIN(f1(...), STOCK.K/DT)

and

R OUT2.KL=MIN(f2(....), STOCK./DT)

as that clearly will still allow STOCK to become negative.

An acceptable alternative is to assume proportionality and write

R OUT1.KL=MIN(f1(....),f1(...)/(f1(...)+f2(....))*STOCK.K/DT)

and similarly for OUT2.

If, for some reason, OUT2 has priority over OUT1, one could write

R OUT1.KL=MIN(f1(...),STOCK.K/DT-OUT2.KL)

This is one of the few legitimate exceptions to the rule against having a
rate on the RHS of another rate.

Bobs suggestions are much the same as mine, but you have to be very careful
about dimensions.

Geoff Coyle
From: "geoff coyle" <
geoff.coyle@btinternet.com>
Niall Palfreyman
Senior Member
Posts: 56
Joined: Fri Mar 29, 2002 3:39 am

Representing constraints

Post by Niall Palfreyman »

"Weaver, Elise A" schrieb:

> Number of Altruists = 100 - Number of Selfists? This doesnt
> seem to capture the depth of what you are after, however.

Hi Elise,

No, thats right. Im after a _mutual_ link in which it is equally the
case that
Number of Selfists = 100 - Number of Altruists
As I say, Im not sure such a thing exists - I was just wondering, since
Id found a couple of possible uses for it in my own work.

> If it is not discrete, then you could have a continuum of change
> over time i.e., yesterday the average individual was 80% Selfist
> and today it is 79% Selfist out there. In between, it was 79.5%
> Selfist and so on. Then you could have an expected value of
> Selfism for the community.

Thats clearly sufficient for some purposes, but in this particular case
I wanted to investigate the discrete genetic dynamics which might lead
to the evolution of altruism.

> A thought about acausal connections: What do you think of the use of
> statistical correlation to talk about contextual, non-causal associations
> in the environment?

My first thoughts about non-causal association actually arose from a
fascination with statistical correlation. However statistical
correlation mostly describes either a long timescale approximation to a
short timescale equilibrating process, or else two variables with a
common cause. I really only became obsessed when I realised that there
are systems in which the underlying dynamics is not causal, but rather
true nonlocality. However from the lack of examples arising in this
discussion I can only assume that this is something confined to physics
with no correlate in other areas. Oh well :-(.

<brightens> Still, Ive learned a lot from the thread - thanks.

Cheers,
Niall.
From: Niall Palfreyman <
niall.palfreyman@fh-weihenstephan.de>
"Christopher Barker"
Junior Member
Posts: 6
Joined: Fri Mar 29, 2002 3:39 am

Representing constraints

Post by "Christopher Barker" »

Geoffs technical email brings out important points, and in particular the need for dimensional consistency, which I trust we all enforce (and if we dont, Powersim Studio assists us in our plight by deducing the dimensions of derived variables for us and automatically highlighting any dimensional inconsistency in our derivations).

I would add - or perhaps clarify - a few points.

1 Its not dimensionally inconsistent to state, per se, a constraint that O1(n+1) + O2(n+1) <= S(n), so long as O1(n+1) is used (as I believe it was) to refer to the **volume** passing within time period (n+1) (units: widgets) and doesnt purport to represent a **rate** (units: widgets/week). Its not a standard SD representation, to be sure, but its equally valid. If, in our description of a system, we are prepared to accept the approximation of the integration of a flow over time to the calculation of discrete accumulations over a series of timesteps of width dt - and this is what we do in SD formulations - the two representations say exactly the same about the system. As a community, we need to be tolerant of other, equally mathematically correct, representations of processes that we would notate differently, and reserve our concern for derivations that are truly dimensionally inconsistent, either by being internally inconsistent (as some of those that Geoff highlig!
hts) or simply by failing to represent the real-world process at hand.

2 Geoffs point about the wrong solution to use to prevent the stock from going negative is also true, and is interesting. Standard SD approaches use stock formulae that attempt to approximate the differential equations underlying the system. Were using an Euler method here, but other stock equations would be equally valid. However, the reformatted stock equation in Geoffs example is well outside any attempt to approximate the systems differential equations, and can never be either meaningful or a true representation of a particular system at hand. Indeed, Powersim Studio would not allow us to make this error.

3 As Geoff points out, the (or lets say, a) correct formulation is to limit an outflow to the lesser of a default rate and (Stock / dt). An alternative formulation is to use a graphical (table) function of the stock to limit the proportion of the default outflow rate that may flow. As always, the right solution to use depends on the way in which the flow is limited in the real-world problem that were simulating.

4 Where one outflow has priority over another, its OK to limit the second to the lesser of the desired rate and ((Stock / dt) - first outflow rate) - but thats not quite enough to help you if the first flow rate is itself large enough to drain the stock in one dt! We also need to be very careful about the way in which this priority works in the real system: it would be unusual for one rate to be entirely sacrificed to the other when a stock fell too low to continue to feed both.

As Geoff would caution us all, dimensional consistency is critically necessary to represent a real system (or indeed to make sense at all) - but its not sufficient. And thats in fact true outside the system dynamics approach as well as in our discipline.


From: "Christopher Barker" <
cbarker@powersim.co.uk>
Christopher Barker
Director
Powersim Consulting
"geoff coyle"
Senior Member
Posts: 94
Joined: Fri Mar 29, 2002 3:39 am

Representing constraints

Post by "geoff coyle" »

Christopher is right, the use of /DT is only one way of representing a
constraint. It corresponds to a policy of deliver until we run out of
stock. An alternative is a policy of slow deliveries (or whatever) as we
get closer to stock out. The latter would be better handled by a table
function though Id still include /DT as a belt and braces protection!

>
> As Geoff would caution us all, dimensional consistency is critically
>necessary to represent a real system (or indeed to make sense at all) - but
>its not sufficient. And thats in fact true outside the system dynamics
>approach as well as in our discipline.
>

Yes, its very true but, as far as I am aware, SD is the only operaional
resarch technique that even mentions dimensions.

> Geoffs technical email brings out important points, and in particular
>the need for dimensional consistency, which I trust we all enforce (and =

I personally prefer, as Christopher implies, to think about dimensions
and then let software do a check. I wonder, though, about how Powersim
would handle this problem.

I want to model production rate PR as a proportional control on
inventory discrepancy DIS and the time to correct that, TCI. The
dimensions are, respectively, [widgets/week], [widgets] and [week]. The
correct equation is PR=3DDIS/TCI. Suppose that I have provided
dimensions for DIS and TCI, Powersim would, presumably, correctly infer
PR as being [widgets/week]. If, however, I had made a mistake (and we
all make them) and entered the equation as DIS*TCI would Powersim make
PR into [widget-weeks]?

Suppose I wanted to add average consumption, AVCON, and make the
equation PR=3DDIS/TCI+AVCON. If I havent given the dimensions of AVCON
what happens? If Ive given them incorrectly (or theyve been deduced
incorrectly) as [widgets] instead of the correct [widgets/week], what
happens?

Incidentally, can anyone explain the origin of widgets?

.......................
> This is perhaps more semantic than literal, but I would tend to suggest
> that considering a backlog a negative stock is more a convenience than

Yes, I agree with this. A negative stock should not exist and, if necessary,
a separate and explicit backlog should be modelled. Why? A backlog will
probably trigger an entirely different set of policies and it is better to
treat them explicitly.

.....................
> I took yours and Bobs suggestion and it works nicely. The case I am
> considering.is Similar to epidemic problem whre O1 is uncontrollable outflow
> (e.g. recovery, death) and O2 is controllable (quarantine). So O1 has
> higher precidence.

Thats interesting as similar issues arise in modelling air power in
defence cases; aircraft lost cannot return to base.

> I point this out because it is really easy to get mixed up on
> MINs and MAXes in equations like this. The equation is the same as

I really support Bob on this - its vital to be careful and to check that
the model is really doing what it should and, in my experience, you have to
do that by studying tables of output, not just the graphs.


Geoff
From: "geoff coyle" <
geoff.coyle@btinternet.com>
"Christopher Barker"
Junior Member
Posts: 6
Joined: Fri Mar 29, 2002 3:39 am

Representing constraints

Post by "Christopher Barker" »

Many thanks to Geoff for asking how Powersim Studio helps us to ensure =
unit consistency.

Every variable has a unit associated with it. If we define the units of =
the systems stocks and its contants, the units of everything else =
follow - just as the numerical state of the entire systems is defined by =
the state of its stocks and its constants.

So in Geoffs example wed have defined the unit <<widgets>> as an =
atomic unit of the model, and wed then create:

* the auxiliary variable DIS (inventory discrepancy), which would =
have units <<widgets>> (which would themselves have been automatically =
derived from other variables in the system: presumably from the =
difference between a desired inventory (units: <<widgets>>) and an =
actual inventory (units: <<widgets>>);

* the constant TCI (time to correct auxiliary) as a certain time =
period: say, 4 <<wks>> or 1 <<month>> (Powersim Studio understands the =
relationships between time periods on the basis of the type of calendar =
that you select, so translates effortlessly between them for us); and

* the flow PR (production rate).


Powersim now helps us to answer Geoffs questions as follows:

1 If PR is properly derived as an nth order delay of DIS with the =
time constant TCI, it will automatically carry units <<widgets/wk>>. =
This will be in agreement with the rest of the model, which will then =
run correctly, giving sensible results.

2 If we mis-enter PR as being DIS * TCI (rather than DIS / TCI for a =
first-order delay), this flow will adopt the units <<widget * wk>>. =
This is, of course, incorrect; and if this flow runs into a stock of =
units <<widgets>>, a ? symbol will appear on top of the flow =
indicating a dimensional inconsistency. The stock will not accumulate =
by the flow, as the flows derivation makes no sense. This is, of =
course, preferable to allowing the stock to accumulate at the =
nonsensical rate implied by a dimensionally inconsistent flow =
formulation, as its better to have no numerical results and be prompted =
to reconsider our logic than to be given such grossly misleading =
results!

3 If we attempted to add Geoffs unitless average consumption AVCON =
to the production rate by writing production rate as DIS/TCI + AVCON, =
Powersims in-line syntax checking alerts us to our dimensional =
inconsistency even before we click OK on the variable definition. We =
will see a message in red reading Function "+": Unit of parameter 2 =
must match unit of parameter 1. In other words, were trying to add =
apples to pears, or in this case, something in <<widgets/wk>> to =
something dimensionless. We could enforce this erroneous formula by =
ignoring the message, but the stock will still not accumulate if we run =
the model, as the flow into it makes no sense.

4 If we change the units of AVCON to anything (Geoffs example was =
<<widgets>>) except the sensible ones of <<widgets/[time period]>>, the =
definition of the flow will still alert us to the inconsistency that we =
are trying to add two units of different dimensions. Once again, the =
stock will not accumulate, as the flow into it makes no sense.


As Geoff points out, we should know when we write a variable what its =
units are: if we dont know what we mean by the variable, we shouldnt =
be writing a formula for it! But mistakes do happen, which is why its =
most useful to have our tool confirm the units of derived variables for =
us, and point out if we are trying to enforce an inconsistent =
derivation.

Christopher Barker
Director
Powersim Consulting
From: "Christopher Barker" <
cbarker@powersim.co.uk>
Niall Palfreyman
Senior Member
Posts: 56
Joined: Fri Mar 29, 2002 3:39 am

Representing constraints

Post by Niall Palfreyman »

"Raymond T. Joseph" schrieb:

> It is fun to see others obsessed with systems!

<grin> Isnt it just? Im finding it incredibly addictive myself.

> Could you please clarify (by example?) your intent of nonlocality?
> I would also like to learn more about the idea of such a concept being
> associated with physics only...

"Nonlocality" is an idea in physics which describes situations in which
a cause has effects which are immediate and far away. I guess the
simplest example is that of classical (pre-quantum) mechanics, which
simply assumes that the gravitational effect of one body on another
takes no time to travel from one body to the other.

In classical mechanics this assumption of instantaneous interaction is
always coupled with some kind of a problem, like for example the
inability of the assumption to cope with various observed relativistic
effects. For this reason we regard nonlocality as "taboo" and "wrong".
However in quantum theory there are many effects which are nonlocal,
which make all kinds of weird things possible, like for instance the
capability of a neutron to instantaneously disappear out of an atomic
nucleus and so make it radioactively decay.

The reason why it might be argued that such an idea is associated only
with physics is that quantum effects tend to cancel each other out in
the large-scale world (unless you intentionally build a device which
amplifies the effects, like a laser or NMR tomograph). The motivation of
my question was not so much to find out whether anyone on the list is
using such quantum devices, but rather to inquire whether the idea of
nonlocality might have _any_ kind of application outside physics. In
essence, I wanted to know whether it is ever, under any circumstances,
justifiable to neglect interaction time in mutual interactions. The
answer seems to to be a more-or-less resounding "no", but I must say I
still have my own sneaking doubts...

Best wishes,
Niall.
From: Niall Palfreyman <
niall.palfreyman@fh-weihenstephan.de>
=?iso-8859-1?Q?Andr=E9_Reichel?=
Junior Member
Posts: 14
Joined: Fri Mar 29, 2002 3:39 am

Representing constraints

Post by =?iso-8859-1?Q?Andr=E9_Reichel?= »

Niall wrote:

| using such quantum devices, but rather to inquire whether the idea of
| nonlocality might have _any_ kind of application outside physics. In
| essence, I wanted to know whether it is ever, under any circumstances,
| justifiable to neglect interaction time in mutual interactions. The
| answer seems to to be a more-or-less resounding "no", but I must say I
| still have my own sneaking doubts...

Hm, in everyday business I would also say "no"... but if you look to
anthropology and the various theories on the development of early humans,
there are two major hypotheses:
(1) Out of Africa, which means humanity originated soley from that
continent;
(2) mutual development, which proposes similar developments in different
places in Africa and Asia.
Although the out of Africa fraction seems to have the hand up, recent
discoveries of the Toumai scull in Chad -- some 2500 km away from the
cradle of humanity in East Africa-- raised the question, if there could
still be a possibility that human evolution might have happened in different
places at the same time, in a sort of scrub-like manner. The problem is,
that fossils are rare and the span of time between them is wide. Still, it
is a fascinating idea that non-localities could occur, even in complex
socio-biological systems, but we still have to wait for more evidences. I
wonder, if there would be a possibility to model non-localities in social
systems or, at least, be able to give a good hypotheses for them.

Many regards / Viele Grüße
André Reichel < reichel@sofo.uni-stuttgart.de >
Universität Stuttgart, Germany
Alan Graham
Member
Posts: 27
Joined: Fri Mar 29, 2002 3:39 am

Representing constraints

Post by Alan Graham »

This is a perfect example of model purpose having much to do with the
formulation (even though in a domain the SD community isnt often paid to
solve problems or teach in):

For the classic piston-in-a-cylinder setup, with the piston position being
changed in time horizons of seconds: represent volume as exogenous, heat
content is the state variable, and temperature is an auxilliary. The
cylinder cools as a function of temperature in Newtons law fashion,
establishing a negative feedback loop.

For a situation where youre heating up a gas in a closed container, volume
is constant, heat content is the state variable and temperature and pressure
are both auxilliaries.

If the container leaks, both heat content and amount of gas are state
variables, with negative loops around temperature and cooling, and pressure
and leaking. A coflow relationship determines heat loss through leakage.
This model structure also works with a slowly (and exogenously) moving
piston.

Of course, if youre modeling PV=NrT inside a gun being fired, the "piston"
(bullet) position becomes an endogenous quantity. Volume is a function of
position of the piston (bullet), which integrates velocity, which integrates
acceleration, which equals cross-section times pressure over mass of the
bullet. (neglecting friction, and with the less-than obvious assumption
that the gas inside the barrel has enough time to reach a spatial
equilibrium of pressure--but it cant be terribly far off.)

One lesson: The variables one measures, particularly at specific locations,
may not be the appropriate state variables.

cheers,

alan
From: Alan Graham <
Alan.Graham@paconsulting.com>
John Sterman
Senior Member
Posts: 117
Joined: Fri Mar 29, 2002 3:39 am

Representing constraints

Post by John Sterman »

Id like to second Alan Grahams excellent reply to Nialls query
about representing the ideal gas law PV = NkT as an explicit
dynamical system. Alan described beautifully how different purposes
(e.g., representing different physical situations, such as heating a
closed container of gas versus, say, compressing a fixed mass of gas)
would lead to different models with different state variables and
different dynamics.

The key point is this: The gas law as stated in PV = NkT is an
equilibrium relationship and not a dynamical system. System dynamics
models are designed to represent disequilibrium processes, that is,
processes in which the state variables are changing over time. The
focus on dynamics is the reason for the requirement that all feedback
loops include at least one stock (state variable), and the reason
none of the SD software packages will allow you to build a model that
contains loops without levels. The error message that results when
one tries to do this is NOT a defect in the software, it is a message
that the modeler is attempting to represent a dynamical process as an
equilibrium one.

If all you want to do is show the locus of equilibria for particular
choices of P, V, N, or T, then system dynamics is NOT the right tool.
Use Mathematica or some other program that handles algebraic
relationships.

If you want to build a model that represents *how* a system moves
from an initial state to some other state, or responds to changes in
the environment (such as changes in volume, heat inflow, pressure,
etc.), then one can pursue the modeling strategy Alan recommends,
choosing the model structure (state variables) that are appropriate
for the particular situation. Doing so for arbitrarily large or fast
changes can get messy. This is why elementary courses treating such
systems, e.g., the Carnot cycle, make severe simplifying assumptions
about the changes to the system. These include moving the system
slowly from an initial state to a final state, instantly changing
one variable (before others can react), or allowing the temperature
of the system to constantly equilibrate with a constant temperature
external heat source/sink. Assumptions of adiabatic or isothermal
change are commonly made in elementrary thermodynamic modeling to
simplify the system and reduce the dimensionality of the state space.

Note also that typical elementary treatments of the dynamics,
including Alans excellent suggestions for modeling different
situations, take a traditional lumped parameter view. That is, the
gas is treated as a single homogeneous quantity whose *internal*
states go to equilibrium quickly relative to the dynamics of the
situations Alan describes, that is, to the rate of change in states
caused by the disequilibrium between the gas and its environment.
For many situations, this is a reasonable assumption. For others, it
is not. For example, in Alans bullet-in-a-barrel example (or in the
similar piston-in-an- internal combustion engine), it may be
important, depending on the model purpose, to represent the
propagation of the shock waves caused by the explosion. In this case
it is not appropriate to assume internal states of the gas are in
equilibrium and one typically moves to a partial differential
equation representation, solved by finite element or other means.
One could go further and note that the PDE approach assumes the gas
is a continuous medium, and propose a molecular dynamics simulation
representing the individual molecules; that representation could be
further elaborated to represent the individual atoms in the gas
molecules, the electron shells in the atoms, the interactions with
the atomic nuclei, etc., in a never-ending path of disaggregation and
detail. Of course such a model quickly becomes infeasible.

Which representation is right? None. All are models and all are
wrong. The relevant question is which representation is appropriate
for your purpose.

John Sterman
From: John Sterman <jsterman@mit.edu>
Tom Fiddaman
Senior Member
Posts: 55
Joined: Fri Mar 29, 2002 3:39 am

Representing constraints

Post by Tom Fiddaman »

I like Alan Grahams approach to gas laws as it gets at an operational
description of the problem, which will probably be more
intuitive/interesting to students than just playing with the algebra.

But assuming that you really do want to play with the algebra, the obvious
output is a 3d surface plot - i.e. a graph with P, V, and T axes and a
surface representing the feasible combinations given Nk. This would be a
lot easier to generate in Mathematica or just Excel (e.g. for the latter
set up a 10x10 matrix of cells, with pressures and volumes along the edges
and the corresponding temperature in each cell, and create a surface chart
of the results).

Having two things on the LHS of an equation is causally weird anyway, so if
you must use SD software, why not just create all 3 permutations of the
equation - P=NkT/V, V=NkT/P, T=PV/N/k - and let people play with those. If
you make one of the RHS inputs a RAMP function (so it varies over some
interesting range), and the other a user-controllable slider, students
could then see how one varies with another, subject to the third. In
Vensims new SyntheSim mode you could make the variations and see the
output realtime, though its still rather unexciting as there are no dynamics.

There are two fancy ways to implement the dependency, without creating
equilibrating stocks or writing your own software. Both follow the lines of
Mike Evans and Raymond Jos suggestions: create a function G(P,V,T) = P*V -
N*k*T that represents the error in meeting the constraint implied by some
combination of PVT, and then force that function to 0. One way to force it
to zero is by optimization (create an objective function that minimizes
G(PVT) by varying one of the inputs). Another is to use a simultaneous
equation solver (the SIMULTANEOUS or FIND ZERO functions in Vensim). While
both approaches are helpful or essential with more complex problems, in
this case they seem to complicate things rather than illuminate them.

Tom
From: Tom Fiddaman <tom@vensim.com>
Alan Graham
Member
Posts: 27
Joined: Fri Mar 29, 2002 3:39 am

Representing constraints

Post by Alan Graham »

I have to raise two objections to some of the implications of the exchange
between Mssrs. Palfreyman and Barry, based on some of the values
traditionally espoused by the system dynamics community. John Stermans
reply has touched on these, but Im compelled to amplify, as the majority of
e-correspondance here seems to slide by these fundamental points. Apologies
in advance to all for a vigorously negative view of what may have seemed
like an innocent technical question, but it goes to the heart of what makes
System Dynamics uniquely useful, and we as a community stray at our peril.

SD models are useful only in very small part because of the software, and in
large measure because the models are transparent and testable along many
dimensions. Among those dimensions and very importantly so is reviewability
(and rejectability) by experts in the domains in question.

My first objection, then, is to the apparent process of coming up with the
"simplest solution". The discussion gives the strong impression that a
legitimate process for representing constraints is to arbitrarily anoint all
the variables involved as state variables, then create fictitious rates of
change directly subverts the easy inspectability of the model and
correspondance to physically real and known phenomena. With apologies if a
different process was followed and Ive misconstrued, questions which imho
must be asked are purpose (who the user/beneficiary of the modeling is, what
the use of the model will be, what the specific situation is) and more
tactically, which of the quantities represent independent, physically
enduring quantities.

Which brings me to my second objection, to the results of the process: I
dont think the statement that the solution "reflects the actual physics"
can be validly made even from superficial level of inspection. Absent a
specific situation, how can one judge? In the bullet-in-a-barrel example,
there are more state variables (position and velocity of the bullet). In
addition, the suggested rates have no obvious relation to a physical process
that would allow one to say even within orders of magnitude what an
appropriate value would be. Moreover, its not even clear that the
first-order form is correct. If the system involves a leak, as I understand
flow mechanics (in a very limited scope), the rate of material flow is
proportional to hgher powers of the pressure difference between inside and
outside. Finally, the "simplest solution" (if its stable at all)
equilibrate at zero. While one can adjust the definitions of pressure and
temperature to outside conditions, this is committing the frequent
spreadsheet sin of making assumptions invisible and hence uninspectable. A
model communicates far better when, e.g., you can point to a rate responding
explicitly to a temperature differential and say "Newtons law cooling".
Thats a point of easy and quick validation. The simplest model isnt
necessarily best if it hides information people need to see to validate its
structure.

So in brief, I suggest that the answer to "how do you represent constraints"
is that you look at whats really going on, and create a dynamic model
formulated so as to be useful to someone. Subverting software to compute
equilibria alone (with the intervening convergence basically meaningless)
misses the point and power of system dynamics.

Again apologies for the vigor of my little essay. But imho these things
need to be stated forcefully, or the in the long run the world loses a
unique and valuable approach to improving important and complex situations.

cheers,

alan
From: Alan Graham <
Alan.Graham@paconsulting.com>

PS I wouldnt mind seeing a thread of dialog on "what makes SD unique and
how do we preserve that while avoiding insularity?" akg
"Chariya Peterson"
Junior Member
Posts: 7
Joined: Fri Mar 29, 2002 3:39 am

Representing constraints

Post by "Chariya Peterson" »

Since the Constraint thread is still luke warm, Id like to ask the
following technical question.

Is there an easy way to impose a constraint between two out flows O1, O2
from the same stock S:
O1(n+1) + O2(n+1) <= S(n)

in order to prevent S(n+1) to turn negative.


chariya
From: "Chariya Peterson" <
Chariya.Peterson@verizon.net>


[ Hosts Note - Though this question is posed in pure difference equation form
the answer is the same. If S can not go negative this means that when S
approaches 0 something must cause all the outflows to go toward 0. Thus the
equations for both 01(t) and 02(t) must depend on S(t). There are, of course,
lots of ways this can be done. Using a MIN function or a lookup table and
having 02 depend on O1 (or vice versa) is the most obvious approach.]
Locked