Code Monkey home page Code Monkey logo

laptools's People

Contributors

jdmoorman avatar qinyichen avatar

Stargazers

 avatar  avatar  avatar

laptools's Issues

Pin versions of github actions dependencies

When calling an action from the marketplace such as actions/checkout@master, it is recommended practice to pin the action to a particular version such as actions/checkout@v1. This alleviates the risk of master introducing a breaking change or vulnerability.

The relevant workflow files are in the .github/workflow directory.

Make flake8 stop complaining

Description

A clear description of the bug

Expected Behavior

What did you expect to happen instead?

Reproduction

A minimal example that exhibits the behavior.

Environment

Any additional information about your environment

Change the project name to `lap-tools`

Use Case

Please provide a use case to help us understand your request in context

Solution

Please describe your ideal solution

Alternatives

Please describe any alternatives you've considered, even if you've dismissed them

Make isort stop complaining

Description

A clear description of the bug

Expected Behavior

What did you expect to happen instead?

Reproduction

A minimal example that exhibits the behavior.

Environment

Any additional information about your environment

Try numba to speed things up

Use Case

Please provide a use case to help us understand your request in context

Solution

Please describe your ideal solution

Alternatives

Please describe any alternatives you've considered, even if you've dismissed them

Decide on the public interface that will be used by uclasm.

  • The function that computes the solution to the linear assignment problem can be called laptools.lap.solve(cost_matrix)
  • Ideally, lap would take an optional argument of whether to return dual variables: laptools.lap.solve(cost_matrix, return_duals=True)
  • The function for computing the cost of the constrained assignment for every possible constraint should be called laptools.clap.costs(cost_matrix)
    • What do we do about the functions for solving problems with a row or column removed? Let's keep them a secret for now.

The output of clap.cost() does not match the expected result

Description

A clear description of the bug

Based on my understanding of the clap.costs() definition, it should solve a constrained linear assignment problem. Therefore, I believe the output of clap.costs() should be consistent with the output of the following naive_cost() function for the same input. However, I don't understand why my test code below fails to pass.

Reproduction

A minimal example that exhibits the behavior.

import numpy as np
from laptools import lap
from laptools import clap

def one_hot(idx, length):
    one_hot = np.zeros(length, dtype=np.bool)
    one_hot[idx] = True
    return one_hot

def naive_costs(cost_matrix):
    """An naive algorithm of solving all constraint LAPs. """
    n_rows, n_cols = cost_matrix.shape
    total_costs = np.full(cost_matrix.shape, np.inf)
    for i in range(n_rows):
        for j in range(n_cols):
            if cost_matrix[i,j] == np.inf:
                continue
            sub_row_ind = ~one_hot(i, n_rows)
            sub_col_ind = ~one_hot(j, n_cols)
            sub_cost_matrix = cost_matrix[sub_row_ind, :][:, sub_col_ind]
            row_idx, col_idx = lap.solve(sub_cost_matrix)
            sub_total_cost = sub_cost_matrix[row_idx, col_idx].sum()
            total_costs[i, j] = cost_matrix[i, j] + sub_total_cost
    return total_costs

cost = [[0. , np.inf, np.inf],
        [np.inf, 0. , 0.5],
        [np.inf, 1. , 0. ]]


cost = np.array(cost)
cost_clap1 = clap.costs(cost)
cost_clap2 = naive_costs(cost)
assert np.array_equal(cost_clap1, cost_clap2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.