# Buggy code
def load_solution(
    self,
    solution,
    allow_consistent_values_for_fixed_vars=False,
    comparison_tolerance_for_fixed_vars=1e-5,
):
    """
    Load a solution.

    Args:
        solution: A :class:`pyomo.opt.Solution` object with a
            symbol map. Optionally, the solution can be tagged
            with a default variable value (e.g., 0) that will be
            applied to those variables in the symbol map that do
            not have a value in the solution.
        allow_consistent_values_for_fixed_vars:
            Indicates whether a solution can specify
            consistent values for variables that are
            fixed.
        comparison_tolerance_for_fixed_vars: The
            tolerance used to define whether or not a
            value in the solution is consistent with the
            value of a fixed variable.
    """
    from pyomo.core.kernel.suffix import import_suffix_generator

    symbol_map = solution.symbol_map
    default_variable_value = getattr(solution, "default_variable_value", None)

    # Generate the list of active import suffixes on
    # this top level model
    valid_import_suffixes = {
        obj.storage_key: obj for obj in import_suffix_generator(self)
    }

    # To ensure that import suffix data gets properly
    # overwritten (e.g., the case where nonzero dual
    # values exist on the suffix and but only sparse
    # dual values exist in the results object) we clear
    # all active import suffixes.
    for suffix in six.itervalues(valid_import_suffixes):
        suffix.clear()

    # Load problem (model) level suffixes. These would
    # only come from ampl interfaced solution suffixes
    # at this point in time.
    for _attr_key, attr_value in six.iteritems(solution.problem):
        attr_key = _attr_key[0].lower() + _attr_key[1:]
        if attr_key in valid_import_suffixes:
            valid_import_suffixes[attr_key][self] = attr_value

    #
    # Load variable data
    #
    from pyomo.core.kernel.variable import IVariable

    for var in self.components(ctype=IVariable):
        var.stale = True
    var_skip_attrs = ["id", "canonical_label"]
    seen_var_ids = set()
    for label, entry in six.iteritems(solution.variable):
        var = symbol_map.getObject(label)
        if (var is None) or (var is SymbolMap.UnknownSymbol):
            # NOTE: the following is a hack, to handle
            #    the ONE_VAR_CONSTANT variable that is
            #    necessary for the objective
            #    constant-offset terms.  probably should
            #    create a dummy variable in the model
            #    map at the same time the objective
            #    expression is being constructed.
            if "ONE_VAR_CONST" in label:
                continue
            else:
                raise KeyError(
                    "Variable associated with symbol '%s' "
                    "is not found on this block" % (label)
                )

        seen_var_ids.add(id(var))

        if (not allow_consistent_values_for_fixed_vars) and var.fixed:
            raise ValueError(
                "Variable '%s' is currently fixed. "
                "A new value is not expected "
                "in solution" % (var.name)
            )

        for _attr_key, attr_value in six.iteritems(entry):
            attr_key = _attr_key[0].lower() + _attr_key[1:]
            if attr_key == "value":
                if (
                    allow_consistent_values_for_fixed_vars
                    and var.fixed
                    and (
                        math.fabs(attr_value - var.value)
                        > comparison_tolerance_for_fixed_vars
                    )
                ):
                    raise ValueError(
                        "Variable %s is currently fixed. "
                        "A value of '%s' in solution is "
                        "not within tolerance=%s of the current "
                        "value of '%s'"
                        % (
                            var.name,
                            attr_value,
                            comparison_tolerance_for_fixed_vars,
                            var.value,
                        )
                    )
                var.value = attr_value
                var.stale = False
            elif attr_key in valid_import_suffixes:
                valid_import_suffixes[attr_key][var] = attr_value

    # start to build up the set of unseen variable ids
    unseen_var_ids = set(symbol_map.byObject.keys())
    # at this point it contains ids for non-variable types
    unseen_var_ids.difference_update(seen_var_ids)

    #
    # Load objective solution (should simply be suffixes if
    # they exist)
    #
    objective_skip_attrs = ["id", "canonical_label", "value"]
    for label, entry in six.iteritems(solution.objective):
        obj = symbol_map.getObject(label)
        if (obj is None) or (obj is SymbolMap.UnknownSymbol):
            raise KeyError(
                "Objective associated with symbol '%s' "
                "is not found on this block" % (label)
            )
        unseen_var_ids.remove(id(obj))
        for _attr_key, attr_value in six.iteritems(entry):
            attr_key = _attr_key[0].lower() + _attr_key[1:]
            if attr_key in valid_import_suffixes:
                valid_import_suffixes[attr_key][obj] = attr_value

    #
    # Load constraint solution
    #
    con_skip_attrs = ["id", "canonical_label"]
    for label, entry in six.iteritems(solution.constraint):
        con = symbol_map.getObject(label)
        if con is SymbolMap.UnknownSymbol:
            #
            # This is a hack - see above.
            #
            if "ONE_VAR_CONST" in label:
                continue
            else:
                raise KeyError(
                    "Constraint associated with symbol '%s' "
                    "is not found on this block" % (label)
                )
        unseen_var_ids.remove(id(con))
        for _attr_key, attr_value in six.iteritems(entry):
            attr_key = _attr_key[0].lower() + _attr_key[1:]
            if attr_key in valid_import_suffixes:
                valid_import_suffixes[attr_key][con] = attr_value

    #
    # Load sparse variable solution
    #
    if default_variable_value is not None:
        for var_id in unseen_var_ids:
            var = symbol_map.getObject(symbol_map.byObject[var_id])
            if var.ctype is not IVariable:
                continue
            if (not allow_consistent_values_for_fixed_vars) and var.fixed:
                raise ValueError(
                    "Variable '%s' is currently fixed. "
                    "A new value is not expected "
                    "in solution" % (var.name)
                )

            if (
                allow_consistent_values_for_fixed_vars
                and var.fixed
                and (
                    math.fabs(default_variable_value - var.value)
                    > comparison_tolerance_for_fixed_vars
                )
            ):
                raise ValueError(
                    "Variable %s is currently fixed. "
                    "A value of '%s' in solution is "
                    "not within tolerance=%s of the current "
                    "value of '%s'"
                    % (
                        var.name,
                        default_variable_value,
                        comparison_tolerance_for_fixed_vars,
                        var.value,
                    )
                )
            var.value = default_variable_value
            var.stale = False


