docs: def _substitute_variables(cls, expression, model=None, **kwargs):
          """Substitutes variables in (optimization)expression (constraint/objective) with variables of the appropriate interface type.
          Attributes
          ----------
          expression: Constraint, Objective
              An optimization expression.
          model: Model or None, optional
              A reference to an optimization model that should be searched for appropriate variables first.
          """
          interface = sys.modules[cls.__module__]
          variable_substitutions = dict()
          for variable in expression.variables:
              if model is not None and variable.name in model.variables:
                  # print(variable.name, id(variable.problem))
                  variable_substitutions[variable] = model.variables[variable.name]
              else:
                  variable_substitutions[variable] = interface.Variable.clone(variable)
          adjusted_expression = expression.expression.xreplace(variable_substitutions)
          return adjusted_expression