• Stars
    star
    115
  • Rank 304,100 (Top 7 %)
  • Language
    TeX
  • License
    MIT License
  • Created almost 6 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Applied mathematics problems with Open Source Software: Operational Research with Python and R.

ampwoss

Applied mathematics problems with Open Source Software: Operational Research with Python and R.

Back Cover

Applied Mathematics with Open-Source Software: Operational Research Problems with Python and R is aimed at a broad segment of readers who wish to learn how to use open-source software to solve problems in applied mathematics. The book has an innovative structure with 4 sections of two chapters covering a large range of applied mathematical techniques: probabilistic modelling, dynamical systems, emergent behaviour and optimisation. The pairs of chapters in each section demonstrate different families of solution approaches. Each chapter starts with a problem, gives an overview of the relevant theory, shows a solution approach in R and in Python, and finally gives wider context by including a number of published references. This structure will allow for maximum accessibility, with minimal prerequisites in mathematics or programming as well as giving the right opportunities for a reader wanting to delve deeper in to a particular topic.

Features

  • An excellent resource for scholars of applied mathematics and operational research, and indeed any academics who want to learn how to use open-source software.
  • Offers more general and accessible treatment of the subject than other texts, both in terms of programming language but also in terms of the subjects considered.
  • The R and Python sections purposefully mirror each other so that a reader can read only the section that interests them.
  • An accompanying open source repository with source files and further examples.

List of chapters

Chapter 1: Introduction

This chapter aims to help a reader understand if this book is for them and what background they need to use it. It starts by answering the following questions:

  • Who is this book for?
  • What is meant by applied mathematics?
  • What is open source software?

The chapter structure of the book is then discussed, apart from the 1st chapter all chapters have a similar structure and then some discussion is given to how the code is written and presented.

This chapter can be skipped if a reader is confident in their use of programming and wants to skip ahead to a specific problem.

Chapter 2: Markov chains

This chapter models a barber shop as a queueing system using a continuous time Markov chain. The goal is to identify which particular reconfiguration of the barber shop would be most beneficial to customers.

A theoretic overview of concepts related to stationary distributions of continuous Markov chains is given before solutions approaches are given in both R and Python. This is done using Numpy in Python and expm in R for all the underlying linear algebra.

Chapter 3: Discrete event simulation

This chapter models a bicycle repair shop as a network of two queueing processes. The goal is to identify the effect of two particular improvements to the service configuration.

A theoretic overview of two types of discrete event simulation frameworks is given: event scheduling and process based simulation. As well as this the topics of random processes and pseudorandom number generation are also covered.

The two types of simulation frameworks are addressed in the solution approaches: in Python Ciw is used which is an implementation of event scheduling. In R simmer is used which is an implementation of process based simulation. As a result, perhaps this chapter more than any other is worthwhile reading both the R and Python section (even if the reader is only a user of one language) as this gives a good contrast to the two frameworks.

Chapter 4: Differential equations

This chapter models the spread of a cold in a population as a single dimensional problem. The goal is to identify whether or not an investment in cold medicine should be made to offset a loss of productivity.

A theoretic overview of what a differential equation is and what a solution of a differential equation represents is given.

The solution offered in Python is done symbolically using the Sympy library whereas the solution offered in R is done through numerical integration using deSolve.

Chapter 5: System dynamics

This chapter models the spread of an infectious disease within a population as a compartmental model. The goal is to understand what interventions could be made to help minimise the long term effects of the disease.

A theoretic overview of systems of ordinary differential equations is presented in terms of stocks and flows. The specific model used here: an SIR model is discussed in detail. This is all complemented with a brief discussion of some numerical techniques used to integrate systems of ordinary differential equations.

The solution offered in Python makes use of Numpy and Scipy which is equivalent to the solution offered in R which makes use of deSolve.

Chapter 6: Game theory

This chapters models a policy decision that has implications on the actions of two companies in a duopoly modelled as a normal form game. The goal is to understand what financial incentives can be put in place to ensure competition between the companies that benefits the consumer.

A theoretic overview of the definition of normal form games and Nash equilibria is given.

The solution offered in Python makes use of Nashpy which is a specific library for the computation of Nash equilibria. The solution offered in R makes use of Recon which is a general purpose library with functionality for a few topics in economics.

Chapter 7: Agent Based Simulation

This chapters models a population of association football fans as a classic agent based model of segregation. The goal is to understand how the individual preferences of the population members affects the overall observed behaviour at the population level.

