MCPcopy Create free account
hub / github.com/cvxpy/cvxpy / __init__

Method __init__

cvxpy/problems/problem.py:1619–1654  ·  view source on GitHub ↗
(self, problem: Problem)

Source from the content-addressed store, hash-verified

1617 """
1618
1619 def __init__(self, problem: Problem) -> None:
1620 # num_scalar_variables
1621 self.num_scalar_variables = 0
1622 for var in problem.variables():
1623 self.num_scalar_variables += var.size
1624
1625 # num_scalar_data, max_data_dimension, and max_big_small_squared
1626 self.max_data_dimension = 0
1627 self.num_scalar_data = 0
1628 self.max_big_small_squared = 0
1629 for const in problem.constants()+problem.parameters():
1630 big = 0
1631 # Compute number of data
1632 self.num_scalar_data += const.size
1633 big = 1 if len(const.shape) == 0 else max(const.shape)
1634 small = 1 if len(const.shape) == 0 else min(const.shape)
1635
1636 # Get max data dimension:
1637 if self.max_data_dimension < big:
1638 self.max_data_dimension = big
1639
1640 max_big_small_squared = float(big)*(float(small)**2)
1641 if self.max_big_small_squared < max_big_small_squared:
1642 self.max_big_small_squared = max_big_small_squared
1643
1644 # num_scalar_eq_constr
1645 self.num_scalar_eq_constr = 0
1646 for constraint in problem.constraints:
1647 if isinstance(constraint, (Equality, Zero)):
1648 self.num_scalar_eq_constr += constraint.expr.size
1649
1650 # num_scalar_leq_constr
1651 self.num_scalar_leq_constr = 0
1652 for constraint in problem.constraints:
1653 if isinstance(constraint, (Inequality, NonPos, NonNeg)):
1654 self.num_scalar_leq_constr += constraint.expr.size

Callers

nothing calls this directly

Calls 5

minClass · 0.85
maxClass · 0.50
variablesMethod · 0.45
constantsMethod · 0.45
parametersMethod · 0.45

Tested by

no test coverage detected