Giter VIP home page Giter VIP logo

scailist's Introduction

docs crates.io

ScAIList

This is rust implementation of the AIList algorithm as described here. The biggest difference is that this implementation dynamicaly determines the max number of components instead of capping at 10. One might call it a Scaled Augmented Interval List. It takes the log2 of the input element lengths to be the max number of components and then decomposes into that.

It seems to be very fast. As fast as rust-lapper in all easy cases with spread our intervals, and faster when things get nested. Benchmarks will be added as the interval_bakeoff project moves along.

Documentation

Crates.io

scailist's People

Contributors

seth-biorad avatar sstadick avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

scailist's Issues

found an error in the iterator implementation

I was using your code in an leetcode problem, and some test cases are bit off, I spend some time debugging, and found an logic error, where for some data sets, the iteration will yield repeated items.

I think what's happening is this:

  • first iteration yields result in this code path with self.offset == 0:

ScAIList/src/lib.rs

Lines 268 to 278 in 156f314

let interval = &self.inner.intervals[self.offset];
self.offset = match self.offset.checked_sub(1) {
Some(n) => n,
None => {
self.breaknow = true;
0
}
};
if interval.end > self.start {
return Some(interval);
}

  • the next iteration moves to the next component (which happens to be a "small" component), with self.offset still being 0:

ScAIList/src/lib.rs

Lines 280 to 288 in 156f314

} else {
while self.offset < comp_end {
let interval = &self.inner.intervals[self.offset];
self.offset += 1;
if interval.start < self.stop && interval.end > self.start {
return Some(interval);
}
}
}

  • thus the interval at offset 0 gets returned twice.

I tried to add this piece of code at L281, and it seems fixes the failure for the test cases, but I don't fully understand the algorithm, I can't be sure if this is correct or not. please take a look at it.

+   if self.find_offset {
+       self.find_offset = comp_start;
+       self.find_offset = 0;
+   }
    while self.offset < comp_end {
        let interval = &self.inner.intervals[self.offset];
        self.offset += 1;
        if interval.start < self.stop && interval.end > self.start {
            return Some(interval);
        }
    }

While condition uses wrong variable

Hey, great job on implementing AIList!

I just noticed one thing, could be nothing, but shouldn't it be

while j < min_cov_len && ...

instead of

while j < min_comp_len && ...

ScAIList/src/lib.rs

Lines 116 to 118 in 156f314

let mut cov = 1;
while j < min_comp_len && cov < min_cov && j + i < input_intervals.len() {
if input_intervals[j + i].end >= interval.end {

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.