# Traceback (IndexError)
Welcome to IBM(R) ILOG(R) CPLEX(R) Interactive Optimizer 20.1.0.0
with Simplex, Mixed Integer &amp; Barrier Optimizers
5725-A06 5725-A29 5724-Y48 5724-Y49 5724-Y54 5724-Y55 5655-Y21
Copyright IBM Corp. 1988, 2020.  All Rights Reserved.

Type 'help' for a list of available commands.
Type 'help' followed by a command name for more
information on commands.

CPLEX> Logfile 'cplex.log' closed.
Logfile '/var/folders/pj/1113b24j7b3083zbt19pjxqm0000gn/T/tmp3ca49s13.cplex.log' open.
CPLEX> Problem '/var/folders/pj/1113b24j7b3083zbt19pjxqm0000gn/T/tmpsefek9qr.pyomo.lp' read.
Read time = 0.00 sec. (0.00 ticks)
CPLEX> Problem name         : /var/folders/pj/1113b24j7b3083zbt19pjxqm0000gn/T/tmpsefek9qr.pyomo.lp
Objective sense      : Minimize
Variables            :       3  [Nneg: 2,  Binary: 1]
Objective nonzeros   :       2
Linear constraints   :       4  [Less: 1,  Greater: 2,  Equal: 1]
Nonzeros           :       6
RHS nonzeros       :       4

Variables            : Min LB: 0.000000         Max UB: 1.000000
Objective nonzeros   : Min   : 1.000000         Max   : 3.000000
Linear constraints   :
Nonzeros           : Min   : 1.000000         Max   : 1.000000
RHS nonzeros       : Min   : 1.000000         Max   : 10.00000
CPLEX> Version identifier: 20.1.0.0 | 2020-11-10 | 9bedb6d68
Found incumbent of value 13.000000 after 0.00 sec. (0.00 ticks)
Tried aggregator 1 time.
MIP Presolve eliminated 4 rows and 3 columns.
All rows and columns eliminated.
Presolve time = 0.00 sec. (0.00 ticks)

