Wednesday, 20 April 2016

Multidimensional Improvements to the NAG Riemann Solvers

The NAG Library contains routines for solving the partial differential equations specific to compressible, ideal fluid flow. These equations are generally written in conservation law form where the conserved quantities are mass density, momentum and total energy of the fluid.  This set of equations can be solved using a finite volume technique that considers each conserved variable as a volume average over a finite volume (typically a small cube) and sums the fluxes (flow rates per unit area) computed at the faces surrounding the volume to get the total rate of change of a particular variable for that volume.

Several methods exist to solve this set of coupled equations (e.g. Flux Corrected Transport, ENO and WENO schemes, etc.). I focus here on the Godunov method where, in its simplest form, the fluxes are computed by solving a Riemann problem at the interface between two cells in the computational mesh. In such methods, appropriately limited (I do not address limiting procedures here, but see e.g. [Toro, 1999]) states left and right of a cell interface are computed. These states are assumed to be constant, discontinuous states, i.e. a Riemann problem. The Riemann problem does have an exact solution which can be used to finally compute the fluxes at the cell interface. The NAG Library possesses a routine for computing the exact solution and returning the fluxes to the user in one spatial dimension (D03PX). The NAG Library also possesses three other approximate "Riemann Solvers": Roe’s solver (D03PU), Osher’s solver (D03PV), and the HLL solver (D03PW). Descriptions of all these algorithms can be found in [Toro, 1999]. To make these routines more generally useful they should be able to handle the full set of three dimensional equations and this blog discusses the modifications to these routines to accomplish this.

In order to extend the current set of Riemann solvers to two and three dimensions, velocities in two additional spatial dimensions must be added to the set of equations describing the fluid flow. The expression for the total energy is also modified to account for these additional velocities. Each of the Riemann solvers mentioned above were modified to take these velocities into account. Each was plugged into an existing two/three dimensional fluid code that I had written earlier. It uses "Monotonic Upsteam-Centered Scheme Limiting" (MUSCL) [van Leer 1976, Toro, 1999] to compute the left and right states for input into the Riemann solver of choice. The method is formally second order in time and space. It also uses dynamic adaptive mesh refinement using the PARAMESH adaptive mesh package [MacNeice et al., 1999, 2000, Olson, 2006, Olson and MacNeice, 2005]. Since it is a multidimensional code, it requires Riemann solvers that can compute and return fluxes for the momenta in all three spatial directions. Therefore, I have produced modified versions of the Riemann solvers in the NAG Library to do this. The solvers modified are D03PX (exact), D03PU (Roe’s solver), D03PV (Osher’s solver), D03PW (HLL solver). Details of all these solvers can also be found in Toro’s book. In addition to this work, we are currently researching a range of improvements to the PDE functionality offered in the NAG Library and encourage users to discuss their requirements with us.

TESTS

To test my implementations of these Riemann solvers, I have set up and run a test problem. The problem is run in two space dimensions and the domain of the problem is 0 to 40 in the x direction and 0 to 10 in the y direction. The entire domain is initially filled with fluid of density ρ = 1. and given a supersonic velocity of Mach 2.7 in the x direction. Into this flow a circular dense region (a blob) of ρ = 10 and radius 1 is inserted. The boundary conditions are set to produce a constant inflow of Mach 2.7 at the x = 0 boundary and outflow at the x = 40 boundary. Reflecting boundary conditions are set at the y = 0 and y = 10 boundaries. As the simulation proceeds a bow shock forms at the front of the dense blob. The dense blob is compressed and flattened and at later times Raleigh-Taylor and Kelvin-Helmholtz instabilities form at the interface between the dense blob and the supersonic flow. In the figure below, each panel shows a different time in the evolution of the mass density of the blob as it interacts with the supersonic flow surrounding it.










Results using the modified NAG HLL solver are shown in the next set of figures. The results are virtually identical to those from the original code. The rest of the NAG Riemann solvers that I have modified give similar results.








                                                                                                               





REFERENCES

