[comp.object] How would you model this situation?

pcb@cacs.usl.edu (Peter C. Bahrs) (10/17/90)

The Domain: Object-oriented with concurrency if needed, objects have
     local state, behaviors

The Problem:
  Model an application where two things(people) ara each applying a 
force(pulling) on another thing (ends of a rope).  The acted upon
thing (the rope) breaks.

So suppose I tell person1 to pull X amount.  Should I model all of
the interactions at an application level and then send the rope and 
person2 reactionary messages.  Or should person1, who knows about a
rope (globally) tell the rope to adjust it self, which in turn must
tell person2 to adjust hisself.  So if the rope breaks, how are the
references in person1 and person2 updated?  Does the existing rope
references become forwarders to new part-rope objects?  In summary,
are interactions managed external to objects or should this be
migrated inside the objects.

Please post responses to the net.

/*----------- Thanks in advance... --------------------------------------+
| Peter C. Bahrs                                                         |
| The USL-NASA Project                                                   |
| Center For Advanced Computer Studies      INET: pcb@swamp.cacs.usl.edu |
| 2 Rex Street                                                           |
| University of Southwestern Louisiana      ...!uunet!dalsqnt!gator!pcb  | 
| Lafayette, LA 70504                                                    |
+-----------------------------------------------------------------------*/

zougas@me.utoronto.ca ("Athanasios(Tom) Zougas") (10/18/90)

pcb@cacs.usl.edu (Peter C. Bahrs) writes:

>The Domain: Object-oriented with concurrency if needed, objects have
>     local state, behaviors

>The Problem:
>  Model an application where two things(people) ara each applying a 
>force(pulling) on another thing (ends of a rope).  The acted upon
>thing (the rope) breaks.

>So suppose I tell person1 to pull X amount.  Should I model all of
>the interactions at an application level and then send the rope and 
>person2 reactionary messages.  Or should person1, who knows about a
>rope (globally) tell the rope to adjust it self, which in turn must
>tell person2 to adjust hisself.  So if the rope breaks, how are the
>references in person1 and person2 updated?  Does the existing rope
>references become forwarders to new part-rope objects?  In summary,
>are interactions managed external to objects or should this be
>migrated inside the objects.

If we were to take the approach that we want to simulate what happens
in reality, we may get the following:
	o person1 is told to pull by X
	o person1 transmits the message to the rope, another 'object',
		that it is pulling by X
	o the rope responds according to its physics, tell person2 that
		it is pulling him be X amount
	o person2 has to have some type of boundary condition to be
		able to react to the rope's message (pull back to
		remain motionless, fall down, etc.)
	o if the rope breaks it tells person1 and person2 that it no
		longer will support their forces, and they responc accordingly
This situation is essentially a set of simultaneous equations that need to
be solved. The steps described above are simply the steps in solving the
equations. An analog I see to the above is the field of finite elements
were the people are the boundary conditions, the rope the element, and
the ends of the rope, the nodes.

Just some thoughts from...
Tom.
-- 
I can be reached at...
  zougas@me.utoronto.ca || zougas@me.toronto.edu || ...!utai!me!zougas

hal@dumbcat.sf.ca.us (Hal Wine) (10/24/90)

In article <16734@rouge.usl.edu> pcb@cacs.usl.edu (Peter C. Bahrs) writes:
> The Domain: Object-oriented with concurrency if needed, objects have
>      local state, behaviors
> 
> The Problem:
>   Model an application where two things(people) ara each applying a 
> force(pulling) on another thing (ends of a rope).  The acted upon
> thing (the rope) breaks.
> 

