A core Course on Modeling Introduction to Modeling 0LAB0 0LBB0 0LCB0 0LDB0 S.16
2 Nothing depends on its own future. Quantities’ current values can only depend on their previous values Totally ordered time: recursive functions
3 Q curr =F(Q prev,P prev ) Dependency works from ‘previous’ to ‘current’, Q prev and P prev have no dependence on Q curr. So we won’t have Q curr =F(Q curr, …) Evaluate F for each of the Q irrespective of the order. Totally ordered time: recursive functions
4 Q curr =F(Q prev,P prev ) Dependency works from ‘previous’ to ‘current’, Q prev and P prev have no dependence on Q curr. So we won’t have Q curr =F(Q curr, …) Evaluate F for each of the Q irrespective of the order. Totally ordered time: recursive functions
5 Q curr =F(Q prev,P prev ) Dependency works from ‘previous’ to ‘current’, Q prev and P prev have no dependence on Q curr. Notice that the following is problematic: X curr =F(X prev,Y curr ) Y curr =G(Y prev,X curr ) X curr = F(G(X curr,...)) Hence both arguments should be ‘prev’. Totally ordered time: recursive functions
6 Q curr =F(Q prev,P prev ) F is called a recursive function: it calculates Q, taking (an) earlier version(s) of Q as argument. Totally ordered time: recursive functions
7 Example for arbitrary intervals: A 120 km bicycle trip; 10 control posts, to be visited in right order every post features a box full of bananas, B kCal each; a list of ‘efforts’ (kCal) between subsequent posts, {E i }, At which posts should you pick banana(s)? Totally ordered time: recursive functions
8 max(0,…): you can’t eat a negative amount of bananas … : rounding up: you don’t want to eat a fraction of a banana Q i =amount of kCal in stomach at post i, i > 0 Q 0 =amount of kCal in stomach at start Q i+1 =Q i -E i if you don’t eat Q i+1 =Q i -E i +n i B if you eat n i bananas at post i What is n i ? Totally ordered time: recursive functions
9 max(0,…): you can’t eat a negative amount of bananas … : rounding up: you don’t want to eat a fraction of a banana Q i+1 =Q i -E i +n i B n i should be such that Q i+1 >0, as small as possible Q i -E i +n i B 0, so n i B E i -Q i ; n i =max(0, (E i -Q i )/B ) Totally ordered time: recursive functions
10 max(0,…): you can’t eat a negative amount of bananas … : rounding up: you don’t want to eat a fraction of a banana Q i+1 =Q i -E i +n i B n i should be such that Q i+1 >0, as small as possible Q i -E i +n i B 0, so n i B E i -Q i ; n i =max(0, (E i -Q i )/B ) Totally ordered time: recursive functions
11 max(0,…): you can’t eat a negative amount of bananas … : rounding up: you don’t want to eat a fraction of a banana Q i+1 =Q i -E i +n i B n i should be such that Q i+1 >0, as small as possible Q i -E i +n i B 0, so n i B E i -Q i ; n i =max(0, (E i -Q i )/B ), so Q i+1 =Q i -E i +B*max(0, (E i -Q i )/B ) or: Q i+1 =F(Q i,P i ) recursive function Totally ordered time: recursive functions