Dynamic Modeling and Python Greg Baker, November 2003.

Slides:



Advertisements
Similar presentations
Chapter 2: Memory Management, Early Systems
Advertisements

Chapter 2: Memory Management, Early Systems
Memory Management, Early Systems
Nonparametric tests I Back to basics. Lecture Outline What is a nonparametric test? Rank tests, distribution free tests and nonparametric tests Which.
Hash Tables Hash function h: search key  [0…B-1]. Buckets are blocks, numbered [0…B-1]. Big idea: If a record with search key K exists, then it must be.
Copyright © 2009 Pearson Education, Inc. Chapter 29 Multiple Regression.
FORAGING. ASK THE FOLLOWING QUESTION: 1. WHAT FOOD ITEMS SHOULD A FORAGER EAT? Diet Selection Models Imagine a predator seeking prey: Finds either prey.
Steepest Decent and Conjugate Gradients (CG). Solving of the linear equation system.
GS 540 week 6. HMM basics Given a sequence, and state parameters: – Each possible path through the states has a certain probability of emitting the sequence.
Visual Recognition Tutorial
Hash Tables Hash function h: search key  [0…B-1]. Buckets are blocks, numbered [0…B-1]. Big idea: If a record with search key K exists, then it must be.
Review. In this lecture we will review and fill in loose ends regarding… Variables and how to name them Floating point data types Deciding what type to.
Lecture 1: Basics of Math and Economics AGEC 352 Spring 2011 – January 12 R. Keeney.
x – independent variable (input)
Hidden Markov Model 11/28/07. Bayes Rule The posterior distribution Select k with the largest posterior distribution. Minimizes the average misclassification.
Hash Table indexing and Secondary Storage Hashing.
General Computer Science for Engineers CISC 106 Lecture 19 Dr. John Cavazos Computer and Information Sciences 04/06/2009.
Reinforcement Learning
CSI 101 Elements of Computing Spring 2009 Lecture # 8 Looping and Recursion Wednesday, February 25 th, 2009.
Run time vs. Compile time
Fitting a Model to Data Reading: 15.1,
Tirgul 7. Find an efficient implementation of a dynamic collection of elements with unique keys Supported Operations: Insert, Search and Delete. The keys.
1 Chapter 8 Designing Small Programs. 2 A ‘Procedure’ v A set of instructions which describe the steps to be followed in order to carry out an activity.
1 Run time vs. Compile time The compiler must generate code to handle issues that arise at run time Representation of various data types Procedure linkage.
D Nagesh Kumar, IIScOptimization Methods: M5L4 1 Dynamic Programming Other Topics.
Computational Methods for Management and Economics Carla Gomes Module 4 Displaying and Solving LP Models on a Spreadsheet.
Week 7 - Programming II Today – more features: – Loop control – Extending if/else – Nesting of loops Debugging tools Textbook chapter 7, pages
CS Reinforcement Learning1 Reinforcement Learning Variation on Supervised Learning Exact target outputs are not given Some variation of reward is.
Every week: Sign in at the door If you are new: Fill in Registration Form Ask a Mentor how to get started Make sure you are on the Athenry Parents/Kids.
JS Arrays, Functions, Events Week 5 INFM 603. Agenda Arrays Functions Event-Driven Programming.
An Introduction to Textual Programming
A revision guide for programming with python. 1.A program is a set of instructions that tells a computer what to do. 2.The role of a programmer is to.
by Chris Brown under Prof. Susan Rodger Duke University June 2012
Computational Stochastic Optimization: Bridging communities October 25, 2012 Warren Powell CASTLE Laboratory Princeton University
DEPRESSION AWARENESS AND SUICIDE PREVENTION Health Science II Mental Health Unit.
ADA: 7. Dynamic Prog.1 Objective o introduce DP, its two hallmarks, and two major programming techniques o look at two examples: the fibonacci.
1 TCSS 143, Autumn 2004 Lecture Notes Recursion Koffman/Wolfgang Ch. 7, pp ,
Model Iteration Iteration means to repeat a process and is sometimes referred to as looping. In ModelBuilder, you can use iteration to cause the entire.
Python. History of python  Python was conceived in the late 1980s and its implementation was started in December 1989 by Guido van Rossum at CWI in the.
23 November Md. Tanvir Al Amin (Presenter) Anupam Bhattacharjee Department of Computer Science and Engineering,
Lecture by: Prof. Pooja Vaishnav.  Language Processor implementations are highly influenced by the kind of storage structure used for program variables.
Decision Trees Binary output – easily extendible to multiple output classes. Takes a set of attributes for a given situation or object and outputs a yes/no.
COSC 2007 Data Structures II Chapter 13 Advanced Implementation of Tables IV.
Variational data assimilation: examination of results obtained by different combinations of numerical algorithms and splitting procedures Zahari Zlatev.
Iteration Hussein Suleman UCT Dept of Computer Science CS115 ~ 2004.
Healthy Animals Curtis is concerned about the
Foraging Psychology Introduction Foraging has been looked at from a functional angle for a long time Optimality models etc Then you have to look.
(c) , University of Washington18a-1 CSC 143 Java Searching and Recursion N&H Chapters 13, 17.
Algorithms and Pseudocode
Today's Ninja Challenge: Write Your First Computer Game!
Computer Program Flow Control structures determine the order of instruction execution: 1. sequential, where instructions are executed in order 2. conditional,
CS 5751 Machine Learning Chapter 13 Reinforcement Learning1 Reinforcement Learning Control learning Control polices that choose optimal actions Q learning.
Memory Management Damian Gordon.
what is computer programming?
Deep Feedforward Networks
Agricultural Economic Students and Faculty!
CS 179 Lecture 17 Options Pricing.
Bryan Burlingame 26 September 2018
Loops CIS 40 – Introduction to Programming in Python
Why do individuals change behaviour?
Introduction In today’s lesson we will look at: why Python?
Multidimensional Scaling
Intrinsically Motivated Collective Motion
PYTHON: BUILDING BLOCKS Sequencing & Selection
Constraint satisfaction problems
Bryan Burlingame 6 March 2019
COMP755 Advanced Operating Systems
Lesson 4: Application to transport distributions
Constraint satisfaction problems
Presentation transcript:

Dynamic Modeling and Python Greg Baker, November 2003

Dynamic Modeling

Assumption: individuals make decisions to maximize reproductive fitness Need fitness of possible decisions. Need fitness of possible decisions. Look at an individual in a certain time window Maximize fitness at the end of time window. Maximize fitness at the end of time window.

Fitness? What determines fitness? Depends on the situation. Depends on the situation. Fat stores? Location? Stress? Not dying. Fat stores? Location? Stress? Not dying. Immediate vs. lifetime reproduction Immediate vs. lifetime reproduction Biology. Biology. Keep track of each factor for the individual. “State variables” “State variables” eg. x = energy, s = stress level eg. x = energy, s = stress level

Discretizing Parameters We can’t handle an infinite number of values for each state variable. We will have to pick a fixed number of values that can be used for each eg. energy, x = 0, 1, 2, 3, …, 30 eg. energy, x = 0, 1, 2, 3, …, 30 time, t = 0, 1, 2, 3, …, 20 time, t = 0, 1, 2, 3, …, 20 Examine every possible combination. Examine every possible combination.

Dynamic array Track fitness values for every combination Will have to be stored as we calculate Will have to be stored as we calculate Fitness: Fitness: t x 012T … … Want t = T values big

Filling in the array Fitness at t = T must be determined initially An approximation of total lifetime fitness. An approximation of total lifetime fitness. Based on values of state variables. Based on values of state variables. Biology. Biology. Calculate backwards from time T to 0 and fill in the table “backwards iteration” “backwards iteration” “dynamic programming” “dynamic programming”

Example t x 012T … … ? Don’t eat Eat

Fitness function Need to calculate fitness for each possible decision … and choose the largest. … and choose the largest. How do we calculate the fitness? Fitness after the decision Fitness after the decision … adjusted by predation risk, energy loss, etc. … adjusted by predation risk, energy loss, etc. Biology. Biology.

Decision Variables To do useful stuff later, also store the decisions themselves Another array like the fitness one. Another array like the fitness one. Lets us look at behaviour, not just fitness. Next week. Next week.

Linear Interpolation We might get a fractional value for some variable eg. After 1 time unit, x goes from 5 to 4.8 eg. After 1 time unit, x goes from 5 to 4.8 No x = 4.8 entry in the array Approximate from surrounding values. Approximate from surrounding values. X 45 f 4.8 f(4.8) ≈ 0.2 f(4) f(5)

Two Dimensional Same idea, but more complicated with two state variables.

Python Programming

First steps Programming Giving instructions to a computer to carry out calculations for you. Giving instructions to a computer to carry out calculations for you. Why Python? Free, widely available Free, widely available Easy to read/learn Easy to read/learn Good free documentation Good free documentation

Python Example 1 Code: for i in range(3): print i print iOutput:012

Python Example 2 Code:x=2 if x<5: if x<5: print "Yes" print "Yes" else: else: print "No" print "No"Output:Yes

Example Model #1 Patch selection from Clark, Mangel Individual has 3 choices each day: Visit feeding patch A (decision 0) Visit feeding patch A (decision 0) Visit feeding patch B (decision 1) Visit feeding patch B (decision 1) Visit reproductive patch (decision 2) Visit reproductive patch (decision 2)Variables: t: time in 1 day increments t: time in 1 day increments x: energy from x: energy from 0-30.

Example Model #2 Seal foraging from Alejandro Variables: t: time in 10s intervals t: time in 10s intervals x: energy from 1-10 x: energy from 1-10 t: oxygen from 1-10 t: oxygen from 1-10 h: habitat (0=haulout, 1=surface, 2=diving) h: habitat (0=haulout, 1=surface, 2=diving)

On to the code…