A theoretic overview of agent based modelling is given specifically concentrating on the roles of agents and the environment.

In Python the fully object oriented nature of the language is used to model agents and the environment as classes. The R solution makes use of the R6 library which allows for a similar implementation of classes with required functionality.

Chapter 8: Linear Programming

This chapter finds an exam schedule for a scenario where there are students that have a number of possible clashes. This is done by formulating and solving a linear programming problem.

A theoretic description of linear programming is given. Intuitive ideas that lead to solutions approaches are described. Direct and linear algebraic formulations are explained.

The Python solution makes use of the Pulp library which corresponds to the direct formulation of the problem. The R solution uses the ROI library which requires the linear algebraic formulation.

Chapter 9: Heuristics

This chapter identifies the best delivery route for a delivery company. This is a traditional travelling salesman problem which aims to find a route that minimises the total distance travelled.

A theoretic description of neighbourhood search and a specific consideration of the "2-opt" algorithm are given. These are types of heuristic algorithms which may not guarantee optimality but can often perform better in practice than exact approaches.

The standard Python library and base R are used to build these algorithms.

Biographies

Geraint Palmer is a Welsh Medium Lecturer at Cardiff University in the School of Mathematics. He is a member of the operational research group where his research interests are in simulation and probabilistic modelling, in particular applying these to model public services such as healthcare systems. He uses open source software in all aspects of his research: he is a maintainer of Ciw, an open source Python library for discrete event simulation, and won the OR Society's Doctoral Award in 2018. Geraint is also a fellow of the Software Sustainability Institute and has presented at a number of international conferences on the subject of best practice of scientific computing, and regularly teaches programming and runs coding workshops for people of all ages.

Vince Knight is a Senior Lecturer at Cardiff University in the School of Mathematics. His research interests are in emergent behaviour, probabilistic modelling, applications in healthcare and pedagogy. He maintains a number of open source research software projects, is a trustee of the UK Python association, is an editor for the Journal of Open Source Software, was awarded the 2017 John Pinner award for contribution to the Python community and is a fellow of the Sustainable Software Institute. He regularly wins awards for his teaching in the School of Mathematics. He does not only speak at conferences around the world but continues to organise conferences to bring the power of open source software to as many people as possible.

Source fils

Create the Conda environment:

Assuming you have anaconda on your machine, run:

$ conda env create -f environment.yml

There are some further dependencies that are needed.

Activate the environment:

$ conda activate ampwoss
$ inv env

To delete the environment:

$ inv delenv

Compilation instructions

Run:

$ inv compile

This creates a build/ directory which contains slightly modified source files (some annotations removed) as well as a main.pdf. This modifications are prescribed by a substitions variables in tasks.py.

An intermediate step is to run:

$ inv build

Which creates the modified source files but does not compile the document.

Note that as documented in #72 the texlive-langgreek latex package might be needed.

Doctesting

Run:

$ inv doctest

To doctest a specific chapter:

$ inv doctest --path="src/chapters/06/main.tex"

To also check the style with black on the python code and lintr on the R code:

$ inv doctest --style

Analysing the document

Run:

$ inv analyse

This analyses the tex documents with style and diction:

  • style: analyses surface characteristics of a document, including sentence length and other readability measures.
  • diction: identifies wordy and commonly misused phrases.

See http://wiki.christophchamp.com/index.php?title=Style_and_Diction#Lix for more information.

To install these packages:

Debian:

    apt install diction
    apt install style

OS X (with the brew package manager):

    brew install diction
    brew install style

More Repositories

1

Nashpy

A python library for 2 player games.
Python
279
star
2

Python-Mathematics-Handbook

A set of notebooks for an introduction to Python for Mathematicians.
Jupyter Notebook
166
star
3

Simulating_Queues

This is some old legacy code: you should use ciw: https://github.com/ciwpython/ciw
Python
41
star
4

gt

Source files for my course on Game Theory.
Jupyter Notebook
30
star
5

Gamepy

PLEASE DO NOT USE THIS REPOSITORY - IT IS OUTDATED AND NOT VERY GOOD
HTML
23
star
6

Year_3_game_theory_course

This repository contains source code for a game theory course.
TeX
17
star
7

EdinburghFringeJokes

A repo for a blog post looking at the Edinburgh Fringe Festival jokes
17
star
8

md2reveal

A script to easily convert (simple) markdown to reveal html.
Python
16
star
9

Monte_Carlo_Simulation_for_Estimating_pi

Repo for a script to make rain drops in a field so as to estimate pi.
Python
13
star
10

