The Genetic Algorithm (GA) is an advanced optimisation method based on a simulation of the process of evolution. Although slow, GAs are excellent for solving problems with large numbers of dimensions and constraints. The surface fitting problem falls into this category, as it is not sufficient to simply create a surface that is a close fit to the data points provided, it is also desirable that the surface be fair and that the control point net be smooth and regular.
Genetic Algorithms start by creating a population of individuals with a small amount of random variation. In the case of surface fitting, a population of usually 25 to 50 surfaces is created based on an initial example surface. Each individual in the population is made unique by randomly moving one or more control points a small distance.
Once the initial population has been created the system simulates evolution by repeating the following steps until a solution is found that meets the fitting criteria sufficiently well.
Measure the fit of each individual surface to the data points and give it a score based on its quality of fit, fairness and net regularity. Rank all the individuals from best to worst.
Repeatedly choose two individuals as parents, with individuals being chosen in proportion to how highly they were ranked in step 1. This means that the most successful individuals produce the most offspring in the next generation.
Create members for the next generation by choosing some surface control points from one parent and the remainder from the other parent. Occasionally include a small amount of random control point movement to provide some mutation from generation to generation.
The result is a population that progressively gets closer to an ideal solution of the problem, with poor solutions being eliminated. The highest ranked individual in the final generation is the best solution.
Prefit is already capable of quickly fitting a simple surface to a table of offsets, however it has several disadvantages:
· Ordered data points.
Prefit requires that data points be ordered in consecutive columns from the stern to the bow. Points within each column should be in the correct order.
· Density of data points.
Prefit has problems if the data points are unevenly distributed over the surface.
· Poor net of control points.
The resulting net of control points from the Prefit fitting process is often not suitable for modification in normal design work. Columns and rows may be skewed and be irregular in their layout.
· Poor fairness.
Even when the Prefit surface fits the data closely, it is possible for it to contain significant unfairness.
Although much slower, the Genetic Algorithm fitting method has several advantages over Prefit.
· Data may be unordered.
It is not necessary to organise data into rows or columns, nor is it necessary for points to be sorted into a particular order. The GA fitting method can handle randomly ordered data with no problems.
· Data may be of varying density
It is possible to have more points concentrated in areas of greater curvature or detail.
· Regular and smooth net
Resulting control point net tends to be regular and smooth with even spacing of rows and columns that tend to be orthogonal to one another.
· Fair and close fit
The resulting surface tends to be fair as well as fitting the data points closely.
Before executing the fitting function it is necessary to set up the markers and create an initial surface. Fortunately, the conditions that the set of marker points have to meet are much less restrictive than those required by Prefit.
It is important to have a reasonable number of data points defining the edges of the surface. If there is a discontinuity in an edge it is better to create some extra data points to form a fair edge and model the discontinuity using trimmed surfaces at a later time.
There is no limit to the number of data points you can use, however the more points you use the longer it will take to find a solution. It is unlikely that using a very large number of points will improve the overall quality of fit, so it may be worth pruning down the original table of offsets data if there is more than about 100 points.
When Maxsurf first scans the data points for fitting it automatically finds the edges of the implied surface. If you do a brief fit, say one generation, and then exit the dialog you will see that the edge points are coloured red while the interior points are coloured blue. If you see an interior point that is coloured red it means that Maxsurf has had difficulty with that point probably because it is nearly a duplicate of another point.
Duplicate points are automatically handled by the fitting process; however points that are simply very close together can cause a problem. It is not so easy for Maxsurf to detect and ignore these. If you see an interior point coloured red, it is usually best to delete that point and continue.
It is also necessary to set up an initial surface for the fitting process. This should have what you think will be the right number of rows and columns as well as having transverse and longitudinal stiffness set appropriately. The surface should have its rows and columns spaced evenly and the corners of the surface placed close to their final positions.
The Genetic Algorithm will use the initial surface as a starting point, so the closer it is to its final configuration the better. It is not essential to get it near to the data points as long as the overall layout of the net is regular.
If you are able to set the corner control points to exactly the right location, or if you are able to manually fit the edges of the surface to your satisfaction, these can be locked during the fitting process with a resultant speeding up of the calculations.
Please note that the Markers - Fit Surface to Markers command is only available if you own a licensed copy of Prefit (see below).
Once the markers and the initial surface have been created it is time to fit a new surface. Selecting the Fit Surface To Markers Command from the Markers Menu brings up the following dialog box.