Root node processing (before b&amp;c):
Real time             =    0.00 sec. (0.00 ticks)
Parallel b&amp;c, 12 threads:
Real time             =    0.00 sec. (0.00 ticks)
Sync time (average)   =    0.00 sec.
Wait time (average)   =    0.00 sec.
------------
Total (root+branch&amp;cut) =    0.00 sec. (0.00 ticks)

Solution pool: 2 solutions saved.

MIP - Integer optimal solution:  Objective =  6.0000000000e+00
Solution time =    0.00 sec.  Iterations = 0  Nodes = 0 (1)
Deterministic time = 0.00 ticks  (1.79 ticks/sec)

CPLEX> Incumbent solution written to file '/var/folders/pj/1113b24j7b3083zbt19pjxqm0000gn/T/tmp8xwq6lvo.cplex.sol'.
CPLEX> Traceback (most recent call last):
File "/Users/zedongpeng/Github/pyomo-MINLP-benchmarking/test.py", line 115, in <module>
results = opt.solve(model,tee=True) #,warmstart=True)
File "/Users/zedongpeng/Github/pyomo/pyomo/opt/base/solvers.py", line 603, in solve
result = self._postsolve()
File "/Users/zedongpeng/Github/pyomo/pyomo/solvers/plugins/solvers/CPLEX.py", line 894, in _postsolve
results = ILMLicensedSystemCallSolver._postsolve(self)
File "/Users/zedongpeng/Github/pyomo/pyomo/opt/solver/shellcmd.py", line 269, in _postsolve
results = self.process_output(self._rc)
File "/Users/zedongpeng/Github/pyomo/pyomo/opt/solver/shellcmd.py", line 331, in process_output
self.process_soln_file(results)
File "/Users/zedongpeng/Github/pyomo/pyomo/solvers/plugins/solvers/CPLEX.py", line 780, in process_soln_file
objective_value = (tokens[0].split('=')[1].strip()).lstrip("\"").rstrip("\"")
IndexError: list index out of range