P. MacNeice, K. M. Olson, C. Mobarry, R. de Fainchtein, and C. Packer. Paramesh: A parallel adaptive mesh refinement community toolkit. NASA Tech. Rep. CR-1999- 209483, 1999.

P. MacNeice, K. M. Olson, C. Mobarry, R. de Fainchtein, and C. Packer. Paramesh: A parallel adaptive mesh refinement community toolkit. Comput. Phys. Commun., 126: 330–354, 2000.

K. Olson. Paramesh: A parallel adaptive grid tool. In A. Deane, A. Ecer, G. Brenner, D. Emerson, J. McDonough, J. Periaux, N. Stofuka, and D. Tromeaur-Dervout, editors, ”Parallel Computational Fluid Dynamics, Theory and Applications”. Elsevier, 2006.

K. Olson and P. MacNeice. An overview of the paramesh amr software package and some of its applications. In T. Plewa, T. Linde, and G. V. Weirs, editors, ”Adaptive Mesh Refinement Theory and Applications, Proceedings of the Chicago Workshop on Adaptive Mesh Refinement Methods”, volume 41 of Lecture Notes in Computational Science and Engineering, pages 315–330. Springer, 2005.

E. F. Toro. Riemann Solver and Numerical Methods for Fluid Dynamics, A Practical Introduction. Springer, Berlin, 1999.

B. van Leer, A New Approach to Numerical Gas Dynamics, "Computing in Plasma Physics and Astrophysics", Max-Planck-Institute fur Physik, Garching, Germany, April 1976.









Tuesday, 8 March 2016

Inspiring future talent - International Women's Day

On International Women’s Day we are delighted to publish an interview with NAG Placement Student, Heather Briggs, in which she speaks about her time at school, what led her to her degree choice, and the challenges and highlights she has experienced along the way. 

Heather, can you tell us a little about your school days – which subjects were you drawn to and did you receive encouragement from your teachers to continue with these into higher education?

It started quite early for me, I went to a very small rural primary school with 5 other children in my year. I was 6 months older than the rest of my year so I was moved up quite quickly. After 4 years in the higher year group I was moved down again because the local secondary school wouldn’t accept me early but I was allowed to continue doing maths lessons with the year above until they left the school. So I was definitely inclined towards maths over any other subject from a young age, although at secondary school I enjoyed science as well. I don’t remember any specific encouragement in science but in maths I was invited as a year 10 student to attend a ‘gifted and talented’ day of lectures at Portsmouth University. The top 5 maths students in the year were invited, I remember asking my teacher before accepting whether I was actually in the top 5 or if they just wanted to take a girl. She showed me the year rankings, where I saw that I was third. I didn’t really need extra encouragement to continue with both science and maths, it was obvious to me; they were by far my best subjects. I wasn’t creative; I wanted to understand how things worked. At A level I took Physics (how the universe works), Maths, Economics (how the world works) and Psychology (how the mind works). I didn’t get on with Psychology and dropped it after a year but in the other 3 subjects I had very enthusiastic teachers who made lessons interesting and fun.

Who or what influenced your degree choice?  

I watched a lot of science fiction growing up which heavily influenced my decision to do a Physics degree, I can’t remember ever wanting to study anything else. I wanted to be like Samantha Carter, a Theoretical Astrophysicist in Stargate SG-1. My school held a careers fair when I was in year 9 (age 14) and the University of Surrey had a stand. The course that caught my eye was ‘Space Technology and Planetary Exploration’ which I thought sounded brilliant. I later found out that it was a Postgraduate Masters course but decided I wanted to go to Surrey anyway and would aim for their Physics course instead. One negative experience during my time at school took place at a compulsory appointment with the school’s Career Advisor. I told her about the Surrey course that I intended to apply for and the required entry grades to which she replied “You’ll never get onto that course, you need to aim lower”. I left the appointment in shock and promptly decided that she clearly didn’t know what she was talking about and ignored her advice entirely. Fast forward 3 years to A level results day when I achieved exactly the grades I needed to get into Surrey on the Physics with Nuclear Astrophysics course.

