Nash - Scientific Computing with PCs (523165), страница 39
Текст из файла (страница 39)
Users may always choose the same settings or tolerancesor not make use of special feature of the program. Output may not be set up in a way that allows it tobe easily transferred to reports.If the program has been well designed and documented, suitable modifications and improvements shouldbe easily incorporated. If design or documentation is poor, then we should consider restarting the problemsolution process from the beginning. Can we salvage any of the existing program code? Can we estimatethe costs of rebuilding versus repairing? Such estimates may be very difficult to provide, especially if weare trying to make them for programmers other than ourselves.A common modification of a program is its adaptation to a new system. Here we may change hardware,operating software or programming language dialect.
Generally, this is a difficult task unless theprogrammer has kept portability in mind when designing the program. The difficulties come aboutbecause effective modifications can only be made if one has a very good working knowledge of bothsource and destination systems. In the realm of calculation, we may be further burdened by poordocumentation concerning number representations and floating-point arithmetic or function approximationproperties. The function and sub-program libraries of different compilers and interpreters may differ.
Thisis beyond the usual problems of language syntax changes and I/O and file conventions. Followingprogramming language standards as much as possible will reduce the work of transporting programsbetween computing systems.We have noted a specific difficulty in transferring linear algebraic calculations to C from FORTRAN,PASCAL or BASIC. C generally indexes a 1-dimensional array of n elements from 0 to (n-1) rather thanfrom 1 to n. This makes some algorithms, in particular the Cholesky codes of Chapter 16, more difficultto translate to C than to the other common programming languages.
Conversion software exists thatautomates at least some translation from FORTRAN or PASCAL to C. The translators appear to do a goodjob of the bulk of the conversion, but programmer effort is needed to tidy the resulting code.Because of these difficulties, it is worth considering the use of an application package with compatibleversions on different platforms. For example, Stata and MATLAB use the same files and scripts acrossplatforms, with documented local specializations.Previous Home Next112Copyright © 1984, 1994 J C & M M NashNash Information Services Inc., 1975 Bel Air Drive, Ottawa, ON K2C 0X1 CanadaSCIENTIFIC COMPUTING WITH PCsCopy for:Dr.
Dobb’s JournalChapter 13Problem formulation13.113.213.313.413.513.613.7Importance of correct formulationMathematical versus real-world problemsUsing a standard approachHelp from othersSources of softwareVerifying resultsUsing known techniques on unknown problemsThis chapter is a guide to formulating problems so that they can be solved. We wish to translate acollection of statements or conditions given in words into a matching set of mathematical equations orinequalities.13.1 Importance of Correct FormulationThe goal in formulating problems is the right answer.
If we fail to generate a proper mathematicalstatement of our problem, the chances of getting even approximately correct answers are small. However,what makes up a proper mathematical statement of a real world problem is difficult to define objectively.Like Stephen Leacock’s Mr. Juggins (Leacock, 1945), we can continue to add new details and refinementsand never get close to producing an answer. Equally, in a headlong rush to print out numbers, we canoverlook subtle but crucial features of the problem. Eschewing the extremes, let us consider the middleroad.
Thus, our mathematical formulation should:•Contain the most simple and direct statement, in equations and inequalities, of the key points of thereal problem;•Note any unusual features in the real problem;•Avoid unnecessary detail.This easy to say but more difficult to accomplish, especially when the real or mathematical problems falloutside our regular experience.
When dealing with the unknown or unfamiliar we may add:•Be ready to start again!A good formulation allows the choice of the right tools for its solution. Many real-world problems haveseveral correct mathematical statements as we have seen in the example in Section 12.1. Some formulationsare practically useless for computational purposes, while others lead to calculations of dubious stability.A mathematical formulation leading to a sequence of approximate results by stable methods may be moreuseful than a totally correct set of equations for which solution methods are unstable. By "stable" we meanthat the method does not magnify any errors present in the data input for the problem.
An "unstable"method may find results far from a solution even when given data of adequate accuracy to find a goodapproximation to a solution of the problem.A proper formulation of the problem should allow particular features of the real-world situation to beincorporated. This flexibility allows us to require, for example, that prices remain positive, that a storagebin must not exceed two meters high and one meter wide, or that building temperatures be between 15and 28 degrees Celsius.
However, formulations that are too restrictive may make it difficult to find a13: PROBLEM FORMULATION113satisfactory solution.The conditions that a solution must satisfy help us to categorize the problem and to select appropriatesolution methods. Positivity or negativity conditions on solution values are common. Similarly, we oftenfind upper or lower bounds on quantities.
In some problems, parameters must be integers sinceequipment such as vehicles, railway junctions, cranes, etc., is measured in whole numbers. In othersituations, parameters may have sums or linear combinations that are constrained e.g., the total energyvalue of an animal’s feed must be at least a certain level of calories. We may want to require parametersequences to obey some condition such as monotonicity (always increasing or decreasing): the numberof animals still alive in a drug toxicity test must be non-increasing. Combinatoric constraints, e.g., that astudent pass one course before taking a related one, may also be formulated.Researchers have developed special methods to handle constraints in many common problems. Thesetechniques, such as bounded least squares estimation (Gill and Murray, 1976), have gradually found theirway into the numerical methods literature.
However, situations exist where methods for incorporatingconstraints efficiently remain elusive.It is unfortunate that in many problems, constraint conditions may remain unstated or unrecognized untilthe results of calculations are presented. The consequent adjustments that have to be made in the solutionmethod, algorithm and program can prove inconvenient and time-wasting. We may, however, choose toignore constraints when solving problems. Methods for determining free (unconstrained) parameters aremore commonly available, so that the effort to incorporate conditions explicitly may be uneconomic. Wecan try such methods. However, the conditions on the parameters should still be written down first.
Thetry-it-and-see use of unconstrained methods is then a conscious step in seeking a solution. We get answersquickly and cheaply if they satisfy the conditions imposed.By keeping our initial mathematical statement of the problem simple and direct, we allow relatedmathematical formulations to be explored. A least squares problem may be transformed into an equationsproblem for minima, maxima or saddle points by setting first derivatives of the sum of squares functionto zero. Alternate formulations are useful because they may be easier to solve or provide checks on thechosen method. Comparisons may show that the problem has multiple solutions or is inherently veryunstable."Clients" of any consultant will have their own formulations of problems that are often several stepsremoved from the original, real-world problem. The true problem may not surface until later.