Constraint Exchange Algorithms¶
Constraints Consensus¶
- class disropt.algorithms.constraintexchange.ConstraintsConsensus(agent, enable_log=False)[source]¶
Bases:
disropt.algorithms.algorithm.Algorithm
Constraints Consensus Algorithm [NoBu11]
This algorithm solves convex and abstract programs in the form
\begin{split} \min_{x} \: & \: c^\top x \\ \mathrm{subj. to} \: & \: x\in \bigcap_{i=1}^{N} X_i \\ & \: x \ge 0 \end{split}- x¶
current value of the local solution
- Type
- B¶
basis associated to the local solution
- Type
- sequence_x¶
sequence of local solutions
- Type
Distributed Simplex¶
- class disropt.algorithms.constraintexchange.DistributedSimplex(agent, problem_size=None, local_indices=None, enable_log=False, stop_iterations=None, big_M=500.0)[source]¶
Bases:
disropt.algorithms.algorithm.Algorithm
Distributed Simplex Algorithm [BuNo11]
This algorithm solves linear programs in standard form
\begin{split} \min_{x} \: & \: c^\top x \\ \mathrm{subj. to} \: & \: Ax = b \\ & \: x \ge 0 \end{split}When reading the variable agent.problem.constraints, this class only considers equality constraints. Other constraints are discarded.
- x¶
current value of the complete solution
- Type
- x_basic¶
current value of the basic solution
- Type
- B¶
basis associated to the local solution
- Type
- A_init¶
initial constraint matrix
- Type
- b_init¶
initial constraint vector
- Type
- c_init¶
initial cost vector
- Type
- sequence_x¶
sequence of solutions
- Type
- sequence_J¶
sequence of costs
- Type
- Parameters
agent (Agent) – agent to execute the algorithm
problem_size (list) – total number of variables in the network. Defaults to None. If both problem_size and local_indices is provided, the complete solution vector will be computed.
local_indices (list) – indices of the agent’s variables in the network, starting from 0. Defaults to None. If both problem_size and local_indices is provided, the complete solution vector will be computed.
enable_log (bool) – True to enable log
stop_iterations (int) – iterations with constant solution to stop algorithm. Defaults to None (disabled).
big_M (float) – cost of big-M variables. Defaults to 500.
- check_index_consistency()[source]¶
Check consistency of local indices, problem_size and constraint matrix
- get_result()[source]¶
Return the current value of the solution
- Returns
value of primal solution, primal basic solution, dual solution, cost
- Return type
tuple of nd.ndarray (primal, primal_basic, dual, cost)
- initialize()[source]¶
Evaluate a first solution and basis starting from agent’s constraints through the Big-M method
- read_problem_data()[source]¶
Read local problem data from agent.problem. The data is saved in order to be solved as a standard form problem.
Dual Distributed Simplex¶
- class disropt.algorithms.constraintexchange.DualDistributedSimplex(agent, num_constraints=None, local_indices=None, enable_log=False, stop_iterations=None, big_M=500.0)[source]¶
Bases:
disropt.algorithms.constraintexchange.DistributedSimplex
Distributed Simplex Algorithm on dual problem [BuNo11]
This algorithm solves linear programs of the form
\begin{split} \max_{x} \: & \: c^\top x \\ \mathrm{subj. to} \: & \: Ax \le b \end{split}This class runs the Distributed Simplex algorithm on the (standard form) dual problem.
- Parameters
agent (Agent) – agent to execute the algorithm
num_constraints (list) – total number of constraints in the network. Defaults to None. If both num_constraints and local_indices is provided, the complete dual solution vector will be computed.
local_indices (list) – indices of the agent’s constraints in the network, starting from 0. Defaults to None. If both num_constraints and local_indices is provided, the complete dual solution vector will be computed.
enable_log (bool) – True to enable log
stop_iterations (int) – iterations with constant solution to stop algorithm. Defaults to None (disabled).
big_M (float) – cost of big-M variables. Defaults to 500.
- check_index_consistency()[source]¶
Check consistency of local indices, num_constraints and constraint matrix
References