As a first step it is necessary to specify which surface you want fitted to the available markers. If your design only has one surface than no options will be shown in the Surface pull down menu, however if your design already has more than one surface you will be able to choose between them.
If the corners of the selected surface are always assumed to be in their correct locations and Maxsurf will not move them during the fitting procedure. You can use the Snap Control Point to Marker function in the Markers menu to help you fit the corners.
If you do not wish Maxsurf to attempt to fit the surface edges, select Lock Edges. You would do this if you were happy that the surface is already adequately fitted to the edges of the data points. You can use the Fit Edge to Markers function in the Markers menu to help you fit the edges.
The two remaining options constrain the surface so that bottom concave and tumblehome at the hull side are not permitted. If you know that your design contains these features then one or both of these boxes should be unchecked.
Once you have specified these options it is simply necessary to click on the Fit button. Once Maxsurf has fitted the surface it will add values to the RMS Error Achieved and Generations Tested fields.
The RMS error value is the Root Mean Square error. This is the square root of the sum of the squares of all of the errors between every data point and the fitted surface. It is a good measure of overall fit, but it should be regarded as an average error rather than a worst error value.
Once you have clicked the Finish button you will be returned to the Maxsurf viewing windows where you will see the new fitted surface.
If the fitted surface has undesirable features, or if you think it can be improved by changing the control point layout, it is possible to modify it and use it as the starting point for further fitting.
Modify the fitted surface to correct any problems that you have detected, and then choose Fit Surface to Markers again. The modified fitted surface will be used as the initial surface for any further fitting, and the Genetic Algorithm will attempt to incorporate your changes into the design.
Once the fitting process has started and the initialisation has been completed, you may exit the fit before the specified time has elapsed by clicking on the Cancel button or hitting the Escape key. Note that the response to this may be a little slow. This is because Maxsurf must finish the current optimisation cycle before exiting. After exiting, you will have the current best-fit surface. If required you can re-start the fitting progress, or close the fitting dialog.
Please note that the Markers - Fit Surface to Markers command is only available if you own a licensed copy of Prefit.
If you own Prefit, you will probably want to enable the Fit Surface to Markers command in Maxsurf. Do this by starting Maxsurf and selecting Activate Prefit from the Edit menu.
Now exit and restart Maxsurf. If you have a valid access code for Prefit, Maxsurf will start automatically and the Fit Surface to Markers command will be available in the Markers menu. If the current access code is not valid, you will be prompted for a new one.
Type in your access code, and click OK. If the correct access code was entered, the Fit Surface to Markers command will be available in the Markers menu.
If for any reason you wish to turn off the Fit Surface to Markers command, select Deactivate Prefit from the Edit menu. Note that you will have to exit and restart Maxsurf for this to take effect. The most likely time you might want to do this is if you are on a network, using a network copy protection device, and need to release a Prefit licence so that another person may use it.
It is also useful to use the Generate Grid from Markers command to set up the grid (stations, buttocks and waterlines) for the surface you have just created from the marker point data. Stations are generated at the markers’ longitudinal position; buttocks at their transverse offset; and waterlines at their vertical location:

You have the option of selecting which items of the grid to generate (stations, buttocks and waterlines). For each of these you have the option of deleting and replacing the existing grid data or adding to the existing grid data. You can also specify how many markers must be at the same longitudinal position, transverse offset or vertical location for a station, buttock or waterline (respectively) to be added. Finally, you can specify a tolerance for markers to be considered at the same plane: for example if the Marker plane separation tolerance were set to 0.001mm then markers up to 1mm apart (in longitudinal position, transverse offset or vertical location) would be considered to be in the same plane and the station, buttock or waterline location would be averaged.
When Importing DXF Markers or GHS markers, Maxsurf can automatically generate the grid. The section grid is generated automatically only if no existing sections are defined. If sections are already defined then imported markers that lie within 1cm of a section will be allocated to that section, otherwise they will be left unallocated.