Tell us about your time at University; the challenges and highlights? 

I started at The University of Surrey on an MPhys course, an integrated Masters degree with a research year between the first and second half of your final year. I decided halfway through my first year that research and labs were not for me, and changed to the standard BSc course. At the time of writing this I have only completed 2 years of my degree so I think the biggest challenge I have faced thus far was getting used to the sheer amount of work involved. The majority of my first year I started the week with 4 hours of lab time in the morning and 4 hours of lectures back to back in the afternoon. 9 hours solid on campus with a 1 hour break for lunch left me feeling exhausted and a little disillusioned with the idea of a physics degree. By the second year the hours were a little more evenly spread across the week so it became easier. I think the main highlight was being the first in my circle of friends to get accepted on a work placement. Also finding out I had averaged a first on a certain set of exams when I was sure I was going to have to explain to my tutor why I had done so badly compared to previous results!

Did you have any standout role models during your time at school and University? 

I don’t know about role models as such, but my first science teacher was my Headteacher from primary school. She taught years 5 and 6 science lessons once a week. Having Mrs Dalziell as a specific science teacher at that young age combined with watching Sam save the world using Physics on Stargate, normalised seeing women in science for me. I feel this made it easier for me to ignore the perceptions and continue with the subjects I enjoyed.

When did you begin thinking about your plans post University? 

I first started thinking about what I will do after my degree when my course leader began talking about finding a work placement during my first year. But I didn’t think about it seriously until just after Christmas this year. I am now half way through my placement year, working at the Numerical Algorithms Group in Oxford, and am thinking more about what I will do after my final year. Although at this stage I still don’t really have a firm idea of what I want to do.

How did you decide on a career choice? 

I haven’t yet as I’m only halfway through my undergraduate degree. Physics is not one of those degrees that leads you towards a certain job. Physics graduates have such a wide range of options available to them, which is great. The only thing I do know is that I don’t want to pursue Physics in academia. For now I'm planning a year of further study for a PGCE (teaching qualification) but I haven't made any longer term decisions.

How did you end up at NAG?

At Surrey you are strongly encouraged to try for a placement year, even if you don’t know what you want to do. It can be a great way to help you decide what to do after University, if only to rule something out! I spent a few weeks looking through the placement database looking for interesting sounding computing related placements. For the most part I was left disappointed. I understand that it is difficult to say what a placement student might end up doing in a workplace since they are there for such a short time but most of the job descriptions were so vague they didn’t compel me to apply. Many of them only listed what the company did or the values they were looking for in a student, and didn’t feature anything about what you’d actually be working on for the year.

In comparison, NAG had a detailed description of possible projects you might work on and directed those interested to a page on their website that showed an article written by a previous placement student about her experience working there. I thought it sounded like something I could see myself doing for a year so I applied. One of the great things about the work I am doing is that it involves Fortran, the programming language we are taught as part of the Physics degree.

I only applied for one other placement, and ended up declining their interview as NAG had already offered me the job. 6 months down the line, I believe I made the right choice. There have been a few hiccups along the way due to having to move to a new city (the other placement was based very near Surrey) but it has been worth it, I’m enjoying the job and can’t believe I’m already over halfway through my year here.

Describe your role at NAG? What’s a typical day at work like? 

I am a placement student in the software Implementations team, my role title Software Engineer. My typical day involves running example programs and checking results to test different versions of the NAG Library on different systems.

What can NAG and other technical companies do to encourage more women into technology careers? 

There was an after school computer club I attended briefly while at secondary school, the Computer Club for Girls, here is a direct quote from their website* “Computer Clubs for Girls (CC4G) – a fun way to inspire and motivate 9 to 14 year old girls with, and through, ICT. Featuring girl-centric topics like music, fashion and celebrity, CC4G develops skills through games and challenges.” For starters, organisations should avoid using language such as girl-centric topics like music, fashion and celebrity! To give the organisation some credit they do appear to have rebranded to ‘TechFutureGirls’ since then and changed the content to something less stereotypical.

