Appendix D



Proto Sim Object Oriented Version

Initial Spec. (undocumented here, merely provisional ideas - see website)

Show object diagrams - translations from procedural model

object relationship diagrams

Classes, objects, processes and a prototype sim! Time interval = 1 year also 1 month cycles

new pcodes prefixed by birth year

Classes Objects Data(variables) ObjProcesses(methods) GRAPH

People(sim yrly)

Male

Pcode

HHCode

Age

Sex

Rel_to_HHH

Special_skills

Spec_urban_investment

Spec_busines

Food

Qty_land_inherit

Pen_mig

Perm_mig

Health

pCash_agri

pCash_mig

pcashincomespecinvest

Pen_mig

Perm_mig

SK_res.

childpcodes

Marragepcode

Female

Pcode

HHCode

Age

Sex

Rel_to_HHH

Special_skills

Spec_urban_investment

Food

Qty_land_inherit

Pen_mig

Perm_mig

Health

pCash_carpets

pCash_trouso

Pen_mig

Perm_mig

SK_res.

childpcodes

Marragepcode

House Holds (sim yrly)

Hhold

HHCode

Land_area

no_of_people count pcodes

no_of_males count pcodes sex in same hholdcode

Classes Objects Data(variables) ObjProcesses(methods) GRAPH

no_of_females count pcodes sex f same hholdcode

Cash_agri count males in hh pcash_agri

Cash_mig count males in hh pcash_mig

Cash_carpets count females in hh pcash_carpet

Credit

Machiner

SK_res.

Pen_mig

Perm_mig

HH_status

Yield

Seed

food/pp no of people in yr / yield

yearly_expenses

cash surplus

no_of_Oxen