I haven't actually done an OO system like this, either, but I have a few
observations (i.e. opinions) based on the OO systems I have done.  (Another
caveat -- it's been *years* since I did any classical mechanics.):

-	It seems that there are actually two issues here: how to model the
	interaction between the objects; and how to propigate changes in a
	model during simulation.  I'll only address the first.

-	I see more than the three objects in the system, as there are also the
	connections between these objects.  I'll refer to the original objects
	as simulation objects, and the connections as simulation connections.  

	The simulation connections have knowledge of how the change (e.g. force
	vector) propigates across that connection, as well as the simulation
	objects to which it is connected (I think there are only two, but I
	couldn't prove it).

	Similarly, the simulation objects know about all of their connections,
	as well as how a change affects it (e.g. for force: deformation,
	acceleration, etc.), and all the proporties of the object (location,
	motion, color, etc.).

	(Note that a collection of such objects is a simulation system, and that
	they could exist recursively.  I.e., the rope could be modeled by a
	system consisting of the two end points as simulation objects joined
	by a simulation connection that would have knowledge of the breaking
	point.  The rope ends might know about stretch, etc..)

(The rest of this discussion assumes that we're only dealing with a classical
mechanics aspect of the tug of war, and will ignore physiological changes
and psychological connections <grin>.)

-	When a change in force is imposed on a simulation object, it responds
	with the force vector comprising the "equal and oposite reaction" that
	comes back across the connection.  Any unbalanced force contributes to
	motion of the system.  I.e. the net force is the (vector) sum of the
	input force and the results of propegating the input force across the
	object and all other connections.  (Note that this results in an order
	'n' squared algorithm.)

-	Putting it together (and ignoring simulation timing), when person 1 (p1)
	pulls away, the change in force vector is sent to the p1-rope connection
	which in turn propegates the vector to the rope.  The rope deals with
	stretch, and propigates the remaining vector to the rope-p2 connection,
	which passes it on to the person 2 (p2) object.  The p2 object calculates
	the net force acting on it, notes any changes to its position, and returns
	its opposing force.  The rope integrates that force into its state, and
	returns the total opposing force to p1.  P1 can then update its position,
	based on its net force.

-	If the rope breaks, the rope (or the rope end to rope end connection)
	know this and simply no longer propigates a force.  This preserves the
	integrity of the system, and requires no special handling by any other
	simulation object or simulation connection.

Physics aside, what this means from an OO design standpoint is that each
object knows about its neighbors only via connections, and propigates *all*
changes to those connections.  It is up to the connections to decide what
(if anything) to do about the change.  The knowledge of the connections is
limited to their existance, however; i.e. each simulation object has a
connection list over which it iterates the sending of the change message.
Furthermore, the connection list is local to each object.  Only those parts
of the model which receive some sort of outside input need to be visible to
other parts of the application.

(For what its worth, I've successfully used similar designs for updating
multiple views of a model and protocol stacks.)

This reply got overlong, thanks for presenting such an interesting problem.
I may have to try implementing some of this...

--Hal
-- 
-- hal@dumbcat.sf.ca.us
-- {ames,decwrl,sun}!pacbell!dumbcat!hal

tma@m5.COM (Tim Atkins) (10/28/90)

In article <16734@rouge.usl.edu> pcb@cacs.usl.edu (Peter C. Bahrs) writes:
>The Domain: Object-oriented with concurrency if needed, objects have
>     local state, behaviors
>
>The Problem:
>  Model an application where two things(people) ara each applying a 
>force(pulling) on another thing (ends of a rope).  The acted upon
>thing (the rope) breaks.
>
>So suppose I tell person1 to pull X amount.  Should I model all of
>the interactions at an application level and then send the rope and 
>person2 reactionary messages.  Or should person1, who knows about a
>rope (globally) tell the rope to adjust it self, which in turn must
>tell person2 to adjust hisself.  So if the rope breaks, how are the
>references in person1 and person2 updated?  Does the existing rope
>references become forwarders to new part-rope objects?  In summary,
>are interactions managed external to objects or should this be
>migrated inside the objects.
>
>Please post responses to the net.

Well now, I would model such a thing a bit differently.  

Each person model might contain:
	what force is being applied to (reference to rope);
	what force is being applied (with direction);
	what force is being experienced (counter pull);
	perhaps acceleration detector stuff and correction if over some limit
	or some fixed distance from a known point is traversed.

The rope model would contain:
	end data on agents attached and length of rope starting at end;
	total length of rope;
	force applied to each end;
	some model of rope stress limits.



So, each agent would be instructed:
	grab rope 
		set first model variable and inform rope of attachement;
	apply force OVER time
		set force variables for persons which get transmitted to rope;
		rope calculates stresses and resultant forces and transmits
		each end force to opposite end holder as long as it is intact;
	on separation 
		rope computes break point and sets internal state;
		transmits change of force messages to end holders;
		end holders respond with acceleration and therefore velocity
		changes which they can respond to;
	each person or the rope itself could be queried directly or indirectly
	for how big their piece of rope is, there current acceleration, etc.


Does this model seem reasonable?

- Tim