Maybe companies could advertise to schools what kinds of job roles are available in computing and give practical advice about how to begin coding? In addition to this schools need to broaden their subject offerings, for example the sixth form that I studied at offered ICT but not Computing at A level. The computing assignments are the part of my degree I enjoy the most and are the reason I applied for the placement here at NAG.

I had been interested in coding before university and had looked up online courses like codecademy but if you google ‘What programming language should I learn?’ you get hundreds of conflicting opinions, mainly on personal blogs and it can be overwhelming trying to figure out where to even start. I expect I would’ve taken Computing in place of Psychology had it been on offer when I made my decision on which A levels to take. Hindsight is 20/20 and I’m not sure I knew enough about it at the time to have made that decision.

* http://girlsinict.org/program/computer-clubs-girls-cc4g

If you are interested in a work placement or internship at NAG see our 'Careers at NAG' pages. NAG is committed to creating a diverse workplace. We outlined our commitment in 2015 and continue to push on in this area.
 

Monday, 22 February 2016

Changepoint Analysis using MongoDB and NAG4PY

Recently, I attended the Alan Tayler Day at St. Catherine’s College, Oxford, organised by the Smith Institute. One of the speakers was Dr Rebecca Killick, of Lancaster University, whose talk highlighted her collaboration with NAG that has led to the inclusion of the PELT algorithm into the NAG Library. Dr Killick's collaboration with NAG started in her student days, when she was the runner-up in the "Take Aim" competition, another event run by the Smith Institute and, this year, sponsored by NAG along with Babcock, BT, CATAPULT Satellite Applications, ESPRC, Experian, GCHQ and National Nuclear Laboratory."

The PELT algorithm, of Killick et al, is designed to detect changepoints in an ordered sequence of data, for example, a time series. A changepoint is the location in the series (or time) at which one or more properties of the sequence, such as the mean, changes. A typical example of this is the time at which the average price of a stock changes to a new average value; this is an example that we will consider in more detail later in this post. PELT is an acronym for Pruned Exact Linear Time, where pruned stands for the pruning technique applied to the data to reduce the computation cost. Exact, in this situation, stands for the nature of the search algorithm for the changepoints; it is guaranteed to find the exact minimisation of a cost function used to determine the changepoints. Finally, the algorithm is linear in time, this means that, as long as the number of changepoints grows linearly, the cost of the algorithm is linear O(n), where n is the number of data points. More information about the PELT algorithm can be found in our documentation and Killick et al. (2012).

In an IPython Notebook, which can also be accessed via NAG’s GitHub, I demonstrate how one could calculate the changepoints of a stock price that has been stored in a MongoDB database. Using the example of Volkswagen, I have shown that a changepoint occurred around the time that the news broke about the recent emissions scandal. One should be careful here and note that the reason behind a changepoint is not necessarily obvious and that changepoints may not occur where one intuitively expects them to.


For those of you who are interested, the winners of the latest Take Aim prize were Georg Maierhofer and Rachael Bonnebaigt, University of Cambridge.

Monday, 16 November 2015

Diversity at NAG: Vision for our future and where we are today

A short time ago my colleague, Andrew Jones, VP HPC Business, introduced me to John West, Director of Strategic Initiatives at the Texas Advanced Computing Center (TACC). Andrew found his blog posts "Diversity in HPC won't improve until we start counting" and his follow up “How One HPC Center Learned to Count inspiring and suggested we get involved. We were all equally encouraged by John’s work and it gave us the impetus to get behind his initiative by investigating NAG’s Gender Diversification figures and publishing them at SC15.

 
(we drill down further into NAG’s Gender Diversity figures here)

NAG believes that Diversity among its workforce brings a broader range of ideas and in turn helps us develop more innovative products and services. If our workforce is diverse, just like the population, then we understand market needs better and can offer first class support. Ultimately, promoting and living diversity in the organisation ensures the best possible outcomes for NAG.

