Notes from Kathy's Desk
Guidance, Ruminations, Thoughts, Miscellaneous Points and Suggestions


Welcome. This is a space for us to share with you some of the interesting questions that come across our desks. There are general articles about optimization  Linear Programming, MIP, SLP, recursion  as well as specific tips and best practice suggestions for GRTMPS. I hope there will be something here that will help you make a success of your Successive Linear Programming models and, ocassionally at least, to have a bit of number fun.
11th December 2018  Greetings from Bavaria, where I am sitting in my hotel room listening to the brass band in the restaurant play Christmas music. I will confess to being relieved that it is not yet so wintery to have snow. Last trip of the year (although possibly not the last desk note.). Something for model builders this week  watch out for tiny little numbers!
Kathy
New entries will appear fortnightly or thereabouts. Index to Previous Notes by Topic
Use the feedback form to ask to subscribe to the mailing list if you want to be notified when a note has been posted.
Comments, suggestions gratefully received via the usual email addresses or here.
(Who is Kathy?)
Did you know that very small numbers are bad for the stability of linear optimization? If you see a zero value for some yield or property in a solution, you will usually be right in assuming that it is actually zero, or so small that it has rounded to it in the report. However, just occasionally, sometimes, if you calculate out the value using your input data and the solution activities, you will find that something should be there. It might be very small, but it should not actually be zero. Here are some suggestions for improving the scaling of process unit representations.
Oil refinery and other process industry optimization problems are largely covered by Linear Programming models. Most variables represent continuous quantities, such as the amount of a component to mix into a blend, that are allowed to take on any real number value between a minimum and maximum. However, there are some constraints that are best handled with discrete variables. A model that contains both linear and discrete variables is an example of Mixed Integer Programming (MIP) and is traditionally solved using a Branch and Bound algorithm.
In GRTMPS, nonlinear equations can be connected to the model directly using Adherent Recursion. Below we’ll present a simple way to fit
process unit data into a polynomial function and then use that in a model to drive the linear approximations that are needed for each optimization pass
A ciritical requirement for anyone making blended products like gasoline or diesel is that the properties – such as density, sulphur, octane, cloud point  of the final mixtures are within the legally required specifications. Refinery optimization models obviously need to have equations that represent these constraints.
I travel a lot. My colleagues in Haverly travel a lot. Amongst us we have probably experienced every possible reason for delay that you can imagine. Some distilled wisdom is offered here from our collective experience of air travel and business trips, particularly those dreaded longhaul flights that land you in a different time zone.
Why is the marginal value on the total blend different from the marginal value of the component?
Are you paranoid enough about backing up your work? How many hours would you lose if your computer just wouldn’t boot or if that core document, spreadsheet or database you have just spent a week on was corrupted?
Haverly’s Matrix Analyzer is a very useful tool for combining the matrix structure with the solution values to see how the equations that make up your model are working  all in Excel so you can tinker around with it.
As an example of how it can be used, this note walks through a look at how block operation affects process unit limits.
If you constrained an operating parameter to take a specific value, forcing it away from the optimal value, you would expect to see an incentive on the limit. But what if it always came out blank, no matter what value you fixed it too? What could be going on?
Installing GRTMPS on another computer? You can copy across all your g5 preferences and run history as long as you are installing the same version.

Marginal values – the additional profit to be made if a constraint is relaxed – are one of the benefits of optimizing planning problems with Linear Programming as they can help us understand the economic drivers of the solution. Refinery planning models are normally written with a balance row for each hydrocarbon material being tracked. As equality rows they are always constraining and so we can see a marginal value for each stream – but what exactly do they mean? 
What makes this case different from the base? It worked yesterday, what’s changed? Why don’t we get the same answer? I have previously written about how the GRTMPS compare tool can be used to identify differences between spreadsheets that contain OMNI format input tables. Here's a tool included in MS Office 2016 that can identify the differences betweeen any pair of Excel worbooks, to help you when you have spreadsheets containing other data formats.
This is a linear programming problem written in MPS format. Can you make sense of it?
What makes this case different from the base? It worked yesterday, what’s changed? Why don’t we get the same answer?
When did you last take a good look at your initial pool property estimates? A good first approximation should put your optimization on a good path and save you some recursion passes. Recursion Monitor is a useful tool for checking out your starting qualities; you can compare first to last pass values and check them for internal consistency.
Would you expect the objective function of an integrated refinery model (two or more sites) to normally be lower or higher than the sum of the value of the individual models?
How did I get here? The recursion monitor is a useful tool as it provides an easy way to see what is going on with the recursed parts of your model across each recursion pass. Looking at the final reports only ever shows you where you arrived, not how you got there. Taking a look at what is going on during earlier passes will give you insights into a model’s solution path and help you resolve problems with instability and infeasibilty.
Fancy an infinite amount of money? UNBD as a solution status is offering you just that – but unbounded solutions are not very likely to be prove true out in the real world so they are no better a basis for a plan than an infeasibility
The Matrix is the question and the Solution Print is the answer.
Have you ever tried to track a stream with multiple uses through a solution?
Fancy yourself as a cryptographer? Here's a little code cracking challenge to keep the brain active over the year end holidays.
Its a bit of a waste to make the solution MDB on every run, if you aren't necessarily going to use it, but even more of a bother if you want it and don't have it. Well you can just…..
Many regulatory regimes include product specifications that cover not just individual batches of a particular grade, but also the overall average which is exported from the refinery over multiple grades. These regulations sometimes include incentives for doing even better than the legal requirement – effectively paying you to blend with giveaway. Including such an incentive in your LP model, is easier than you might think.
Does it make any difference if you use a FIX limit or equal MIN and MAX constraints?
Do you have the Haverly Addin activated? Originally for indexing GRTMPS input data spreadsheets, it now has some useful functions for working with your PSI workbooks and for analysing solutions.
When a model doesn’t converge, one possible cause is that some of the adherent recursion PUPs don’t converge. To address this problem, one can use the adherent recursion slope damping to reduce the variations of PUPs between recursions passes to help the model to converge.
Maths boring? Never! Here are some books and movies that illustrate the dramatic (and even comic) potential of a story that revolves around mathematics and computing
This is a guide to the hierarchy of data types in the GRTMPS input database: Model, Case, and Base/Alternate.

