pythonconstraintsfinancetoolboxeconomics

Systems with multiple constraints in PyMacroFin


I have a question regarding the toolbox PyMacroFin. Is handling simultaneous constraints possible? I mean for example we>1 && wr<0? (we and wr are two endogenous variables that need to be constrained at the same time)


Solution

  • You would do that as follows, following this page of the documentation:

    m.constraint(‘we’,’>’,1, label=’one’)
    m.constraint(‘wr’,’<’,0, label=’two’)
    
    s = system([‘one’,’two’],m)
    …
    m.systems.append(s)
    

    Basically, you just add the list of constraint labels to the system. The solution procedure should sort the systems such that if you have a system with both constraints, then another system with just one of the constraints, it will check for the combined constraints first, then check for the individual constraints. For example, you can do the following:

    m.constraint(‘we’,’>’,1, label=’one’)
    m.constraint(‘wr’,’<’,0, label=’two’)
    
    s1 = system([‘one’,’two’],m)
    …
    m.systems.append(s1)
    
    s2 = system([‘one’],m)
    …
    m.systems.append(s2)
    

    If we <= 1 and wr >=0, then it will switch to system s1. If however we <= 1 and wr < 0, it will switch to system 2.