Our Diversity figures show that as an organisation, NAG is not where it would like to be, but we are using these to cement our commitment in creating a truly diverse workplace in the future. We continue to work on new initiatives to encourage girls and boys alike to be interested in coding and computing.

There’s a host of Diversity discussions going on at SC15 that we are proud to be part of. Learn more here

 

 

Friday, 6 November 2015

Finding the safe path through the HPC fog

The use of HPC (or supercomputing or big data computing or advanced technical computing or …) delivers real and significant benefits to those organizations that can exploit it effectively. However, the world of HPC technology is a complex space, with a plethora of technology options, continuous rapid change, ambiguous long terms trends, diverse business models, and potential disruptive technologies.

This presents challenges for buyers, managers, programmers and users of HPC facilities:
  • how to find the right technology that will accelerate your modelling, simulation and big data processing needs;
  • determining the best time to adopt new technologies (stability vs. first-mover benefits vs. mature ecosystem vs. migration cost vs. missed performance potential, ...);
  • how to reduce the risks in evaluating potential new technologies;
  • minimize time, effort and cost in finding the important information among the clutter in the HPC market;
  • develop confidence in solutions that will improve cost-effectiveness, business impact, or application performance.
NAG, together with our colleagues at Red Oak Consulting, continually explore and analyze this complex space on behalf of our customers. Our HPC experts:
  • regularly attend a wide range of HPC and other technology conferences around the world.
  • have a broad network of other users of HPC technologies and their real world experiences.
  • keep up to date with the many excellent sources of HPC news and analysis that are available.
  • engage with technology providers, liaise with researchers in academia, national labs and industry.
  • undertake in-house or collaborative mini-research projects and technology evaluations.
Most importantly, because HPC technology consulting is a core business for us, we have the time, effort and expertise to engage with all of these sources and to analyse the information to extract insight from the noise.

We have delivered this insight to our consulting customers for several years, with around 50 successful strategy, technology evaluation or procurement consulting projects.

Today, we are announcing a new service to deliver this impartial intelligence and analysis to HPC buyers, managers, programmers and users. The NAG HPC Technology Intelligence Service in partnership with Red Oak Consulting will deliver technology insight and risk-reduction to help HPC buyers and users make better decisions and optimize their HPC investments. The Service will help you find what you need to know about HPC technology with less time, effort and cost on your part and thus enable better decisions focusing on the important information among the clutter in the HPC market.

The central feature of the Service is our Technology Intelligence Report, issued three times per year to subscribers, with fresh intelligence and insight. Each report will have 3 or 4 focus areas that will be explored in depth, an update on the HPC technology space in general, a wildcard topic, and a community news section. Our launch report has four focus areas: compute, programming, storage, and Total-Cost-of-Ownership models. Each focus area chapter explores a particular theme in depth, covering the main technology options and issues, the short term outlook (what will affect your plans this year/next year), the long term outlook (how the future changes might affect your decisions and planning now), and includes our “what this means for you” summary.

For more information visit www.nag.com/hpc-technology-intelligence.

We also invite you speak to the NAG and Red Oak Consulting team at booth #1619 at SC15 in Austin.

Watch this space in the next few days for extracts from the first report!


Friday, 2 October 2015

Travelling Rugby Fan Problem

The Rugby World Cup is well under way here in England. So far, I have been lucky enough to witness Japan beat South Africa at the Community Stadium in Brighton and next on my list is the nail biting encounter between England and Australia at Twickenham in South West London (Update: Even though it was disappointing to see England loose and go out of the tournament, it was a good day out). All this travelling got me thinking, what would be the fastest circular route to visit all the stadia hosting a Rugby World Cup game if one was lucky enough to have tickets?

The naive approach is to go to Google Maps and choose the best order yourself. However, and this is where the Numerical Algorithms Group comes in, algorithms exist to solve this type of problem. In fact, this is quite a famous problem and is commonly referred to as the Travelling Salesman Problem (TSP). A good introduction to the TSP can be found here.

