def __init__(self, constraints, include_only=None, exclude=None):
    if (not isinstance(constraints, ConstraintSet)):
        constraints = ConstraintSet(constraints)
    exclude = (frozenset(exclude) if exclude else frozenset())
    include_only = (frozenset(include_only) if include_only else frozenset())
    substitutions = KeyDict(constraints.substitutions)
    (constants, _, linked) = parse_subs(constraints.varkeys, substitutions)
    constrained_varkeys = constraints.constrained_varkeys()
    if linked:
        kdc = KeyDict(constants)
        constants.update({k: f(kdc) for (k, f) in linked.items() if (k in constrained_varkeys)})
    self.constants = constants
    (relaxvars, self.origvars, relaxation_constraints) = ([], [], {})
    with NamedVariables('Relax') as (self.lineage, _):
        pass
    self._unrelaxmap = {}
    for (key, value) in constants.items():
        if (value == 0):
            continue
        elif (include_only and (key.name not in include_only)):
            continue
        elif (key.name in exclude):
            continue
        key.descr.pop('gradients', None)
        descr = key.descr.copy()
        descr.pop('veckey', None)
        descr['lineage'] = (descr.pop('lineage', ()) + (self.lineage[(- 1)],))
        relaxvardescr = descr.copy()
        relaxvardescr['unitrepr'] = '-'
        relaxvar = Variable(**relaxvardescr)
        relaxvars.append(relaxvar)
        del substitutions[key]
        var = Variable(**key.descr)
        self.origvars.append(var)
        unrelaxeddescr = descr.copy()
        unrelaxeddescr['lineage'] += (('OriginalValues', 0),)
        unrelaxed = Variable(**unrelaxeddescr)
        self._unrelaxmap[unrelaxed.key] = key
        substitutions[unrelaxed] = value
        relaxation_constraints[str(key)] = [(relaxvar >= 1), ((unrelaxed / relaxvar) <= var), (var <= (unrelaxed * relaxvar))]
    self.relaxvars = NomialArray(relaxvars)
    ConstraintSet.__init__(self, {'original constraints': constraints, 'relaxation constraints': relaxation_constraints})
    self.substitutions = substitutions
def __init__(self, constraints, include_only=None, exclude=None):
    if (not isinstance(constraints, ConstraintSet)):
        constraints = ConstraintSet(constraints)
    exclude = (frozenset(exclude) if exclude else frozenset())
    include_only = (frozenset(include_only) if include_only else frozenset())
    substitutions = KeyDict(constraints.substitutions)
    (constants, _, linked) = parse_subs(constraints.varkeys, substitutions)
    constrained_varkeys = constraints.constrained_varkeys()
    if linked:
        kdc = KeyDict(constants)
        constants.update({k: f(kdc) for (k, f) in linked.items() if (k in constrained_varkeys)})
    self.constants = constants
    (relaxvars, self.origvars, relaxation_constraints) = ([], [], {})
    with NamedVariables('Relax') as (self.lineage, _):
        pass
    self._unrelaxmap = {}
    for (key, value) in constants.items():
        if (value == 0):
            continue
        elif (include_only and (key.name not in include_only)):
            continue
        elif (key.name in exclude):
            continue
        key.descr.pop('gradients', None)
        descr = key.descr.copy()
        descr.pop('veckey', None)
        descr['lineage'] = (descr.pop('lineage', ()) + (self.lineage[(- 1)],))
        relaxvardescr = descr.copy()
        relaxvardescr['unitrepr'] = '-'
        relaxvar = Variable(**relaxvardescr)
        relaxvars.append(relaxvar)
        del substitutions[key]
        var = Variable(**key.descr)
        self.origvars.append(var)
        unrelaxeddescr = descr.copy()
        unrelaxeddescr['lineage'] += (('OriginalValues', 0),)
        unrelaxed = Variable(**unrelaxeddescr)
        self._unrelaxmap[unrelaxed.key] = key
        substitutions[unrelaxed] = value
        relaxation_constraints[str(key)] = [(relaxvar >= 1), ((unrelaxed / relaxvar) <= var), (var <= (unrelaxed * relaxvar))]
    self.relaxvars = NomialArray(relaxvars)
    ConstraintSet.__init__(self, {'original constraints': constraints, 'relaxation constraints': relaxation_constraints})
    self.substitutions = substitutions