| … | … | @@ -502,37 +502,28 @@ |
| 502 | 502 | (cog-set-value! (car individual-list) seir-state infected) |
| 503 | 503 | |
| 504 | 504 | ; --------------------------------------------------------------------- |
| 505 | | ; Obtain a list of all friendship relations, and all encounters between |
| 506 | | ; strangers. We don't really need to have these (they can always be |
| 507 | | ; generated on the fly) but they're handy to look at and have around. |
| 508 | | |
| 509 | | (define all-relations (remove-duplicate-atoms (append-map |
| 510 | | (lambda (individual) (cog-incoming-by-type individual 'SetLink)) |
| 511 | | individual-list))) |
| 512 | | |
| 513 | | (format #t "The social network consists of ~D pair-wise relationships\n" |
| 514 | | (length all-relations)) |
| 515 | | |
| 505 | ; Reporting statistics. |
| 506 | ; |
| 507 | ; Two reports are provided. The first describes the structure of the |
| 508 | ; generated network: the number of friend and stranger relationships |
| 509 | ; in the network. The second describes the progression of the disease |
| 510 | ; state. |
| 511 | ; |
| 512 | ; Obtain a list of pairs of interacting individuals, who interact either |
| 513 | ; through friendship or stranger encounters. |
| 516 | 514 | (define (get-relations-of-type RELATION) |
| 517 | | (filter-map (lambda (relpair) |
| 518 | | (equal? RELATION (gar (car |
| 519 | | (cog-incoming-by-type relpair 'EvaluationLink))))) |
| 520 | | all-relations)) |
| 515 | (exec-unwrap |
| 516 | (Get |
| 517 | (TypedVariable (Variable "$pair") (Type "SetLink")) |
| 518 | (Present (Evaluation RELATION (Variable "$pair")))))) |
| 521 | 519 | |
| 522 | | (define friend-relations (get-relations-of-type (Concept "friend"))) |
| 523 | 520 | (format #t "The social network consists of ~D friend-pairs\n" |
| 524 | | (length friend-relations)) |
| 521 | (length (get-relations-of-type (Concept "friend")))) |
| 525 | 522 | |
| 526 | | (define stranger-relations (get-relations-of-type (Concept "stranger"))) |
| 527 | 523 | (format #t "The social network consists of ~D stranger-pairs\n" |
| 528 | | (length stranger-relations)) |
| 524 | (length (get-relations-of-type (Concept "stranger")))) |
| 529 | 525 | |
| 530 | | ; --------------------------------------------------------------------- |
| 531 | | ; Reporting statistics. |
| 532 | | ; |
| 533 | | ; As the simulation progresses, some reports are needed. This implements |
| 534 | | ; a very simple reporting function. |
| 535 | | ; |
| 526 | ; --------- |
| 536 | 527 | ; Obtain a list of individuals in a given state. |
| 537 | 528 | (define (get-individuals-in-state STATE) |
| 538 | 529 | (exec-unwrap |