Energy((sim yrly Agg.

Availableene

No_of_men

No_of_women

No_of_tractors

No_of_oxen

Neededene

No_of_men

No_of_women

No_of_tractors

No_of_oxen

Surplusene

No_of_men Yes

No_of_women Yes

No_of_tractors Yes

No_of_oxen Yes

Village Income(sim agg yrly)

Cash Agri.

Villagriin_yr Yes

Cash Mig

Villmigin_yr Yes

Cash Carpets

Villcarpin_yr Yes

Village Living expenses(sim agg yrly)

Expenses / house hold

Villexp_yr Yes

Buildings(sim agg yrly)

New SK

Newsk Yes

New Gekondos

Newgek Yes

New Urban Speculations

Newurspec Yes

Food(sim monthly)

Food

Rainqty_month "whole harvest " Yes

Tempmin_month Yes

Tempmax_month Yes

Classes Objects Data(variables) ObjProcesses(methods) GRAPH

BugYieldreduction

Seedcashplant

Gross yield

Net yield

Croptype

Fertilizerplant

Health(sim agg yrly)

Medicine antibiotics

Medicine

Cash

Affordmed

Hospitals

Hospital

Doctors

No_of_docs

Knowledge

healthedu

Population (sim agg yrly)

SK_res

Popsk Yes

Pen_mig

Poppenmig Yes

Perm_mig

Popmig Yes

Iobs(agg all from real census)

Male

imPcode

imHHCode

imAge

imSex

imPenmig

imPermmig

imSk

iyearobs

nomiobs counim pcode Yes

Female

ifPcode

ifHHCode

ifAge

ifSex

ifPenmig

ifPermmig

ifSk

iyearobs

nofiobs Countif pcodes Yes

History(sim agg yrly)

Events

Year

pcash_mig

pcash_agri

pcash_carpets

PROCESSES: main methods to cycle

Marrying

male,female,hhold hhstatus OK age range OK health OK age

>15(distrib pop)-marry

Planting

food,Hholdhhold land + no of men or trsctor =

time, + seed

Growing

food,hhold gross expectation

Bugging

food gross yield reduction by factor

Harvesting

food,hhold net yield updates hhold food

buying

machine, hhold if hh cash surplus and land > thresh

old and cash = enough

and year =>1971 buy tractor reduce animals

buying fertilizer hhold

if hh cash surplus and and cash =

enough and year = >threshold buy

fertilizer else need credit and buy

fertilizer

Migrating

male,female,Hhold, ifstatus low or no cash or land in

herit< threshold or pop

sk,pen_mig,perm_mig

wealthy and year > threshold +

others sons

Birthing

male,female,hhold,popsk,popmig from birth distribution create male

female random 50 % prob to married

couples

Dying

male,female,hhold,popsk,popmig from death distribution killoff male

female pcodes random 50 % prob

Inheriting male,Hhold Oldest non migrating son at fathers

death son pcode becomes hhh

Building

newsk,newgek,newurspec surplus casn non migrating hh builds

mig hh with surplud cash build gk

mig hh with surplus cash > threshold

speculates

Earning

hhold,pcashmig,pcashagri,

pcashcar

pets

sums hh aggr incomes from male, fe

male

PhysicalConditioning

male,female gives health score for people

Speculating

male,hhold hhmig and cash surplus > threshold

then spec

Investing

male,hhold calc return on investment - random +

GNP rise

Countenesurmen Avail

able,needed,surplus count surplus men in all hh

Countingenewomen Avail

able,needed,surplus count women in

all hh

Countingenemen Avail

able,needed,surplus countmen in all hh

Countingenetractors Avail

able,needed,surplus count total tractors

Countingeneanimals Avail

able,needed,surplus count total no of animals

Countingvillagiin Cash

Agri,Cash Carpets

Countingvillmigin Cash

Mig

Countingvillcapin Cash

carpets

Countingvillexpout hhold

Counting hhcash

surp hhold

Countingnewsk

hhold,buildings

Countingnewgk

hhold,buildings

Countnewurbanspec

hhold,buildings

Countinvestments male

Countpopsk hhold,

popsk

Countpoppenmig

hhold,popmig

Countpoppermmig

hhold,popmig

Counting surplusene surplus

calc retun on investmesnt

calc retutn on spec.

Graphingcounts (yes graph objects)

(Problem with trying to implement the above is that it assumes that I already know the answers. break it down) - test it and build it up! too complex as a first try!!!!

Keep to Birthing - eating dying processes

generate the food give to people

generate the people if enough food given

couple the people

generate births

kill the people

New proto sim for realistic implementation - a subset of the larger picture.

Objectives.

reasons for migration!

pop explosion - antibiotics?

house holds remain constant at approx 6 person per hh.

pops increase new hh increase start to migrate

look at land sharing - work out a carrying capacity and see when it is exceeded by distribution amonst sons - (the strategy continues in pther words)

Don't model cash system -

Here is the reduced spec.

Classes Objects Data(variables) ObjProcesses(methods) GRAPH

People(sim yrly)

Male

Pcode

HHCode

Age

Sex

Food

Qty_land_inherit

Pen_mig

Perm_mig

Health

SK_res.

childpcodes

Marragepcode

YOB

YOD

Female

Pcode

HHCode

Age

Sex

Food

Qty_land_inherit

Pen_mig

Perm_mig

Health

Pen_mig

Perm_mig

SK_res.

childpcodes

Marragepcode

YOB

YOD

House Holds(sim yrly)

Hhold

HHCode

Land_area

no_of_people count pcodes

no_of_males count pcodes sex m same hholdcode

no_of_females count pcodes sex f same hholdcode

Machinery

SK_res.

Pen_mig

Perm_mig

HH_status

Yield

food/pp noofpeopleinyr / yield

Food(sim monthly)

Food

Rainqty_month "whole harvest method" Yes

Tempmin_month Yes

Tempmax_month Yes

BugYieldreduction

Seedcashplant

Gross yield

Net yield

Croptype

Fertilizerplant

Population (sim aggri. yrly)

SK_res

Popsk Yes

Pen_mig

Poppenmig Yes

Perm_mig

Popmig Yes

History(sim agg yrly)

Events

Year

Date medicine

date machines

date fertilizer

PROCESSES: main methods to cycle

Marrying male,female,hhold hhstatus OK age range OK health OK

age >15(distrib pop)-marry

Planting food, Hhold hholdland + no of men or trsctor =

time, + seed

Growing food,hhold gross expectation

Bugging food gross

yield reduction by factor

Harvesting food,hhold net

yield updates hhold food credit and buy fertilizer

Migrating male,female,Hhold, if

tus low or no cash or land inherit< threshold or pop

sk,pen_mig,perm_mig

wealthy and year > threshold + others sons

Birthing male,female,hhold,popsk,popmig from birth distribution create male female random 50 % prob to

married couples

Dying male,female,hhold,popsk,popmig from death distribution killoff male female pcodes random 50 %

prob

Inheriting male,Hhold Oldest non migrating son at fathers death son

pcode becomes hhh

illness male,female gives health score for people

Countenesurmen Available,needed,surplus count surplus men in all hh

Countingenewomen Available,needed,surplus count women in all hh

Countingenemen Available,needed,surplus countmen in all hh

Countingenetractors Available,needed,surplus count total tractors

Countpopsk hhold,popsk

Countpoppenmig hhold,popmig

Countpoppermmig hhold,popmig

Graphingcounts (yes graph objects)

Even this is too complex try again!

Implementable Reduced Spec.

Classes Objects Data(variables) ObjProcesses(methods) GRAPH

People(sim yrly)

Male

Age

Sex

Food

Health

YOB

YOD

Female

Age

Sex

Food

Health

YOB

YOD

Food(sim monthly)

Food

Rainqty_month "whole harvest method" Yes

Tempmin_month Yes

Tempmax_month Yes

BugYieldreduction

Seedcashplant

Gross yield

Net yield

Croptype

Fertilizerplant

Health(sim agg yrly)

Medicine

antibiotics

Medicine

Cash Affordmed

Hospitals

Hospital

Doctor

No_of_docs

Knowledge

healthedu

Implementation Notes on Java -

DEF:

implements

classes

components

objects

visual objects

related classes!

When an object sends a message it needs:

The object to whom the message is sent!

The name of the method to perform

The parameters needed by the method!

An object is an instance of a class.

There are object methods and variables and class methods and variables

You can access any class methods and variables from any object or from the class

Class methods can only act on class variables they do not have access to object variables

Object are subclasses of Classes (blue prints and actual useful entities)

Classes are super classes or objects

Each subclass inherits variable declarations from its super class - This is called inheritance

The subclass inherits State from the superclass or the object inherits state from its parent class.

The state plus method = behaviour.

These states can be overiden and changed and added to

The further down the inheritance hierarchy you go the more specialised the objects behaviour

(see "benefits of behaviour" p 40 Java manual (scanned in))

The nuts and bolts of Java!

Variables and data types

operators

expressions

control flow statements

arrays an strings

main methods

exceptions

standard input - output.

Model using these tools!

class blocks are enclosed by { }

variables SCOPE

member variable

local variable

method parameter

exception handler parameter

local and member variables can be initialised

int count = 0;

standard in - out streams

system.in.read()

system.out.println();

references system class variables

Objects -

creating

using

destruction.

An objects class is an objects type!

An interface is a collection of method definitions (without implementations) and constant values!

they are used to define a protocol of behaviour that can be implemented by any class in the class hierarchy.

classes and interfaces get grouped into "packages" - generic

declaration instantiation and initialisation can all occur in

Date Today = new date();

if I have an object Rect

I can directly access its variables Rect.x and Rect.y

or

rect.move(15, 12)

calls the rects move method to manipulate x na dy indirectly

me.move(14,89) move another object rect

method calls are MESSAGES

creating classes

class imaginary number extends number implements arithmetic {

)

creates a class from the super class number and uses an interface arithmetic.

Multicycle runs sims

cycle params runs one cycle of the sim