constitch.solving
index
/home/nicho/starcall-docs/constitch/solving.py

 
Modules
       
numpy
os
scipy
skimage
sklearn
sys
time

 
Classes
       
builtins.object
Solver
LinearSolver
HuberSolver
LPSolver
MAESolver
OptimalSolver
NeighborOutlierSolver
OutlierSolver
SelectionSolver
SpanningTreeSolver

 
class HuberSolver(LinearSolver)
    HuberSolver(**kwargs)
 
Solver that performs quantile regression instead of ordinary least squares
to solve the system of equations described by constraints. Equivalent to minimizing
the mean absolute error, this is much more outlier resistant that minimizing MSE
and should provide better results when there are erroneous constraints present.
This is identical to LinearSolver except that the linear model used is QuantileRegressor.
Any parameters passed to the constructor are forwared to the constructor of
sklearn.linear_model.QuantileRegressor. By default the L1 regularization constant
alpha=0 and fit_intercept=False, unless specified in the constructor.
 
 
Method resolution order:
HuberSolver
LinearSolver
Solver
builtins.object

Methods defined here:
__init__(self, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.

Methods inherited from LinearSolver:
make_constraint_matrix(self, constraints, initial_poses)
make_positions(self, initial_poses, poses)
score_func(self, constraint)
solve(self, constraints, initial_poses)
Solve the global positions for images given the constraints and estimated positions.
returns the xy position for each image, mapping the image index to the position
with a dictionary.
Additionally the constraints dictionary can be returned as the second return value, which
will replace the constraints in the composite with the ones returned, filtering outliers.
solve_matrix(self, solution_mat, solution_vals, initial_values)

Data descriptors inherited from Solver:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class LPSolver(LinearSolver)
    LPSolver(integral=True)
 
Solver that uses (integer) linear programming to find a solution minimizing the mean
absolute error of the system of equations specified by the constraints. This
differs from MAESolver as by using integer linear programming we can constrain
the resulting values to be integers, which removes any errors that might come from
rounding the solution values.
 
 
Method resolution order:
LPSolver
LinearSolver
Solver
builtins.object

Methods defined here:
__init__(self, integral=True)
Initialize self.  See help(type(self)) for accurate signature.
solve_matrix(self, solution_mat, solution_vals, initial_values)

Methods inherited from LinearSolver:
make_constraint_matrix(self, constraints, initial_poses)
make_positions(self, initial_poses, poses)
score_func(self, constraint)
solve(self, constraints, initial_poses)
Solve the global positions for images given the constraints and estimated positions.
returns the xy position for each image, mapping the image index to the position
with a dictionary.
Additionally the constraints dictionary can be returned as the second return value, which
will replace the constraints in the composite with the ones returned, filtering outliers.

Data descriptors inherited from Solver:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class LinearSolver(Solver)
    LinearSolver(model=None)
 
Solver that represents the constraints as an overconstrained system of equations, and
solves it using least squares.
 
 
Method resolution order:
LinearSolver
Solver
builtins.object

Methods defined here:
__init__(self, model=None)
Initialize self.  See help(type(self)) for accurate signature.
make_constraint_matrix(self, constraints, initial_poses)
make_positions(self, initial_poses, poses)
score_func(self, constraint)
solve(self, constraints, initial_poses)
Solve the global positions for images given the constraints and estimated positions.
returns the xy position for each image, mapping the image index to the position
with a dictionary.
Additionally the constraints dictionary can be returned as the second return value, which
will replace the constraints in the composite with the ones returned, filtering outliers.
solve_matrix(self, solution_mat, solution_vals, initial_values)

Data descriptors inherited from Solver:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class MAESolver(LinearSolver)
    MAESolver(**kwargs)
 
Solver that performs quantile regression instead of ordinary least squares
to solve the system of equations described by constraints. Equivalent to minimizing
the mean absolute error, this is much more outlier resistant that minimizing MSE
and should provide better results when there are erroneous constraints present.
This is identical to LinearSolver except that the linear model used is QuantileRegressor.
Any parameters passed to the constructor are forwared to the constructor of
sklearn.linear_model.QuantileRegressor. By default the L1 regularization constant
alpha=0 and fit_intercept=False, unless specified in the constructor.
 
 
Method resolution order:
MAESolver
LinearSolver
Solver
builtins.object

Methods defined here:
__init__(self, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.
score_func(self, constraint)

Methods inherited from LinearSolver:
make_constraint_matrix(self, constraints, initial_poses)
make_positions(self, initial_poses, poses)
solve(self, constraints, initial_poses)
Solve the global positions for images given the constraints and estimated positions.
returns the xy position for each image, mapping the image index to the position
with a dictionary.
Additionally the constraints dictionary can be returned as the second return value, which
will replace the constraints in the composite with the ones returned, filtering outliers.
solve_matrix(self, solution_mat, solution_vals, initial_values)

Data descriptors inherited from Solver:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class NeighborOutlierSolver(Solver)
    NeighborOutlierSolver(solver=None, testing_radius=3)
 

 
 
Method resolution order:
NeighborOutlierSolver
Solver
builtins.object

Methods defined here:
__init__(self, solver=None, testing_radius=3)
Initialize self.  See help(type(self)) for accurate signature.
get_touching(self, constraints, start_pair, max_dist)
returns a new constraints dict with only constraints within max_dist to the start pair
basically bfs
solve(self, constraints, initial_poses)
Solve the global positions for images given the constraints and estimated positions.
returns the xy position for each image, mapping the image index to the position
with a dictionary.
Additionally the constraints dictionary can be returned as the second return value, which
will replace the constraints in the composite with the ones returned, filtering outliers.

Data descriptors inherited from Solver:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class OptimalSolver(LinearSolver)
    OptimalSolver(model=None, loss_func=None)
 
Solver that solves the system of equations generated by LinearSolver by
minimizing an arbitrary loss function.
This solver uses the provided linear model, default LinearRegression,
to get initial positions then uses scipy.optimize.minimize to find the final
solution that minimizes the loss function.
By default the loss function used is mean absolute error, however if you are
looking to minimize on MAE you should use MAESolver as it is equivalent
and more efficient. Only use this model when there is not a dedicated
sklearn.linear_model or similar regressor that can be utilized with LinearSolver
for your loss function
 
 
Method resolution order:
OptimalSolver
LinearSolver
Solver
builtins.object

Methods defined here:
__init__(self, model=None, loss_func=None)
Initialize self.  See help(type(self)) for accurate signature.
loss(self, values, solution_mat, solution_vals)
solve_matrix(self, solution_mat, solution_vals, initial_values)

Methods inherited from LinearSolver:
make_constraint_matrix(self, constraints, initial_poses)
make_positions(self, initial_poses, poses)
score_func(self, constraint)
solve(self, constraints, initial_poses)
Solve the global positions for images given the constraints and estimated positions.
returns the xy position for each image, mapping the image index to the position
with a dictionary.
Additionally the constraints dictionary can be returned as the second return value, which
will replace the constraints in the composite with the ones returned, filtering outliers.

Data descriptors inherited from Solver:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class OutlierSolver(Solver)
    OutlierSolver(solver=None, outlier_threshold=1.5)
 

 
 
Method resolution order:
OutlierSolver
Solver
builtins.object

Methods defined here:
__init__(self, solver=None, outlier_threshold=1.5)
Initialize self.  See help(type(self)) for accurate signature.
solve(self, constraints, initial_poses)
Solve the global positions for images given the constraints and estimated positions.
returns the xy position for each image, mapping the image index to the position
with a dictionary.
Additionally the constraints dictionary can be returned as the second return value, which
will replace the constraints in the composite with the ones returned, filtering outliers.

Data descriptors inherited from Solver:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class SelectionSolver(Solver)
    Solver that finds the maximal set of constraints that all align with each other
 
 
Method resolution order:
SelectionSolver
Solver
builtins.object

Methods defined here:
__init__(self)
Initialize self.  See help(type(self)) for accurate signature.
find_cycles(self, nodes, edges)
find_cycles_node(self, node, edges)
solve(self, constraints, initial_poses)
Solve the global positions for images given the constraints and estimated positions.
returns the xy position for each image, mapping the image index to the position
with a dictionary.
Additionally the constraints dictionary can be returned as the second return value, which
will replace the constraints in the composite with the ones returned, filtering outliers.

Data descriptors inherited from Solver:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class Solver(builtins.object)
    Base class that takes in all the constraints of a composite
and solves them into global positions
 
  Methods defined here:
solve(self, constraints, initial_poses)
Solve the global positions for images given the constraints and estimated positions.
returns the xy position for each image, mapping the image index to the position
with a dictionary.
Additionally the constraints dictionary can be returned as the second return value, which
will replace the constraints in the composite with the ones returned, filtering outliers.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class SpanningTreeSolver(Solver)
    Solver that finds the maximum spanning tree, and uses it to solve for
global positions of all images
 
 
Method resolution order:
SpanningTreeSolver
Solver
builtins.object

Methods defined here:
__init__(self)
Initialize self.  See help(type(self)) for accurate signature.
solve(self, constraints, initial_poses)
Constructs a maximum spanning tree with Kruskals algorithm

Data descriptors inherited from Solver:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Functions
       
calc_box_score(scores, boxes, overlapping_indices, box, index)
constraint_scores(constraints, index)