pfm

Python for Mathematics: A book aimed at undergraduate mathematicians learning python
Jupyter Notebook
11
star
11

cfm

Repository for a Python course for university Mathematics students
Jupyter Notebook
9
star
12

DataScienceingDogRates

A repo with some code to analyse dog rates
Jupyter Notebook
8
star
13

ertai

Mathematical modelling of Magic the Gathering
Python
7
star
14

sklDj

A django app as an interface to scikit-learn
Python
7
star
15

Assigning_Fair_Individual_Marks_To_Group_Projects

Repo for the assignment of marks using Cooperative game theory.
CSS
7
star
16

unpeudemath

Repository for my blog
Jupyter Notebook
7
star
17

oop

A jupyter notebook for the teaching of basic Python and OOP
Jupyter Notebook
5
star
18

ghtalks

Organise and share your slide decks
Python
5
star
19

TestingPaper

Jupyter Notebook
4
star
20

pandocipy

Create pdf, html and docx versions of all md files in a directory
Python
4
star
21

agent-based-learn

A library for agent based learning of normal form games
Python
3
star
22

dwys

Language agnostic doctester
Python
2
star
23

video-editing-process

How I prepare teaching videos
2
star
24

dotfiles

A repo with my dotfiles
Shell
2
star
25

Shut_The_Box

Repo with code relevant to the Shut The Box Parlour game
Python
2
star
26

LaTeX_Course

Source files for an intro to LaTeX course
2
star
27

two_thirds_of_the_average_game

A repo with some material to help run a two thirds of the average game.
Python
2
star
28

drvinceknight.github.com

Html code for my site
HTML
2
star
29

blog

A blog about programming (usually scientific python), mathematics (usually game theory) and learning (usually student centred pedagogic approaches).
Jupyter Notebook
2
star
30

Intro_to_Object_Orientated_Programming_With_Python

This repository contains the source files for a 1 day introduction to object orientated programming course which is taught using Python.
CSS
2
star
31

Markov_Chains

This contains sources files for my Markov Chain notes.
Python
2
star
32

LaTeXFilesWordCount

Script to recursively word count all tex files in all subdirectories.
Python
2
star
33

coord_coop

A library to replicate the coordinated cooperation game presented in https://www.frontiersin.org/articles/10.3389/fevo.2018.00062/full
Python
2
star
34

list-of-dev-things

A repository containing lists of concepts, tutorials etc to be able to do development: aimed at beginners.
2
star
35

sal

Generate the transition matrix for snakes 🐍 and ladders
Python
1
star
36

Admissions_Talk

Slides for a talk on my work in queueing theory and game theory. The target audience are potential mathematics graduates.
1
star
37

SSI-fellowship-application

1
star
38

pupcoach

Python
1
star
39

Chapter_7_of_Comp_Sci_Illuminated

Some code I've scribbled down from the pseudo code in CH7 of "Computer Science Illuminated" by Dale and Lewis
Python
1
star
40

Partial_Sum_Transportation_Polytope

A repo for some code for a long overdue paper.
Python
1
star
41

Comparing_recursion_and_iteration

A repo with some code used to compare timing of recursion and iteration
Python
1
star
42

Playing-games-a-case-study-in-active-learning

A paper for https://journals.gre.ac.uk/index.php/msor/about
TeX
1
star
43

pop

Python
1
star
44

CU_BSc_LaTeX_Template

Jupyter Notebook
1
star
45

speak

A repository for my talks
HTML
1
star
46

MathEdWorkshop

A repo for some content for a workshop organised by Prof. Harper and myself.
TeX
1
star
47

MAT013

Code for a SAS/R course.
CSS
1
star
48

MSc_week_0

Introductory refresher session for the MSc course
TeX
1
star
49

Dissertation

OR and Stats MSc Thesis 2015-2016
TeX
1
star
50

SimulatingQueuesInSage

A repo to experiment with simulation of queues in Sage (mainly to make use of @parallel tag)
Python
1
star
51

AnIncompleteOverviewOfSomeApplicationsOfGameTheoryToPatientFlow

A repository for a paper for SBP XLVI
TeX
1
star
52

testing_for_ZD

Recognising zero determinant strategies: code for a paper under review (pre print: https://arxiv.org/abs/1904.00973).
Jupyter Notebook
1
star
53

hphp

A research paper on intergenerational trauma
Jupyter Notebook
1
star
54

HeterogeneousAmbulanceFleetAllocations

Code for optimising ambulance allocation
Jupyter Notebook
1
star