Ignore:
Timestamp:
Oct 14, 2005, 9:01:24 AM (19 years ago)
Author:
duncan
Message:

draft

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/wiki/least_squares_refactoring.txt

    r1899 r1915  
    77 Software, called least squares, has been developed to implement a
    88penalised least-squares fit and associated interpolations. It is in
    9 least_squares.py.  It is currently not meeting user requirements with
     9least_squares.py.  Steven Roberts outlined the least squares algorithm
     10used. The code is currently not meeting user requirements with
    1011regards to speed and memory use.  Additional functionality is also needed.
    1112
    1213SCOPE
    13 This is looking at refactoring the Class Interpolation
     14This is looking at refactoring the Class Interpolation and the
     15functions fit_to_mesh_file, fit_to_mesh and the command line use of
     16least_squares.py.
    1417
    1518LIFE-CYCLE
     
    1922build_quadtree in quad.py can be worked on after requirements have
    2023been determined.  Also, the current least squares may be tinkered with
    21 to check the feasibility of concepts.
    22 
    23 At this stage how the design will be coded, eg built from the ground
    24 up, cut and past into a new file or changing the current code, has not
    25 been determined.
    26 
     24to check the feasibility of concepts and general maintanance.  The
     25main thrust will be refactoring though.
    2726
    2827
     
    3534INTRODUCTION
    3635
    37 This document specifies the requirements to implement when these
    38 modules are refactored.
    39 
    40 
    41 OVERALL DESCRIPTION
    42 
    43 Steven Roberts outlined the least squares algorithm used. 
    44 
     36This document specifies the requirements to implement least squares
     37is refactored.
    4538
    4639DEFINITIONS
    4740
    48 The least squares algorithm will not be changed. 
    49 
    50 
     41 
    5142REQUIREMENT SECTION
    5243
     
    5950
    6051Requirements
    61 Warn the user when interpolating if points are outside the mesh.
    62      Let the user set the default value that is returned for these points.
     52
     53When interpolating, return information on which points were outside
     54the mesh (in such a way that it can not be interporated as real data).
     55If attribute information for points outside the mesh is returned, that can
     56only be a float, let the user set the default value that is returned
     57for points outside the mesh.
     58
     59When fitting, when in verbose mode display how many triangles are in the
     60mesh and how many are out. Also display the max # of points/ triangle
     61and the minimum number of points.  If this operation takes alot of
     62time, let it be optional.
    6363
    6464Warn the user when fitting to mesh if the mesh is outside the points boundary.
    65  (Note: by using alpha least squares can alway return a result in this
     65 (Note: by using alpha least squares can always return a result in this
    6666 situation)
    6767
    68 X number of points will not cause a memory error.  (Problem is setting
    69 how many)
    70 Reduce the memory use of least_squares.  (This requirement isn't
    71 really testable)
     68Fitting 2 million points to a one million triangles mesh will not cause a
     69memory error.
    7270
    73 Reduce the time spent building matrix A. (ditto)
     71Reduce the time spent building matrix A. (not a testable requirement)
    7472
    75  by using blocking and improving
    76 the architecture. and is implementation focused.)
    77 
    78  
     73(This isn't long, are there any other requirements?)
    7974 
    8075Requirement Notes
     
    8378Other options are, set to a given value.
    8479Raise an error.
    85 Return/set a flag and set to a given value/0.0. (I like this one)
     80Raise/return a warning and set to a given value/0.0. (I like this one)
    8681
    8782
     
    9186General Error Handling Guidelines
    9287
    93 Assume 4 ways of using the code
     88Assume 4 ways of using the code (for Inperpolate class)
    94891) command line interface
    95902) API function - these have parameters of input  data file names,
     
    98934) Internal methods.
    9994
    100 Ways 1 and 2 are used by general users, so they should not return
     95Way 1 is used by general users, so they should not return
    10196something that looks like a code crash from bad input.
    102 Another option for way 2 is to raise an error, which the user handles. 
    103 Discus with  Ole
     97An option for way 2 is to raise an exception, which the user
     98handles. Should the code display a warning, based on the error?
     99
     100Note, if a method is used by a gui, or by scripts change the requirements 
     101Discus with Error Handling Ole
    104102
    105103
     
    107105Least Squares System Design Specification
    108106
    109 By Duncan Gray
     107By Duncan Gray - lots of good ideas by Ole
    110108
    111109
     
    114112This specifies design choices for the least squares code.
    115113
    116 OVERALL ARCHITECTURAL CHANGES
    117 
    118114DESIGN IDEAS, to meet requirements
    119115*To save memory;
    120116When interpolating, don't build AtA, B and D. (This has been implemented)
    121 When fitting, don't build A.
     117When fitting, don't build A. - Work with AtA and Atz.
    122118
    123119
     
    125121
    126122* To save memory
    127 Use blocking when interpolating a large number of points (how large?
    128 Can the program check the available memory and work out a good block
    129 size?)
     123
     124This is for the layer interpolation and fitting with IO: Use blocking
     125when interpolating/fitting a large number of points (how large?  Can the
     126program check the available memory and work out a good block size?)
     127
     128The code has to be refactored so fitting can handling blocked point
     129info.  Need a building phase and a solve phase. 
     130
    130131
    131132*To reduce the time spent building matrix A.
     
    135136has to be there.
    136137
     138Another speed up option is to write the bottlenecks in C. Do it if necessary.
     139
    137140
    138141DESIGN IDEAS, refactoring
     
    141144point co-ords to conform to the mesh co-ords early in the code.
    142145
     146Currently there is one class, called Interpolation, that holds the
     147matrix data and methods for fitting and interpolation.  Break this
     148into two classes, one for fittting, the other for interpolation. Have
     149processes common to both classes in functions.     
    143150
     151Have least squares as two stand alone packages.  One that has the guts
     152of LS (e.g. the two new classes).  One that is has the IO API's
     153(functions that load and write files).  The guts package will be
     154dependent of the general mesh package.  The IO API will rely on an IO
     155module.
     156
     157HOW WILL IMPLEMENTATION OCCUR?
     158Code a new least squares module in a seperate directory.  Heavily cut
     159and paste from the old least squares. Implement memory and time tests
     160on the old least squares (and new LS) before doing any changes. 
Note: See TracChangeset for help on using the changeset viewer.