Changeset 9844c3a in sasmodels


Ignore:
Timestamp:
Sep 27, 2017 12:44:40 PM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
c0d7ab3
Parents:
0f48f1e
Message:

add note to the model writer about integer parameters

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/guide/plugin.rst

    r30b60d2 r9844c3a  
    366366    dispersion. 
    367367 
     368 
     369Integer Parameters 
     370.................. 
     371 
     372Some models will have integer parameters, such as number of pearls in the 
     373pearl necklace model, or number of shells in the multi-layer vesicle model. 
     374The optimizers in BUMPS treat all parameters as floating point numbers which 
     375can take arbitrary values, even for integer parameters, so your model should 
     376round the incoming parameter value to the nearest integer inside your model 
     377you should round to the nearest integer.  In C code, you can do this using:: 
     378 
     379    static double 
     380    Iq(double q, ..., double fp_n, ...) 
     381    { 
     382        int n = (int)(fp_n + 0.5); 
     383        ... 
     384    } 
     385 
     386in python:: 
     387 
     388    def Iq(q, ..., n, ...): 
     389        n = int(n+0.5) 
     390        ... 
     391 
     392Derivatibve based optimizers such as Levenberg-Marquardt will not work 
     393for integer parameters since the partial derivative is always zero, but 
     394the remaining optimizers (DREAM, differential evolution, Nelder-Mead simplex) 
     395will still function. 
    368396 
    369397Model Computation 
Note: See TracChangeset for help on using the changeset viewer.