So what can we use instead? The NAG Library contains a routine, H03BB, which can provide an approximate solution to the symmetric TSP. I was drawn to this routine for several reason: it has recently been added to the Library in Mark 25 and it simulates an interesting physical process called annealing.

Annealing is the process of heating a metal to a certain temperature and then cooling it slowly. The reason for doing this is to remove any stresses that have developed during the original formation. On the molecular scale, energetic atoms are free to rearrange themselves into the lowest energy state. This reduces impurities in the crystalline structure.

Simulated annealing is inspired by the above physical process and attempts to solve the global optimization problem commonly known as the TSP. At higher ‘temperatures’ the solution space is traversed in large jumps. These help identify regions of low energy. Fundamental to the routine is the ability to jump to ‘higher’ energy states, as this allows a greater search of the solution space. Overall, the algorithm favours moving to a state lower in ‘energy’, rather than moving to a closer state with higher ‘energy’. Finally, as the ‘material’ cools, the jumps reduce in size. More information can be found here.

Before we can use the H03BB algorithm, we need some input data. At this point, I remembered that I had seen a similar problem on Reddit. Dr. Randy Olson used a genetic algorithm to solve the TSP. His blog post can be found here. On his blog, he also provided all the necessary code, in Python, to download a matrix of distances between the points from Google Maps using the Google Maps API. Details on how to get this matrix can be found here. He also produced a HTML file that can be used to display the solution on a webpage. That code can be found here.

So, we have an algorithm to solve the TSP, a method of getting the input data and a way of displaying the results. It’s now time to go ahead and solve the problem. The following stadia are hosting at least one game during the Rugby World Cup:

  1. Brighton Community Stadium, Brighton
  2. Elland Road, Leeds
  3. Kingsholm Stadium, Gloucester
  4. Leicester City Stadium, Leicester
  5. Millennium Stadium, Cardiff
  6. Manchester City Stadium, Manchester
  7. Stadium MK, Milton Keynes
  8. Olympic Stadium, London
  9. Sandy Park, Exeter
  10. St James’ Park, Newcastle
  11. Villa Park, Birmingham
  12. Wembley Stadium, London
  13. Twickenham Stadium, London

Using Randy’s code, I was able to get a matrix of journey durations between all the different stadia. This is 13 X 13 symmetric matrix with zeros along the diagonal. I then used the NAG4PY wrappers to call the NAG C Library and solve the TSP and obtain an approximation to the quickest route.

A more detailed version of the above code can be found here.

Finally, using Randy’s HTML file I was able to produce the route below. For this particular route, I decided that cycling would be my preferred mode of transport. As well as visiting all 13 stadiums, the route passes through three national parks, eleven areas of outstanding natural beauty and through London where it passes: Canary Wharf, Queen Elizabeth Olympic Park, The Royal Courts of Justice, Trafalgar Square, The Mall, Buckingham Palace, Hyde Park and Kew Gardens.

The TSP routine is one of many different optimization routines that can be found in the NAG Library. Please feel free to contact us directly or look in our documentation to find out more.

Thursday, 24 September 2015

Life Service Award 2015 – David Sayers

The NAG Life Service Recognition Award has been running for 5 years – it was created in NAG’s 40th year as a way of showing gratitude to people that have dedicated immense time and commitment to the company.

It was a pleasure to see David Sayers, NAG Honorarium, receive the award at our recent AGM. As has become customary, James Davenport, Professor of Information Technology, University of Bath, presented David with the award and said a colleague wrote of David as follows, “David has been an outstanding ambassador for NAG for over forty years. For many customers, he has been the face of NAG - someone that they recognise and relate to, because of his many trips outside the office in the role of sales support. His interactions with NAG collaborators have been many and varied."

A code contributor wrote “David is, I believe, the main reason many of us contributed software to the early library. He came to our meetings, he listened and encouraged us, indeed he was one of us".

Professor James Davenport presenting David Sayers with the NAG Life Service Recognition Award 2015

Friday, 11 September 2015

Introducing the team: Kathy Godwin, Quality Manager and Libraries Project Manager


