pyepo.model.copt.coptmodel

Abstract optimization model based on Cardinal Optimizer (COPT)

Classes

optCoptModel

Abstract base class for Cardinal Optimizer (COPT) backed models.

Module Contents

class pyepo.model.copt.coptmodel.optCoptModel

Bases: pyepo.model.opt.optModel

Abstract base class for Cardinal Optimizer (COPT) backed models.

Subclasses implement _getModel to build a COPT Model and return (model, variables). The objective sense is auto-detected from the underlying COPT model (no need to set modelSense manually); solver logging is silenced by default. Cost-vector updates use the C-level setInfo("Obj", ...) batch path for efficiency. A process-local COPT Envr singleton is reused across instances to avoid re-booting the license and worker threads on every model build.

Variables:

_model (coptpy.Model) – underlying COPT model

setObj(c: numpy.ndarray | torch.Tensor | list) None

A method to set the objective function

Parameters:

c – cost of objective function

solve() tuple[numpy.ndarray, float]

A method to solve the model

Returns:

optimal solution and objective value

Return type:

tuple

copy() Self

A method to copy the model

Returns:

new copied model

Return type:

optModel

addConstr(coefs: numpy.ndarray | torch.Tensor | list, rhs: float) Self

A method to add a new constraint

Parameters:
  • coefs – coefficients of new constraint

  • rhs – right-hand side of new constraint

Returns:

new model with the added constraint

Return type:

optModel