Changeset 568


Ignore:
Timestamp:
10/09/09 12:52:11 (5 years ago)
Author:
srkline
Message:

Corrected the setting of limits for all parameters when setting up genetic optimization

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Analysis/Packages/GeneticOptimization/NCNR_GenFitUtils.ipf

    r499 r568  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2 
     3// genetic optimization, uses XOP supplied by Andy Nelson, ANSTO 
     4// http://www.igorexchange.com/project/gencurvefit 
     5 
    26 
    37 
     
    1418// X add a check to make sure that the XOP is installed before the switch is set (force 0 if not present) 
    1519// X add a global variable as a switch 
    16 // - parse the limits. All must be filled in. Currently unfilled slots are val/10 < val < 10*val, bad choice 
    17 //   if coef is zero, or too far from the true value 
     20// X parse the limits. All must be filled in. If not, fit aborts and asks for user input to fill them in. Limits 
     21//   on fixed parameters are +/- 1% of the value. Has no effect on fit (duh), but filled in for completeness. 
    1822// X create a mask wave for use when cursors are selected. [a,b] subranges can't be used w/Andy's XOP 
    1923// X fitYw not behaving correctly - probably need to hand-trim 
     
    2529// X odd bug where first "fit" fails on AppendToGraph as GenCurveFit is started. May need to disable /D flag 
    2630// 
     31// -- need to pass back the chi-squared and number of points. "V_" globals don't appear 
    2732// 
    2833// for the speed test. try writing my own wrapper for an unsmeared calculation, and see if it's still dog-slow. 
     
    176181        //need to parse limits, or make up some defaults 
    177182        // limits is (n,2) 
    178         Variable nPnts = numpnts(fs.coefW),i,multip=10,isUSANS=0,tol=0.01 
     183        Variable nPnts = numpnts(fs.coefW),i,multip=1.01,isUSANS=0,tol=0.01 
    179184        Make/O/D/N=(nPnts,2) limits 
    180185        Wave limits=limits 
    181186        for (i=0; i < nPnts; i += 1) 
     187         
    182188                if (strlen(lolim[i]) > 0) 
    183189                        limits[i][0] = str2num(lolim[i]) 
    184                 else     
    185                         limits[i][0] = fs.coefW[i]/multip 
    186                 endif 
     190                else 
     191                        if(cmpstr(holdStr[i],"0")==0)           //no limit, not held 
     192                                Abort "You must enter low and high coefficient limits for all free parameters" 
     193                        else 
     194                                limits[i][0] = fs.coefW[i]/multip               //fixed parameter, just stick something in 
     195                        endif 
     196                endif 
     197                 
    187198                if (strlen(hilim[i]) > 0) 
    188199                        limits[i][1] = str2num(hilim[i]) 
    189                 else     
    190                         limits[i][1] = fs.coefW[i] * multip 
     200                else 
     201                        if(cmpstr(holdStr[i],"0")==0)           //no limit, not held 
     202                                Abort "You must enter low and high coefficient limits for all free parameters" 
     203                        else     
     204                                limits[i][1] = fs.coefW[i] * multip 
     205                        endif 
    191206                endif 
    192207        endfor 
Note: See TracChangeset for help on using the changeset viewer.