'checks for better solutions in list `arx`, based on the smallest
corresponding value in `arf`, alternatively, `update` may be called
with a `BestSolution` instance like ``update(another_best_solution)``
in which case the better solution becomes the current best.
`xarchive` is used to retrieve the genotype of a solution.'

def update(self, arx, xarchive=None, arf=None, evals=None):

    if (arf is not None):
        minidx = np.nanargmin(arf)
        if (minidx is np.nan):
            return
        minarf = arf[minidx]
    if (type(arx) == BestSolution):
        if (self.evalsall is None):
            self.evalsall = arx.evalsall
        elif (arx.evalsall is not None):
            self.evalsall = max((self.evalsall, arx.evalsall))
        if ((arx.f is not None) and (arx.f < np.inf)):
            self.update([arx.x], xarchive, [arx.f], arx.evals)
        return self
    elif ((minarf < np.inf) and ((minarf < self.f) or (self.f is None))):
        (self.x, self.f) = (arx[minidx], arf[minidx])
        self.x_geno = (xarchive[self.x]['geno'] if (xarchive is not None) else None)
        self.evals = (None if (not evals) else (((evals - len(arf)) + minidx) + 1))
        self.evalsall = evals
    elif evals:
        self.evalsall = evals
    self.last.x = arx[minidx]
    self.last.f = minarf