A butterfly flaps its wings in the Andes and …. 
Do you ever find yourself grumbling because you got the scaling wrong on a set of numbers, or reversed your positives and negatives? The Multiply and Divide options in Paste Special allow you to sort the problem out with just a few clicks.
If you are working with GRTMPS database models and entering your data via the interface panels the older GRTMPS data table system may be something of a mystery to you. However since the database information is exported into these tables before being processed it can be very helpful to be able to recognize the connections between panels and tables. Debugging tools such as data check, run time messages and file compare all refer to data in the internal tables, so knowing how the names work will make you more efficient. Here is a brief guide.
Every variable and equation in an LP matrix generated via GRTMPS has a unique name built from user assigned codes and internal elements. Understanding them will help in debugging model problems, such as infeasibilities.

It is time for a new computer! What should I get?
We are often asked for computer hardware recommendations to reduce the time required to solve a GRTMPS planning case. Let's answer the hardware question and throw in some additional suggestions that can reduce run times.

If you’ve ever wasted a few hours debugging a broken Excel workbook, then you will be as excited as I was when I learned about Go To Special last year. This does a lot of really interesting things, including finding all the cells in a worksheet with errors in them. 

If you have a model with multiple locations and / or periods, you may want to create limits that control subtotals across all or some of these places and times. If you can buy a stream at 3 locations in 3 periods, how many constraints would you need to cover every possible subset? How do you put them in the model?
Are you using the “spooling” option when you submit runs? It might save you some run time.
Have you ever entered a formula into Excel only to have it treat it as text and just sit there displaying what you typed without resolving it?
When you are setting up the case data for your monthly plan, what price should you use for the crude or other materials that you have already bought? Quite a few people I have asked thought the answer was obvious, but they did not all come up with the same answer.
Distributed Recursion SLP* models require initial estimates for the pool properties that are being optimized and the pool’s distribution factors. By default the pool property values are taken from the blending data and the error distribution is an even division over all the ways the pool can be used. However, you can override these numbers by using a “181 file” as an additional input to the model. Sometimes this helps the optimization converge sooner and may find you a better value.
Sorting your stream list can help you manage your data and make your reports easier to read. In most full database models, this is quite a long list and it can be challenging to use and maintain as it is unlikely to fit on one screen. (Even if you use a tablebased model, you probably have a list of crude streams here – so read on.)
The trend towards larger and larger models works against our desire for fast run times. If you are adding many crudes, periods and / or locations, adjusting the OMNI settings for your GRTMPS model might help speed things up again. It might even be essential to keep it running.
This is an introduction to the fundamental issue that brought recursion into refinery planning models and how this approximation allows us to optimize the qualities of products where some of the components are themselves mixtures of varying qualities.
HOW DO YOU SEARCH FOR "*", "?" and "~" ?
If you are working with GRTMPS data in a spreadsheet  data tables, SSIs, etc.  you probably have some cells that contain asterisks(*) and question marks (?) since GRTMPS uses these as wild cards, replacing them with specific period, location and crude codes when the data is processed. The challenge on doing a Find for a specific entry with one of these characters is that Excel uses them as wild cards in search terms, “?” for any single character and “*” for any group of characters (as does the find in Windows Explorer and many editors).
WHAT DO YOU DO WHEN H/XPRESS FREEZES OVER?
Have you had a run that appears to freeze in the optimize step? It might well have already done some recursion passes, but now it’s just sitting there in the Queue Manager like it is never going to finish.
Have you ever wondered why pool qualities sometimes have marginal values, even when there is no specification?