Kathy, describe your role at NAG?

I am now the Quality Manager and Libraries Project Manager.  

As Quality Manager, I try to keep everyone on their toes by checking 'everything' ... how it was done, why it was done, when it was done, ..., was it done to spec, was it thoroughly and successfully tested/checked, could we have done it any better, ..., is the customer happy, is the Developer happy, is the team happy. I am pleased to say that all at NAG take the quality of the products we produce and the services we provide very seriously.  

As Libraries Project Manager, I am instructed as to the new functionality, enhancements and corrections required for future releases of the NAG Library. In collaboration with NAG Developers, I schedule and manage the work to ensure that it progresses through development, peer-review, quality assurance and on to the Implementations Group so that they have the documentation and code they need for new releases to be made available to customers as soon as possible. 

Can you give examples of the customer problems you help solve via NAG Technical Support?

I don't work directly on NAG Technical Support, but I do monitor the progress of Technical Support queries to ensure that they are answered in a timely manner, that enough information is provided and that the customer has been provided with an answer. If they are not then I check that there has been a follow-up action to any short fall in our performance and that a satisfactory solution is provided.

Tell us something special/unusual about NAG?

I have worked at NAG almost continuously since 1979, experiencing many management styles. Our current style of management is the most open, honest, trusting and flexible that I have experienced. It makes for a truly relaxed, but inspiring place to work. So much more is achieved because we have the opportunity to work to our full potential. The people at NAG all contribute to a friendly and pleasant place to be.

Why have you worked at NAG so long?

I first started work at NAG as Mark 6 of the Library was due to go out. I spent the first year or so keying every single routine document, Chapter Introduction and Introductory document for our first automatically generated release of the Fortran Library. I have been involved in every Mark since, helping to develop the NAG style, introducing standards and consistency, and helping improve efficiency of production. Using TSSD, TeX, SGML and now XSLT and XML has made working at NAG varied and interesting. The Library is like an old friend and we have grown up together.

Developers have come and gone and each have had their own unique personality - they have been fun and interesting to get to know. They have all made important contributions to the Library and should be proud of that.

There are many benefits to working at NAG, on top of those I have already mentioned, so I have never 'really' wanted to leave.
 
Tell us something special/unusual about yourself?

I don't think that there is anything special or unusual about myself - I tend to do everything to extremes and I'll give anything a go. As long as I can see improvement or some advantage and, I guess, receive some positive feedback, I'll keep going ... which is probably another reason for still being here. I just like to get things done.

Thursday, 9 July 2015

NAG Linear Regression on Apache Spark

This is a brief summary of a talk I gave recently at the Chicago Apache Spark Users Group Meetup. During the talk, I present many of the problems and successes when using the NAG Library distributed on Apache Spark worker nodes. You can find the slides available here.

The Linear Regression Problem


In this post we test the scalability and performance of using NAG Library for Java to solve a large-scale multi-linear regression problem on Spark. The example data ranges from 2 gigabytes up to 64 gigabytes in the form of

label x1 x2 x3 x4
68050.9 42.3 12.1 2.32 1
87565 47.3 19.5 7.19 2
65151.5 47.3 7.4 1.68 0
78564.1 53.2 11.4 1.74 1
56556.7 34.9 10.7 6.84 0

We solve this problem using the normal equations. This method allows us to map the sum-of-squares matrix computation across worker nodes. The reduce phase of Spark aggregates two of these matrices together. In the final step, a NAG linear regression routine is called on the master node to calculate the regression coefficients. All of this happens in one pass over the data - no iterative methods needed!

Example output from the linear regression is the following:

Time taken for NAG analysis: 236.964 seconds
Number of Independent Variables: 5
Total Number of Points: 334800000
R-Squared = 0.699
Var Coef SE t-value
Intcp 12723.3 2.2 5783.3
0 989.7 0.02 47392.5
1 503.4 0.04 11866.5
2 491.1 0.1 4911.9
3 7859.1 0.9 8732.3

