'Returns the result of the call to the solver.
Parameters
objective : LinOp
The canonicalized objective.
constraints : list
The list of canonicalized cosntraints.
cached_data : dict
A map of solver name to cached problem data.
warm_start : bool
Should the previous solver result be used to warm_start?
verbose : bool
Should the solver print output?
solver_opts : dict
Additional arguments for the solver.
Returns
tuple
(status, optimal value, primal, equality dual, inequality dual)'

def solve(self, objective, constraints, cached_data, warm_start, verbose, solver_opts):

    import xpress
    verbose = True
    data = super(XPRESS, self).get_problem_data(objective, constraints, cached_data)
    origprob = None
    if ('original_problem' in solver_opts.keys()):
        origprob = solver_opts['original_problem']
    if (('no_qp_reduction' in solver_opts.keys()) and (solver_opts['no_qp_reduction'] is True)):
        self.translate_back_QP_ = True
    c = data[s.C]
    dims = data[s.DIMS]
    nrowsEQ = dims[s.EQ_DIM]
    nrowsLEQ = dims[s.LEQ_DIM]
    nrows = (nrowsEQ + nrowsLEQ)
    b = data[s.B][:nrows]
    A = data[s.A][:nrows]
    n = c.shape[0]
    solver_cache = cached_data[self.name()]
    if (warm_start and (solver_cache.prev_result is not None) and (n == len(solver_cache.prev_result['obj'])) and (nrows == len(solver_cache.prev_result['rhs'])) and (data[s.DIMS][s.SOC_DIM] == solver_cache.prev_result['cone_ind'])):
        self.prob_ = solver_cache.prev_result['problem']
        c0 = solver_cache.prev_result['obj']
        A0 = solver_cache.prev_result['mat']
        b0 = solver_cache.prev_result['rhs']
        vartype0 = solver_cache.prev_result['vartype']
        if (len(linutils.get_expr_params(objective)) > 0):
            dci = numpy.where((c != c0))[0]
            self.prob_.chgobj(dci, c[dci])
        sym_data = self.get_sym_data(objective, constraints, cached_data)
        (all_constrs, _, _) = self.split_constr(sym_data.constr_map)
        if any(((len(linutils.get_expr_params(con.expr)) > 0) for con in constraints)):
            dAi = (A != A0).tocoo()
            dbi = numpy.where((b != b0))[0]
            if (dAi.getnnz() > 0):
                self.prob_.chgmcoef(dAi.row, dAi.col, [A[(i, j)] for (i, j) in list(zip(dAi.row, dAi.col))])
            if (len(dbi) > 0):
                self.prob_.chgrhs(dbi, b[dbi])
        vartype = []
        self.prob_.getcoltype(vartype, 0, (len(data[s.C]) - 1))
        vti = (numpy.array(vartype) != numpy.array(vartype0))
        if any(vti):
            self.prob_.chgcoltype(numpy.arange(len(c))[vti], vartype[vti])
    else:
        self.prob_ = xpress.problem()
        mstart = makeMstart(A, len(c), 1)
        varGroups = {}
        transf2Orig = {}
        nOrigVar = len(c)
        if (origprob is not None):
            nOrigVar = 0
            orig_id = [i.id for i in origprob.constraints]
            varnames = []
            for v in origprob.variables():
                nOrigVar += v.size[0]
                if (v.size[0] == 1):
                    varnames.append('{0}'.format(v.var_id))
                else:
                    varnames.extend(['{0}_{1:d}'.format(v.var_id, j) for j in range(v.size[0])])
            varnames.extend(['aux_{0:d}'.format(i) for i in range(len(varnames), len(c))])
            linRownames = []
            for con in constraints:
                if (con.constr_id in orig_id):
                    prefix = ''
                    if (type(con.constr_id) == int):
                        prefix = 'row_'
                    if (con.size[0] == 1):
                        name = '{0}{1}'.format(prefix, con.constr_id)
                        linRownames.append(name)
                        transf2Orig[name] = con.constr_id
                    else:
                        names = ['{0}{1}_{2:d}'.format(prefix, con.constr_id, j) for j in range(con.size[0])]
                        linRownames.extend(names)
                        for i in names:
                            transf2Orig[i] = con.constr_id
            iObjQuad = 0
            for i in range(nOrigVar, len(c)):
                if (c[i] != 0):
                    varGroups[varnames[i]] = 'objF_{0}'.format(iObjQuad)
                    iObjQuad += 1
                if (len(A.indices[mstart[i]:mstart[(i + 1)]]) > 0):
                    varGroups[varnames[i]] = linRownames[min(A.indices[mstart[i]:mstart[(i + 1)]])]
        else:
            varnames = ['x_{0:05d}'.format(i) for i in range(len(c))]
            linRownames = ['lc_{0:05d}'.format(i) for i in range(len(b))]
        self.prob_.loadproblem('CVXproblem', ((['E'] * nrowsEQ) + (['L'] * nrowsLEQ)), b, None, c, mstart, None, A.indices, A.data, ([(- xpress.infinity)] * len(c)), ([xpress.infinity] * len(c)), colnames=varnames, rownames=linRownames)
        x = numpy.array(self.prob_.getVariable())
        self.prob_.chgcoltype((data[s.BOOL_IDX] + data[s.INT_IDX]), (('B' * len(data[s.BOOL_IDX])) + ('I' * len(data[s.INT_IDX]))))
        currow = nrows
        iCone = 0
        auxVars = set(range(nOrigVar, len(c)))
        for k in dims[s.SOC_DIM]:
            A = data[s.A][currow:(currow + k)].tocsr()
            b = data[s.B][currow:(currow + k)]
            currow += k
            if self.translate_back_QP_:
                Plhs = A[1:]
                Prhs = A[0]
                (indRowL, indColL) = Plhs.nonzero()
                (indRowR, indColR) = Prhs.nonzero()
                coeL = Plhs.data
                coeR = Prhs.data
                lhs = list(b[1:])
                rhs = b[0]
                for i in range(len(coeL)):
                    lhs[indRowL[i]] -= (coeL[i] * x[indColL[i]])
                for i in range(len(coeR)):
                    rhs -= (coeR[i] * x[indColR[i]])
                self.prob_.addConstraint((xpress.Sum([(lhs[i] ** 2) for i in range(len(lhs))]) <= (rhs ** 2)))
            else:
                conevar = numpy.array([xpress.var(name='cX{0:d}_{1:d}'.format(iCone, i), lb=((- xpress.infinity) if (i > 0) else 0)) for i in range(k)])
                self.prob_.addVariable(conevar)
                initrow = self.prob_.attributes.rows
                mstart = makeMstart(A, k, 0)
                trNames = ['linT_qc{0:d}_{1:d}'.format(iCone, i) for i in range(k)]
                self.prob_.addrows((['E'] * k), b, mstart, A.indices, A.data, names=trNames)
                self.prob_.chgmcoef([(initrow + i) for i in range(k)], conevar, ([1] * k))
                conename = 'cone_qc{0:d}'.format(iCone)
                if (k > 1):
                    self.prob_.addConstraint(xpress.constraint(constraint=(xpress.Sum(((conevar[i] ** 2) for i in range(1, k))) <= (conevar[0] ** 2)), name=conename))
                auxInd = list((set(A.indices) & auxVars))
                if (len(auxInd) > 0):
                    group = varGroups[varnames[auxInd[0]]]
                    for i in trNames:
                        transf2Orig[i] = group
                    transf2Orig[conename] = group
            iCone += 1
        self.prob_.setObjective(xpress.Sum(((c[i] * x[i]) for i in range(len(c)))))
    if verbose:
        self.prob_.controls.miplog = 2
        self.prob_.controls.lplog = 1
        self.prob_.controls.outputlog = 1
    else:
        self.prob_.controls.miplog = 0
        self.prob_.controls.lplog = 0
        self.prob_.controls.outputlog = 0
    if ('solver_opts' in solver_opts.keys()):
        self.prob_.setControl(solver_opts['solver_opts'])
    self.prob_.setControl({i: solver_opts[i] for i in solver_opts.keys() if (i in xpress.controls.__dict__.keys())})
    self.prob_.solve()
    results_dict = {'problem': self.prob_, 'status': self.prob_.getProbStatus(), 'obj_value': self.prob_.getObjVal()}
    (status_map_lp, status_map_mip) = self.get_status_maps()
    if self.is_mip(data):
        status = status_map_mip[results_dict['status']]
    else:
        status = status_map_lp[results_dict['status']]
    results_dict[s.XPRESS_TROW] = transf2Orig
    results_dict[s.XPRESS_IIS] = None
    if (status in s.SOLUTION_PRESENT):
        results_dict['x'] = self.prob_.getSolution()
        if (not self.is_mip(data)):
            results_dict['y'] = self.prob_.getDual()
    elif (status == s.INFEASIBLE):
        iisIndex = 0
        self.prob_.iisfirst(0)
        (row, col, rtype, btype, duals, rdcs, isrows, icols) = ([], [], [], [], [], [], [], [])
        self.prob_.getiisdata(0, row, col, rtype, btype, duals, rdcs, isrows, icols)
        origrow = []
        for iRow in row:
            if (iRow.name in transf2Orig.keys()):
                name = transf2Orig[iRow.name]
            else:
                name = iRow.name
            if (name not in origrow):
                origrow.append(name)
        results_dict[s.XPRESS_IIS] = [{'orig_row': origrow, 'row': row, 'col': col, 'rtype': rtype, 'btype': btype, 'duals': duals, 'redcost': rdcs, 'isolrow': isrows, 'isolcol': icols}]
        while (self.prob_.iisnext() == 0):
            iisIndex += 1
            self.prob_.getiisdata(iisIndex, row, col, rtype, btype, duals, rdcs, isrows, icols)
            results_dict[s.XPRESS_IIS].append((row, col, rtype, btype, duals, rdcs, isrows, icols))
    return self.format_results(results_dict, data, cached_data)
