Ignore:
Timestamp:
Nov 7, 2013 12:12:55 PM (8 years ago)
Author:
toby
Message:

major constraints revision

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIImapvars.py

    r1046 r1138  
    221221
    222222# prefix for parameter names
    223 paramPrefix = "::constr:"
     223paramPrefix = "::constr;"
    224224consNum = 0 # number of the next constraint to be created
    225225
     
    248248    :returns: two lists of lists:
    249249   
    250       * a list of grouped contraints where each constraint grouped containts a list of indices for constraint constrDict entries
     250      * a list of grouped contraints where each constraint grouped containts a list
     251        of indices for constraint constrDict entries
    251252      * a list containing lists of parameter names contained in each group
    252253     
     
    284285    :param list varyList: a list of parameters names that will be varied
    285286
    286     :param dict constrDict: a list of dicts defining relationships/constraints (as defined in :func:`GroupConstraints`)
    287 
    288     :param list fixedList: a list of values specifying a fixed value for each dict in constrDict. Values are
    289       either strings that can be converted to floats or None if the constraint defines a new parameter rather
     287    :param dict constrDict: a list of dicts defining relationships/constraints
     288      (as created in :func:`GSASIIstrIO.ProcessConstraints` and
     289      documented in :func:`GroupConstraints`)
     290
     291    :param list fixedList: a list of values specifying a fixed value for each
     292      dict in constrDict. Values are either strings that can be converted to
     293      floats or ``None`` if the constraint defines a new parameter rather
    290294      than a constant.
    291295
     
    491495    conflicts or inconsistencies in parameter/variable definitions.
    492496
    493     :param list groups: a list of grouped contraints where each constraint grouped containts a list of
    494       indices for constraint constrDict entries, created in :func:`GroupConstraints` (returned as 1st value)
    495 
    496     :param list parmlist: a list containing lists of parameter names contained in each group,
     497    :param list groups: a list of grouped contraints where each constraint
     498      grouped containts a list of indices for constraint constrDict entries,
    497499      created in :func:`GroupConstraints` (returned as 1st value)
    498500
    499     :param list varyList: a list of parameters names (strings of form ``<ph>:<hst>:<nam>``) that will be varied
     501    :param list parmlist: a list containing lists of parameter names
     502      contained in each group, created in :func:`GroupConstraints`
     503      (returned as 2nd value)
     504
     505    :param list varyList: a list of parameters names (strings of form
     506      ``<ph>:<hst>:<nam>``) that will be varied
    500507   
    501     :param dict constrDict: a list of dicts defining relationships/constraints (as defined in :func:`GroupConstraints`)
    502 
    503     :param list fixedList: a list of values specifying a fixed value for each dict in constrDict. Values are
    504       either strings that can be converted to floats, float values or None if the constraint defines a new
    505       parameter
     508    :param dict constrDict: a list of dicts defining relationships/constraints
     509      (as defined in :func:`GroupConstraints`)
     510
     511    :param list fixedList: a list of values specifying a fixed value for each
     512      dict in constrDict. Values are either strings that can be converted to
     513      floats, float values or None if the constraint defines a new parameter.
    506514     
    507     :param dict constrDict: a list of dicts defining relationships/constraints
     515    :param dict constrDict: a list of dicts defining relationships/constraints.
    508516
    509517    '''
     
    537545                if mv not in indepVarList: indepVarList.append(mv)
    538546                for v,m in zip(varlist,invmultarr):
    539                     #if len(s): s += '  & '
    540                     #s += str(v)
    541                     #if m != 1:
    542                     #    s += " / " + str(m[0])                       
    543547                    if m == 0: zeromult = True
    544548                    if v in varyList:
     
    551555                    else:
    552556                        depVarList.append(v)
    553                 #print str(mv) + ' is equivalent to parameter(s): '+s
    554557            if varied > 0 and varied != len(varlist)+1:
    555558                msg += "\nNot all variables refined in equivalence:\n\t"
     
    587590        msg += '\t'+ s + '\n'
    588591    equivVarList = list(set(indepVarList).union(set(depVarList)))
    589     #print 'equivVarList',equivVarList
    590 #    inboth = set(fixedVarList).intersection(set(equivVarList))
    591 #    if len(inboth) > 0:
    592 #        msg += "\nError! The following variables are used in both Equivalence and Fixed constraints:\n"
    593 #        s = ''
    594 #        for var in sorted(inboth):
    595 #            if s != "": s+= ", "
    596 #            s += str(var)
    597 #        msg += '\t'+ s + '\n'
    598 #
     592
    599593    # scan through parameters in each relationship. Are all varied? If only some are
    600594    # varied, create an error message.
     
    616610                    msg += '\nError: parameter '+var+" is Fixed and used in a constraint:\n\t"
    617611                    msg += _FormatConstraint(constrDict[rel],fixedList[rel])+"\n"
    618 #                if var in equivVarList:
    619 #                    msg += '\nError: parameter '+var+" is Equivalenced and used in a constraint:\n\t"
    620 #                    msg += _FormatConstraint(constrDict[rel],fixedList[rel])+"\n"
    621612            if varied > 0 and varied != len(constrDict[rel]):
    622613                msg += "\nNot all variables refined in constraint:\n\t"
     
    656647            varied = 0
    657648            notvaried = ''
    658             if len(group) > 0:
     649            if len(group) > 0: # get the original equation reference
    659650                rel = group.pop(0)
     651                if debug:
     652                    print rel
     653                    print fixedList[rel]
     654                    print constrDict[rel]
    660655                fixedval = fixedList[rel]
    661656                for var in constrDict[rel]:
     
    696691    if debug: # on debug, show what is parsed & generated, semi-readable
    697692        print 50*'-'
    698         for group,varlist,multarr,inv,mapvar in zip(groups,parmlist,arrayList,invarrayList,indParmList):
    699             print '\n*** relation(s) in group:',group,'\tvars in group:',varlist
    700             print 'new parameters:', mapvar
    701             print 'Input relationship matrix'
    702             print multarr[:len(group)]
    703             added = len(group) - len(varlist)
    704             if added < 0:
    705                 print 'added relationship rows'
    706                 print multarr[added:]
    707             print 'Inverse relationship matrix'
    708             print inv
     693        print VarRemapShow(varyList)
    709694
    710695def StoreEquivalence(independentVar,dependentList):
Note: See TracChangeset for help on using the changeset viewer.