*************************************************
Predicting 4 points
Prediction: 57634.9 Actual: 60293.6
Prediction: 32746.6 Actual: 35155.5
Prediction: 49917.5 Actual: 52085.3
Prediction: 82413.2 Actual: 82900.3

Timings


Using the above method, the NAG linear regression algorithm is able to compute the exact values for the regression coefficients, t-values, and errors. Below is a log-log plot of the Runtimes vs. Size of Input data for the NAG routines on an 8 slave Amazon EC2 cluster.





Not only is it important the NAG routines run fast, but that they scale efficiently as you increase the number of worker nodes. Let's look at how the 16 GB data set scales as we vary the number of slaves.







Comparison To MLlib


We tried running the MLlib Linear Regression algorithm on the same data, but were unable to get meaningful results. The MLlib algorithm using the stochastic gradient descent to find the optimal coefficients, but the last stochastic steps always seemed to return NaNs (we would be happy to share sample data ...let us know if you can solve the problem!).

More Information


For more information including examples of the NAG Library on Spark, contact us at support(at)nag.com

Thursday, 25 June 2015

Helping primary school children achieve the best in their SATs

My wife Caroline is a teacher in a primary school near where we live in Buckinghamshire. She teaches year 6, that is to say, ten to eleven year old children.

Now, year 6 is a rather important year in British schools. Children following the National Curriculum in state-funded schools are subject to SATs (standard assessment tests) before they move on to secondary school, and the results of these tests are used to create the dreaded league tables which are supposed to help parents make an informed choice about which school to send their children to. Importantly, the number of pupils can affect the amount of funding a school gets.

Year 6 teachers are therefore under a lot of pressure to help their pupils achieve good SATs results, so extra sessions and booster groups are common. This year Caroline asked if I could go into school to spend a few hours with her top maths set - ones that it had been decided were good enough to be entered for the harder (Level 6) papers.

I'm used to teaching adults on NAG training courses, but this was the first time I'd been into a primary school to teach. It turned out to be good fun! I had four students, all of whom had already passed their "eleven plus" and would be going to grammar school. Topics we covered included straight line graphs, probability and algebra. The kids were enthusiastic, and not too shy. Many of the problems tackled turned out to involve rearrangement of equations, so drilling into them that if you do the same thing to both sides of an equation (with some caveats of course) then the equality still holds seemed quite important.

Whether the short time I spent with them actually made any difference is hard to know, but I really enjoyed the interaction and the children seemed to also. The SATs results are not yet out, and scoring a Level 6 in Mathematics or English is quite difficult (the average 11 year old is expected to achieve Level 4) - so there will be no dishonour in not achieving it, but I'm looking forward to hearing how they get on. And I'm hoping that next year, as part of NAG's Community Outreach Programme, I'll be able to go into school again, and maybe for more hours this time around.

Thursday, 18 June 2015

Wilkinson Prize for Numerical Software 2015

by Mike Dewar, Chief Technical Officer, Numerical Algorithms Group (NAG)


James Hardy Wilkinson
NAG, along with Argonne National Laboratory and the National Physical Laboratory (NPL), awards the Wilkinson Prize every four years to the authors of an outstanding piece of numerical software. The prize honours the pioneering work of Dr James Hardy Wilkinson in the field of numerical algorithms, work which had a fundamental impact on NAG in our early years and which still resonates today. The Wilkinson Prize is unique in that it is awarded on the basis of the quality of a piece of software, not just for the mathematics behind it, and the judges consider the documentation and test suites as well as the software itself.  

This year the winners are P.E. Farrell (University of Oxford), S.W. Funke (Simula Research Laboratory), D.A. Ham (Imperial College London), and M.E. Rognes (Simula Research laboratory) for the development of dolfin-adjoint, a package which automatically derives and solves adjoint and tangent linear equations from high-level mathematical specifications of finite element discretisations of partial differential equations. The prize will be presented at ICIAM in Beijing in August, during the SIAM Awards Lunch. 


More details about the Wilkinson Prize and past winners can be found here.