Solution
- class flopt.Solution(variables, sort=True, *args, **kwargs)[source]
Solution Class
- Parameters:
variables (list of VarElement family) – variables which has no duplicate
- name
name of solution
- Type:
str
- type
- Type:
str
- _variables
variable array
- Type:
list of varElement
- _var_dict
key is name of variable, key is variable
- Type:
dict
Examples
Create a Solution which has Integer, Continuous and Binary Variables
>>> a = Variable(name="a", lowBound=0, upBound=1, cat="Integer") >>> b = Variable(name="b", lowBound=1, upBound=2, cat="Continuous") >>> c = Variable(name="c", cat="Binary") >>> sol = Solution([a, b, c])
Four arithmetic operations are supported between Solutions or between a Solution and a constant.
>>> sol1 = Solution([a, b]) >>> sol2 = Solution([a, c]) >>> sol_plus = sol1 + sol2 # (Solution + Solution or Solution + list) >>> sol_minus = sol1 - sol2 # (Solution - Solution or Solution - list) >>> sol_product = sol1 * 2 # (Solution * constant) >>> sol_divide = sol1 / 2 # (Solution / constant)
- dot(other)[source]
- Returns:
Inner product between the Solution and another Solution
- Return type:
float
- squaredNorm()[source]
- Returns:
Squared 2-norm of the solution as a vector in Euclid space
- Return type:
float