# Fixed code
def load_solution(
    self,
    solution,
    allow_consistent_values_for_fixed_vars=False,
    comparison_tolerance_for_fixed_vars=1e-5,
):
    """
    Load a solution.

    Args:
        solution: A :class:`pyomo.opt.Solution` object with a
            symbol map. Optionally, the solution can be tagged
            with a default variable value (e.g., 0) that will be
            applied to those variables in the symbol map that do
            not have a value in the solution.
        allow_consistent_values_for_fixed_vars:
            Indicates whether a solution can specify
            consistent values for variables that are
            fixed.
        comparison_tolerance_for_fixed_vars: The
            tolerance used to define whether or not a
            value in the solution is consistent with the
            value of a fixed variable.
    """
    from pyomo.core.kernel.suffix import import_suffix_generator

    symbol_map = solution.symbol_map
    default_variable_value = getattr(solution, "default_variable_value", None)

    # Generate the list of active import suffixes on
    # this top level model
    valid_import_suffixes = {
        obj.storage_key: obj for obj in import_suffix_generator(self)
    }

    # To ensure that import suffix data gets properly
    # overwritten (e.g., the case where nonzero dual
    # values exist on the suffix and but only sparse
    # dual values exist in the results object) we clear
    # all active import suffixes.
    for suffix in six.itervalues(valid_import_suffixes):
        suffix.clear()

    # Load problem (model) level suffixes. These would
    # only come from ampl interfaced solution suffixes
    # at this point in time.
    for _attr_key, attr_value in six.iteritems(solution.problem):
        attr_key = _attr_key[0].lower() + _attr_key[1:]
        if attr_key in valid_import_suffixes:
            valid_import_suffixes[attr_key][self] = attr_value

    #
    # Load variable data
    #
    from pyomo.core.kernel.variable import IVariable

    for var in self.components(ctype=IVariable):
        var.stale = True
    var_skip_attrs = ["id", "canonical_label"]
    seen_var_ids = set()
    for label, entry in six.iteritems(solution.variable):
        var = symbol_map.getObject(label)
        if (var is None) or (var is SymbolMap.UnknownSymbol):
            # NOTE: the following is a hack, to handle
            #    the ONE_VAR_CONSTANT variable that is
            #    necessary for the objective
            #    constant-offset terms.  probably should
            #    create a dummy variable in the model
            #    map at the same time the objective
            #    expression is being constructed.
            if "ONE_VAR_CONST" in label:
                continue
            else:
                raise KeyError(
                    "Variable associated with symbol '%s' "
                    "is not found on this block" % (label)
                )

        seen_var_ids.add(id(var))

        if (not allow_consistent_values_for_fixed_vars) and var.fixed:
            raise ValueError(
                "Variable '%s' is currently fixed. "
                "A new value is not expected "
                "in solution" % (var.name)
            )

        for _attr_key, attr_value in six.iteritems(entry):
            attr_key = _attr_key[0].lower() + _attr_key[1:]
            if attr_key == "value":
                if (
                    allow_consistent_values_for_fixed_vars
                    and var.fixed
                    and (
                        math.fabs(attr_value - var.value)
                        > comparison_tolerance_for_fixed_vars
                    )
                ):
                    raise ValueError(
                        "Variable %s is currently fixed. "
                        "A value of '%s' in solution is "
                        "not within tolerance=%s of the current "
                        "value of '%s'"
                        % (
                            var.name,
                            attr_value,
                            comparison_tolerance_for_fixed_vars,
                            var.value,
                        )
                    )
                var.value = attr_value
                var.stale = False
            elif attr_key in valid_import_suffixes:
                valid_import_suffixes[attr_key][var] = attr_value

    # start to build up the set of unseen variable ids
    unseen_var_ids = set(symbol_map.byObject.keys())
    # at this point it contains ids for non-variable types
    unseen_var_ids.difference_update(seen_var_ids)

    #
    # Load objective solution (should simply be suffixes if
    # they exist)
    #
    objective_skip_attrs = ["id", "canonical_label", "value"]
    for label, entry in six.iteritems(solution.objective):
        obj = symbol_map.getObject(label)
        if (obj is None) or (obj is SymbolMap.UnknownSymbol):
            raise KeyError(
                "Objective associated with symbol '%s' "
                "is not found on this block" % (label)
            )
        # Because of __default_objective__, an objective might
        # appear twice in the objective dictionary.
        unseen_var_ids.discard(id(obj))
        for _attr_key, attr_value in six.iteritems(entry):
            attr_key = _attr_key[0].lower() + _attr_key[1:]
            if attr_key in valid_import_suffixes:
                valid_import_suffixes[attr_key][obj] = attr_value

    #
    # Load constraint solution
    #
    con_skip_attrs = ["id", "canonical_label"]
    for label, entry in six.iteritems(solution.constraint):
        con = symbol_map.getObject(label)
        if con is SymbolMap.UnknownSymbol:
            #
            # This is a hack - see above.
            #
            if "ONE_VAR_CONST" in label:
                continue
            else:
                raise KeyError(
                    "Constraint associated with symbol '%s' "
                    "is not found on this block" % (label)
                )
        unseen_var_ids.remove(id(con))
        for _attr_key, attr_value in six.iteritems(entry):
            attr_key = _attr_key[0].lower() + _attr_key[1:]
            if attr_key in valid_import_suffixes:
                valid_import_suffixes[attr_key][con] = attr_value

    #
    # Load sparse variable solution
    #
    if default_variable_value is not None:
        for var_id in unseen_var_ids:
            var = symbol_map.getObject(symbol_map.byObject[var_id])
            if var.ctype is not IVariable:
                continue
            if (not allow_consistent_values_for_fixed_vars) and var.fixed:
                raise ValueError(
                    "Variable '%s' is currently fixed. "
                    "A new value is not expected "
                    "in solution" % (var.name)
                )

            if (
                allow_consistent_values_for_fixed_vars
                and var.fixed
                and (
                    math.fabs(default_variable_value - var.value)
                    > comparison_tolerance_for_fixed_vars
                )
            ):
                raise ValueError(
                    "Variable %s is currently fixed. "
                    "A value of '%s' in solution is "
                    "not within tolerance=%s of the current "
                    "value of '%s'"
                    % (
                        var.name,
                        default_variable_value,
                        comparison_tolerance_for_fixed_vars,
                        var.value,
                    )
                )
            var.value = default_variable_value
            var.stale = False