;;; -*- Mode:Common-Lisp; Package:QSIM; Syntax:COMMON-LISP; Base:10 -*- (in-package :qsim) ;;; Definition of software growth model, but without the state transitions ;;; This section can be ignored (define-QDE growth-phase-no-transitions (quantity-spaces (total-effort (0 eff-t inf) "Total effort") (effort-size (0 eff-s inf) "Effort to increase size") (effort-complexity (0 eff-c inf) "Effort to decrease complexity") (size (0 inf) "Size") ; (d-size (minf 0 inf) "d/dt Size") (d-size (0 inf) "d/dt Size") (complexity (0 inf) "Complexity") (complexity-hinder (0 inf) "Complexity-induced growth hinderance") (surplus-effort-size (0 inf) "Surplus effort for increasing size") (d-complexity (minf 0 inf) "d/dt Complexity")) (constraints ((d/dt complexity d-complexity)) ; Law 2 ((ADD d-complexity effort-complexity effort-size)) ((constant total-effort)) ((constant effort-size)) ((constant effort-complexity)) ((ADD effort-size effort-complexity total-effort)) ((d/dt size d-size)) ; Law 5 ((M+ complexity complexity-hinder) (0 0) (inf inf)) ((ADD d-size complexity-hinder effort-size)) ((ADD complexity-hinder surplus-effort-size effort-size)) ((S+ surplus-effort-size d-size) (0 0) (inf inf)) ) (layout (effort-size effort-complexity) (size d-size) (complexity d-complexity) (complexity-hinder nil))) (defun grow-no-transitions () (let* ((normal (make-new-state :from-qde growth-phase-no-transitions :assert-values '((effort-size (eff-s std)) (effort-complexity (eff-c std)) (total-effort (eff-t std)) (size (0 nil)) (complexity ((0 inf) nil)))))) (qsim normal) (q-continue :new-state-limit 100) (qsim-display normal))) ;;; Time to start paying attention again... ;;; The model, with state transitions (define-QDE growth-phase ; Define a system of qualitative differential equations (quantity-spaces ; Define the variables in the system and their landmarks ; Variable name landmarks description (total-effort (0 eff-t inf) "Total effort") (effort-size (0 eff-s-c eff-s-g inf) "Effort to increase size") (effort-complexity (0 eff-c-g eff-c-c inf) "Effort to decrease complexity") (size (0 inf) "Size") (d-size (0 inf) "d/dt Size") (complexity (0 inf) "Complexity") (complexity-hinder (0 inf) "Complexity-induced growth hinderance") (surplus-effort-size (minf 0 inf) "Surplus effort for increasing size") (d-complexity (minf 0 inf) "d/dt Complexity")) (constraints ; Define some constraints (equations) ((d/dt complexity d-complexity)) ; Law 2: d/dt complexity = d-complexity ((ADD d-complexity effort-complexity effort-size)) ; d-complexity = effort-size - effort-complexity ((constant total-effort)) ; Efforts are constant, and sum to a constant ((constant effort-size)) ((constant effort-complexity)) ((ADD effort-size effort-complexity total-effort)) ((d/dt size d-size)) ; Law 5: d/dt size = d-size ((M+ complexity complexity-hinder) (0 0) (inf inf)) ; complexity-hinder = M+(complexity), ; and 0 = M+(0) and infinity = M+(infinity) ((ADD complexity-hinder surplus-effort-size effort-size)) ; surplus-effort-size = effort-size - complexity-hinder ((S+ surplus-effort-size d-size (0 0) (inf inf))) ; d-size = 0 if surplus-effort-size < 0 ; d-size = M+(surplus-effort-size) otherwise ) (transitions ; Define state transitions ((d-size (0 nil)) -> transition-to-consolidation)) ; if d-size becomes 0 (ignoring its direction), move to the consolidation phase (layout (effort-size effort-complexity) ; How to pretty-print the results (size d-size) (complexity d-complexity) (complexity-hinder surplus-effort-size))) (define-QDE consolidation-phase (quantity-spaces (total-effort (0 eff-t inf) "Total effort") (effort-size (0 eff-s-c eff-s-g inf) "Effort to increase size") (effort-complexity (0 eff-c-g eff-c-c inf) "Effort to decrease complexity") (size (0 inf) "Size") ; (d-size (minf 0 inf) "d/dt Size") (d-size (0 inf) "d/dt Size") (complexity (0 inf) "Complexity") (complexity-hinder (0 inf) "Complexity-induced growth hinderance") (surplus-effort-size (minf 0 inf) "Surplus effort for increasing size") (d-complexity (minf 0 inf) "d/dt Complexity")) (constraints ((d/dt complexity d-complexity)) ; Law 2 ((ADD d-complexity effort-complexity effort-size)) ((constant total-effort)) ((constant effort-size)) ((constant effort-complexity)) ((ADD effort-size effort-complexity total-effort)) ((d/dt size d-size)) ; Law 5 ((M+ complexity complexity-hinder) (0 0) (inf inf)) ((ADD complexity-hinder surplus-effort-size effort-size)) ((S+ surplus-effort-size d-size (0 0) (inf inf))) ) (transitions ; ((or (complexity (0 nil)) (surplus-effort-size (0 nil))) -> transition-to-growth)) ((complexity (0 nil)) -> transition-to-growth)) (layout (effort-size effort-complexity) (size d-size) (complexity d-complexity) (complexity-hinder surplus-effort-size))) ;;; Functions to handle the state transitions (defun transition-to-consolidation (growth-state) (create-transition-state :from-state growth-state :to-qde consolidation-phase ; :assert '((effort-size (eff-s-c std)) (effort-complexity (eff-c-c std)) (d-complexity ((minf 0) nil))) ; Assert the new values for the efforts :assert '((effort-size (eff-s-c std)) (effort-complexity (eff-c-c std))) ; Retain the values of size, complexity, and total effort :inherit-qmag '(size complexity total-effort))) (defun transition-to-growth (consolidation-state) (create-transition-state :from-state consolidation-state :to-qde growth-phase ; :assert '((effort-size (eff-s-g std)) (effort-complexity (eff-c-g std)) (d-complexity ((0 inf) nil))) :assert '((effort-size (eff-s-g std)) (effort-complexity (eff-c-g std))) :inherit-qmag '(size complexity total-effort))) ;;; Define the initial state for the simulation (defun grow () (let* ((normal (make-new-state :from-qde growth-phase ; The QDE set to use ; Define the initial values ; Values are given as pairs ; The value may be either a landmark or between a pair of landmarks :assert-values '((effort-size (eff-s-g std)) ; effort-size starts at the landmark, and is unchanging (effort-complexity (eff-c-g std)) (total-effort (eff-t std)) (size (0 inc)) ; size is initially zero and increasing (d-size ((0 inf) nil)) ; d-sze is at some positive value, and its direction is unknown (complexity ((0 inf) nil)) ; (complexity (0 nil)) )))) (qsim normal) (q-continue :new-state-limit 30) (qsim-display normal) )) ;;; Ignore this: it's test code to start the simulation in the consolidation phase (defun consolidate () (let* ((normal (make-new-state :from-qde consolidation-phase :assert-values '((effort-size (eff-s-c std)) (effort-complexity (eff-c-c std)) (total-effort (eff-t std)) (size ((0 inf) nil)) ; (d-size (0 nil)) (complexity ((0 inf) nil)))))) (qsim normal) (q-continue :new-state-limit 200) (qsim-display normal) ))