File core.py
has 532 lines of code (exceeds 250 allowed). Consider refactoring. Open
""" Module for solving linear and quadratic optimization problems using
multiple open-source and commercials solvers.
:Author: Jonathan Karr <jonrkarr@gmail.com>
:Date: 2017-11-14
Function get_type
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def get_type(self):
""" Get the type of the model
Returns:
:obj:`ModelType`: model type
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function export
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def export(self, filename, format=None, solver=None):
""" Export a model to a file in one of these support formats
* **alp**: model with generic names in lp format, where the variable names are annotated to indicate the type and bounds of each variable
* **cbf**
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function convert
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def convert(self, options=None):
""" Generate a data structure for the model for another package
Args:
options (:obj:`SolveOptions`, optional): options
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Consider simplifying this complex logical expression. Open
if Solver.cbc in preferred_solvers and format in ['lp']:
from .solver import cbc
simplex = cbc.CbcModel(self).get_model()
simplex.writeLp(filename)
elif Solver.cbc in preferred_solvers and format in ['mps']:
Function solve
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def solve(self, options=None):
""" Solve the model
Args:
options (:obj:`SolveOptions`, optional): options
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function __init__
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, solver=Solver.cplex, tune=False, presolve=Presolve.off, precision=64,
Function __init__
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, status_code, status_message, value, primals, reduced_costs, duals):
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, name='', variables=None, objective_direction=ObjectiveDirection.minimize, objective_terms=None, constraints=None):
Avoid too many return
statements within this function. Open
return minos.MinosModel(self, options)
Avoid too many return
statements within this function. Open
return mosek.MosekModel(self, options)
Avoid too many return
statements within this function. Open
return xpress.XpressModel(self, options)
Avoid too many return
statements within this function. Open
return scipy.ScipyModel(self, options)
Avoid too many return
statements within this function. Open
return gurobi.GurobiModel(self, options)
Avoid too many return
statements within this function. Open
return quadprog.QuadprogModel(self, options)
Avoid too many return
statements within this function. Open
return soplex.SoplexModel(self, options)