Cplex

class pyomo.contrib.appsi.solvers.cplex.CplexConfig(description=None, doc=None, implicit=False, implicit_domain=None, visibility=0)[source]

Bases: MIPSolverConfig

add(name, config)
content_filters = {'all', 'userdata', None}
declare(name, config)
declare_as_argument(*args, **kwds)

Map this Config item to an argparse argument.

Valid arguments include all valid arguments to argparse’s ArgumentParser.add_argument() with the exception of ‘default’. In addition, you may provide a group keyword argument to either pass in a pre-defined option group or subparser, or else pass in the string name of a group, subparser, or (subparser, group).

declare_from(other, skip=None)
display(content_filter=None, indent_spacing=2, ostream=None, visibility=None)
domain_name()
generate_documentation(block_start=None, block_end=None, item_start=None, item_body=None, item_end=None, indent_spacing=2, width=78, visibility=None, format='latex')
generate_yaml_template(indent_spacing=2, width=78, visibility=0)
get(k[, d]) D[k] if k in D, else d.  d defaults to None.
import_argparse(parsed_args)
initialize_argparse(parser)
items() a set-like object providing a view on D's items
iteritems()

DEPRECATED.

Deprecated since version 6.0: The iteritems method is deprecated. Use dict.keys().

iterkeys()

DEPRECATED.

Deprecated since version 6.0: The iterkeys method is deprecated. Use dict.keys().

itervalues()

DEPRECATED.

Deprecated since version 6.0: The itervalues method is deprecated. Use dict.keys().

keys() a set-like object providing a view on D's keys
load_solution: bool
mip_gap: float | None
name(fully_qualified=False)
relax_integrality: bool
report_timing: bool
reset()
set_default_value(default)
set_domain(domain)
set_value(value, skip_implicit=False)
setdefault(key, default=NOTSET)
stream_solver: bool
symbolic_solver_labels: bool
time_limit: float | None
unused_user_values()
user_values()
value(accessValue=True)
values() an object providing a view on D's values
class pyomo.contrib.appsi.solvers.cplex.CplexResults(solver)[source]

Bases: Results

class pyomo.contrib.appsi.solvers.cplex.Cplex(only_child_vars=False)[source]

Bases: PersistentSolver

enum Availability(value)

Bases: IntEnum

An enumeration.

Member Type:

int

Valid values are as follows:

NotFound = <Availability.NotFound: 0>
BadVersion = <Availability.BadVersion: -1>
BadLicense = <Availability.BadLicense: -2>
FullLicense = <Availability.FullLicense: 1>
LimitedLicense = <Availability.LimitedLicense: 2>
NeedsCompiledExtension = <Availability.NeedsCompiledExtension: -3>
add_block(block: _BlockData)[source]
add_constraints(cons: List[_GeneralConstraintData])[source]
add_params(params: List[_ParamData])[source]
add_variables(variables: List[_GeneralVarData])[source]
available()[source]

Test if the solver is available on this system.

Nominally, this will return True if the solver interface is valid and can be used to solve problems and False if it cannot.

Note that for licensed solvers there are a number of “levels” of available: depending on the license, the solver may be available with limitations on problem size or runtime (e.g., ‘demo’ vs. ‘community’ vs. ‘full’). In these cases, the solver may return a subclass of enum.IntEnum, with members that resolve to True if the solver is available (possibly with limitations). The Enum may also have multiple members that all resolve to False indicating the reason why the interface is not available (not found, bad license, unsupported version, etc).

Returns:

available – An enum that indicates “how available” the solver is. Note that the enum can be cast to bool, which will be True if the solver is runable at all and False otherwise.

Return type:

Solver.Availability

property config

An object for configuring solve options.

Returns:

An object for configuring pyomo solve options such as the time limit. These options are mostly independent of the solver.

Return type:

SolverConfig

property cplex_options

A dictionary mapping solver options to values for those options. These are solver specific.

Returns:

A dictionary mapping solver options to values for those options

Return type:

dict

get_duals(cons_to_load: Sequence[_GeneralConstraintData] | None = None) Dict[_GeneralConstraintData, float][source]

Declare sign convention in docstring here.

Parameters:

cons_to_load (list) – A list of the constraints whose duals should be loaded. If cons_to_load is None, then the duals for all constraints will be loaded.

Returns:

duals – Maps constraints to dual values

Return type:

dict

get_primals(vars_to_load: Sequence[_GeneralVarData] | None = None) Mapping[_GeneralVarData, float][source]
get_reduced_costs(vars_to_load: Sequence[_GeneralVarData] | None = None) Mapping[_GeneralVarData, float][source]
Parameters:

vars_to_load (list) – A list of the variables whose reduced cost should be loaded. If vars_to_load is None, then all reduced costs will be loaded.

Returns:

reduced_costs – Maps variable to reduced cost

Return type:

ComponentMap

get_slacks(cons_to_load: Sequence[_GeneralConstraintData] | None = None) Dict[_GeneralConstraintData, float]
Parameters:

cons_to_load (list) – A list of the constraints whose slacks should be loaded. If cons_to_load is None, then the slacks for all constraints will be loaded.

Returns:

slacks – Maps constraints to slack values

Return type:

dict

is_persistent()
Returns:

is_persistent – True if the solver is a persistent solver.

Return type:

bool

load_vars(vars_to_load: Sequence[_GeneralVarData] | None = None) NoReturn

Load the solution of the primal variables into the value attribute of the variables.

Parameters:

vars_to_load (list) – A list of the variables whose solution should be loaded. If vars_to_load is None, then the solution to all primal variables will be loaded.

log_filename()[source]
lp_filename()[source]
remove_block(block: _BlockData)[source]
remove_constraints(cons: List[_GeneralConstraintData])[source]
remove_params(params: List[_ParamData])[source]
remove_variables(variables: List[_GeneralVarData])[source]
set_instance(model)[source]
set_objective(obj: _GeneralObjectiveData)[source]
solve(model, timer: HierarchicalTimer | None = None)[source]

Solve a Pyomo model.

Parameters:
  • model (_BlockData) – The Pyomo model to be solved

  • timer (HierarchicalTimer) – An option timer for reporting timing

Returns:

results – A results object

Return type:

Results

property symbol_map
property update_config
update_params()[source]
update_variables(variables: List[_GeneralVarData])[source]
version()[source]
Returns:

version – A tuple representing the version

Return type:

tuple

property writer