Resit Assessment

Read Complete Research Material



Resit Assessment

Resit Assessment

Part I: Prolog

Prolog has a number of properties that makes it very useful for qualitative and non-deterministic simulations ? and is weakest in quantitative simulations. (Clocksin ? Christopher ? 2003) There are some problems with Prolog ? because although we will find it relatively easy to represent the sub-models and their interaction in Prolog ? it is often difficult or cumbersome to evaluate the results.

We can define our basic object type in Prolog by using a person fact: person(age ?sex ?status) which we repeat for every person in our population ? where age is either a numerical age ? (Clocksin ? 2003) sex is male or female ? and status is married or unmarried. These could be read from a data file ? created by an initialising program module (in Prolog a program module is called a predicate) ? or typed in. We could then use a very simple (and unrealistic) marriage rule ? 'each unmarried male at or beyond the age of 18 will marry the first female encountered who is 11 years of age or older and who is between 5 and 7 years younger than the male'.

(i) Answer to (i) starts here:

Explain why the program does not function properly at present. (HINT: there may be more than one problem).

/* Database */

 person(abdul ? 24 ? male ? unmarried).person(rubina ?18 ?female ? unmarried)./* ... */person(zarina ? 22 ? female ? unmarried).

 /* Rules */

 marry_all :-/* marry all eligible people */

 marry(Male ? Female) ?/* marry a couple */

 fail./* forces evaluation of  next couple */

 marry_all./* so that marry_all will succeed  after all marriages  */

 marry(Id_male ? Id_female) :- /* marry people if eligible */

 eligible(Id_male ? Id_female) ?change_marital_status(Id_male ?Id_female).

 eligible(Id_male ? Id_female) :- /* check eligibility for marriage */

 person(Id_male ?Age_male ?male ?unmarried) ? /* unmarried male*/

 person(Id_female ?Age_female ?female ?unmarried) ? /* unmarried female */

 age_check(Age_male ?Age_female).

 age_check(Age_male ?Age_female) :-  /* check to see if ages are compatible */

 Age_male >= 18 ?Age_male - Age_female <= 7 ?Age_male - Age_female >= 5.

 change_marital_status(Id_male ?Id_female) :- /* change from unmarried to married status */

 retract(person(Id_male ?Age_male ?male ?unmarried)) ? /* remove old entry */

 assert(person(Id_male ?Age_male ?male ?married)) ? /* add updated information */retract(person(Id_female ?Age_female ?female ?unmarried)) ? /* ditto */assert(person(Id_female ?Age_female ?female ?married)).

The predicate marry_all will attempt to marry everyone in the population according to the defined criteria. This does not mean that everyone who is eligible for marriage will be married at the end ? because of demographic restrictions of the initial population. One problem with this example ? especially from an anthropological perspective is that all males and females are interchangeable with all other males and females respectively. (Clocksin ? Christopher ? 2003) There is no mechanism to take account of kinship or other relationships ? not even such primitive aspects such as sibling-hood! We can accommodate by adding avoidance for half and full siblings: person(Id ?Age ?Sex ?Marital ?Father ?Mother)

marry(Id_male ? Id_female) :- /* marry a couple */

 eligible(Id_male ? Id_female) ?change_marital_status(Id_male ?Id_female).

 eligible(Id_male ? Id_female) :-

 is_male(Id_male) ?not(is_married(Id_male)) ?is_female(Id_female) ? not(is_married(Id_female) ?

 not(are_siblings(Id_male ?Id_female)) ?

 age_check(Id_male ?Id_female).

 is_male(Id) :- person(Id ?_ ?male ...
Related Ads
  • Resit Project
    www.researchomatic.com...

    Resit Project, Resit Project Essay writing help sour ...