Search Results

Search found 532 results on 22 pages for 'intervals'.

Page 1/22 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Minimizing the number of boxes that cover a given set of intervals

    - by fortran
    Hi, this is a question for the algorithms gurus out there :-) Let S be a set of intervals of the natural numbers that might overlap and b a box size. Assume that for each interval, the range is strictly less than b. I want to find the minimum set of intervals of size b (let's call it M) so all the intervals in S are contained in the intervals of M. Trivial example: S = {[1..4], [2..7], [3..5], [8..15], [9..13]} b = 10 M = {[1..10], [8..18]} // so ([1..4], [2..7], [3..5]) are inside [1..10] and ([8..15], [9..13]) are inside [8..18] I think a greedy algorithm might not work always, so if anybody knows of a solution of this problem (or a similar one that can be converted into), that would be great. Thanks!

    Read the article

  • Php - divide time period into equal intervals

    - by experc
    Hi! I am working on my php course project and for the past few days I have stucked at the point where I have to create php function which gets 5 parameters which represents information about the working time of some department - when the work starts/ends, when the lunchtime (or any other break) starts/ends and integer representing minutes into how small piecies we should divide time period. Besides - it's possible that there are not any breaks in the working time. The function should return all intervals from working time. function split_time_into_intervals($work_starts,$work_ends,$break_starts=null; $break_ends=null,$minutes_per_interval=60){ $intervals=array(); //all of the function code return $intervals; } So if I have the following parameters for the function function split_time_into_intervals("8:30","14:50","11:45"; "12:25"){ .. } I would like to retrieve the following array: $intervals[0]['starts']="8:30"; $intervals[0]['ends']="9:30"; $intervals[1]['starts']="9:30"; $intervals[1]['ends']="10:30"; $intervals[2]['starts']="10:30"; $intervals[2]['ends']="11:30"; $intervals[3]['starts']="11:30"; $intervals[3]['ends']="11:45"; //this interval was smaller than 60 minutes - because of the break (which starts at 11:45) $intervals[4]['starts']="12:25";//starts when the break ends $intervals[4]['ends']="13:25"; // interval is again 60 minutes $intervals[5]['starts']="13:25"; $intervals[5]['ends']="14:25"; $intervals[6]['starts']="14:25"; $intervals[6]['ends']="14:50"; //this period is shorter than 60 minutes - because work ends Any advises? I would apriciate any php (or C#) code regarding to this problem!

    Read the article

  • Grouping SQL results by continous time intervals (oracle sql)

    - by Kamil Zadora
    Hi I have following data in the table: ID-----startDate----endDate 5549 2008-05-01 4712-12-31 5567 2008-04-17 2008-04-30 1 5567 2008-05-01 2008-07-31 1 5567 2008-09-01 4712-12-31 2 5569 2008-05-01 2008-08-31 5569 2008-09-01 4712-12-31 5589 2008-04-18 2008-04-30 5589 2008-05-01 4712-12-31 5667 2008-05-01 4712-12-31 5828 2008-06-03 4712-12-31 5867 2008-06-03 4712-12-31 6167 2008-11-01 4712-12-31 6207 2008-07-01 4712-12-31 6228 2008-07-01 4712-12-31 6267 2008-07-14 4712-12-31 I am looking for I way to group the continuous time intervals for each id to return: ID, min(startDate), max(endDate), to have something like this in result for the bolded ID 5567 5567 2008-04-17 2008-07-31 5567 2008-09-01 4712-12-31 PL/SQL is also an option here :) Thanks,

    Read the article

  • two or more timer with different intervals with C#

    - by kaushal
    Hi guys, I have to a d.b entry in which the intervals are given, Suppose 1 timer tm_5 will check the entries after every 5 mins & the timer tm_10 will check the entries after every 10 mins, The problem is that it checks only the entries for tm_5 not for the tm_10. I am using C#.net 2005 & MS sql server 2005. Guys please me with full code beacuase I am new to this field.. Thnks a lot... Kaushal

    Read the article

  • Calculating the union of 2 longitudal intervals (that may wrap around 180 degrees)

    - by timpatt
    The story: I have a LatLongBounds class that represents an area on the surface of the earth by a latitudinal interval (bounded by north & south - not important to this question) and a longitudinal interval (bounded by east and west; both normalized to a range [-180, 180] - negative being a westerly direction). In order to be able to represent an area that straddles the 180 degree meridian the value of west may be set to be greater than east (eg. the range west = 170, east = -170 will straddle said meridian). In effect the longitudinal interval may wrap around at 180 degrees (or equivalently -180 degrees). My Question: Does anyone have any suggestions as to how I can calculate the union of two longitudinal intervals that may wrap around at 180 degrees. Thanks.

    Read the article

  • javascript switch using intervals

    - by Fernando SBS
    Can I use intervals in a switch statement? Like switch (parseInt(troops[i])) { case <10: editbox.style.fontSize = "13px"; break; case <100: editbox.style.fontSize = "12px"; break; case <1000: editbox.style.fontSize = "8px"; editbox.size = 3; //editbox.style.width = "18px"; break; default: editbox.style.fontSize = "10px"; } ???

    Read the article

  • rsnapshot intervals in configuration file…

    - by Patrick
    A simple question about rsnapshot. In order to perform daily backups I'm going to add lines to cron in my Ubuntu. Then, why do I have also these lines in the rsnapshot.conf ? ######################################### # BACKUP INTERVALS # # Must be unique and in ascending order # # i.e. hourly, daily, weekly, etc. # ######################################### interval hourly 6 interval daily 7 interval weekly 4 #interval monthly 3 If I use cron, should I disable them ? thanks ps. I've just realized that in the crontab I still have "hourly" and "daily". Should I then uncomment only the one I use in the crontab ? And what's the point to specify hourly if it is already specified in cron ? I'm a bit confused. # crontab -e 0 */4 * * * /usr/local/bin/rsnapshot hourly 30 23 * * * /usr/local/bin/rsnapshot daily

    Read the article

  • "Backup Intervals" in rsnapshot.conf?

    - by Patrick
    A simple question about rsnapshot. In order to perform daily backups I'm going to add lines to cron in my Ubuntu. Then, why do I have also these lines in the rsnapshot.conf ? ######################################### # BACKUP INTERVALS # # Must be unique and in ascending order # # i.e. hourly, daily, weekly, etc. # ######################################### interval hourly 6 interval daily 7 interval weekly 4 #interval monthly 3 If I use cron, should I disable them ? thanks ps. I've just realized that in the crontab I still have "hourly" and "daily". Should I then uncomment only the one I use in the crontab ? And what's the point to specify hourly if it is already specified in cron ? I'm a bit confused. # crontab -e 0 */4 * * * /usr/local/bin/rsnapshot hourly 30 23 * * * /usr/local/bin/rsnapshot daily

    Read the article

  • Algorithms for finding the intersections of intervals

    - by tomwu
    I am wondering how I can find the number of intervals that intersect with the ones before it. for the intervals [2, 4], [1, 6], [5, 6], [0, 4], the output should be 2. from [2,4] [5,6] and [5,6] [0,4]. So now we have 1 set of intervals with size n all containing a point a, then we add another set of intervals size n as well, and all of the intervals are to the right of a. Can you do this in O(nlgn) and O(nlg^2n)?

    Read the article

  • Adding objects to the environment at timed intervals

    - by david
    I am using an ArrayList to handle objects and at each interval of 120 frames, I am adding a new object of the same type at a random location along the z-axis of 60. The problem is, it doesn't add just 1. It depends on how many are in the list. If I kill the Fox before the time interval when one is supposed to spawn comes, then no Fox will be spawned. If I don't kill any foxes, it grows exponentially. I only want one Fox to be added every 120 frames. This problem never happened before when I created new ones and added them to the environment. Any insights? Here is my code: /**** FOX CLASS ****/ import env3d.EnvObject; import java.util.ArrayList; public class Fox extends Creature { private int frame = 0; public Fox(double x, double y, double z) { super(x, y, z); // Must use the mutator as the fields have private access // in the parent class setTexture("models/fox/fox.png"); setModel("models/fox/fox.obj"); setScale(1.4); } public void move(ArrayList<Creature> creatures, ArrayList<Creature> dead_creatures, ArrayList<Creature> new_creatures) { frame++; setX(getX()-0.2); setRotateY(270); if (frame > 120) { Fox f = new Fox(60, 1, (int)(Math.random()*28)+1); new_creatures.add(f); frame = 0; } for (Creature c : creatures) { if (this.distance(c) < this.getScale()+c.getScale() && c instanceof Tux) { dead_creatures.add(c); } } for (Creature c : creatures) { if (c.getX() < 1 && c instanceof Fox) { dead_creatures.add(c); } } } } import env3d.Env; import java.util.ArrayList; import org.lwjgl.input.Keyboard; /** * A predator and prey simulation. Fox is the predator and Tux is the prey. */ public class Game { private Env env; private boolean finished; private ArrayList<Creature> creatures; private KingTux king; private Snowball ball; private int tuxcounter; private int kills; /** * Constructor for the Game class. It sets up the foxes and tuxes. */ public Game() { // we use a separate ArrayList to keep track of each animal. // our room is 50 x 50. creatures = new ArrayList<Creature>(); for (int i = 0; i < 10; i++) { creatures.add(new Tux((int)(Math.random()*10)+1, 1, (int)(Math.random()*28)+1)); } for (int i = 0; i < 1; i++) { creatures.add(new Fox(60, 1, (int)(Math.random()*28)+1)); } king = new KingTux(25, 1, 35); ball = new Snowball(-400, -400, -400); } /** * Play the game */ public void play() { finished = false; // Create the new environment. Must be done in the same // method as the game loop env = new Env(); // Make the room 50 x 50. env.setRoom(new Room()); // Add all the animals into to the environment for display for (Creature c : creatures) { env.addObject(c); } for (Creature c : creatures) { if (c instanceof Tux) { tuxcounter++; } } env.addObject(king); env.addObject(ball); // Sets up the camera env.setCameraXYZ(30, 50, 55); env.setCameraPitch(-63); // Turn off the default controls env.setDefaultControl(false); // A list to keep track of dead tuxes. ArrayList<Creature> dead_creatures = new ArrayList<Creature>(); ArrayList<Creature> new_creatures = new ArrayList<Creature>(); // The main game loop while (!finished) { if (env.getKey() == 1 || tuxcounter == 0) { finished = true; } env.setDisplayStr("Tuxes: " + tuxcounter, 15, 0); env.setDisplayStr("Kills: " + kills, 140, 0); processInput(); ball.move(); king.check(); // Move each fox and tux. for (Creature c : creatures) { c.move(creatures, dead_creatures, new_creatures); } for (Creature c : creatures) { if (c.distance(ball) < c.getScale()+ball.getScale() && c instanceof Fox) { dead_creatures.add(c); ball.setX(-400); ball.setY(-400); ball.setZ(-400); kills++; } } // Clean up of the dead tuxes. for (Creature c : dead_creatures) { if (c instanceof Tux) { tuxcounter--; } env.removeObject(c); creatures.remove(c); } for (Creature c : new_creatures) { creatures.add(c); env.addObject(c); } // we clear the ArrayList for the next loop. We could create a new one // every loop but that would be very inefficient. dead_creatures.clear(); new_creatures.clear(); // Update display env.advanceOneFrame(); } // Just a little clean up env.exit(); } private void processInput() { int keyDown = env.getKeyDown(); int key = env.getKey(); if (keyDown == 203) { king.setX(king.getX()-1); } else if (keyDown == 205) { king.setX(king.getX()+1); } if (ball.getX() <= -400 && key == Keyboard.KEY_S) { ball.setX(king.getX()); ball.setY(king.getY()); ball.setZ(king.getZ()); } } /** * Main method to launch the program. */ public static void main(String args[]) { (new Game()).play(); } } /**** CREATURE CLASS ****/ /* (Parent class to Tux, Fox, and KingTux) */ import env3d.EnvObject; import java.util.ArrayList; abstract public class Creature extends EnvObject { private int frame; private double rand; /** * Constructor for objects of class Creature */ public Creature(double x, double y, double z) { setX(x); setY(y); setZ(z); setScale(1); rand = Math.random(); } private void randomGenerator() { rand = Math.random(); } public void move(ArrayList<Creature> creatures, ArrayList<Creature> dead_creatures, ArrayList<Creature> new_creatures) { frame++; if (frame > 12) { randomGenerator(); frame = 0; } // if (rand < 0.25) { // setX(getX()+0.3); // setRotateY(90); // } else if (rand < 0.5) { // setX(getX()-0.3); // setRotateY(270); // } else if (rand < 0.75) { // setZ(getZ()+0.3); // setRotateY(0); // } else if (rand < 1) { // setZ(getZ()-0.3); // setRotateY(180); // } if (rand < 0.5) { setRotateY(getRotateY()-7); } else if (rand < 1) { setRotateY(getRotateY()+7); } setX(getX()+Math.sin(Math.toRadians(getRotateY()))*0.5); setZ(getZ()+Math.cos(Math.toRadians(getRotateY()))*0.5); if (getX() < getScale()) setX(getScale()); if (getX() > 50-getScale()) setX(50 - getScale()); if (getZ() < getScale()) setZ(getScale()); if (getZ() > 50-getScale()) setZ(50 - getScale()); // The move method now handles collision detection if (this instanceof Fox) { for (Creature c : creatures) { if (c.distance(this) < c.getScale()+this.getScale() && c instanceof Tux) { dead_creatures.add(c); } } } } } The rest of the classes are a bit trivial to this specific problem.

    Read the article

  • Execute code at specific intervals, only once?

    - by Mathias Lykkegaard Lorenzen
    I am having an issue with XNA, where I want to execute some code in my Update method, but only at a given interval, and only once. I would like to avoid booleans to check if I've already called it once, if possible. My code is here: if ((gameTime.TotalGameTime.TotalMilliseconds % 500) == 0) { Caret.Visible = !Caret.Visible; } As you may have guessed, it's for a TextBox control, to animate the caret between invisible and visible states. I just have reason to believe that it is called twice or maybe even 3 times in a single update-call, which is bad, and makes it look unstable and jumpy.

    Read the article

  • TSQL Challenge 31 - Managing multiple overlapping date intervals.

    This challenge is adapted from a budgeting system used in a large company to perform quarterly analysis of what kind of work will be done and where it will be done. Project Managers make plans and the estimated hours of work required from each employee each month end up in a central database. Top managers want to see a synthesis of this by department and profession

    Read the article

  • C# Running several tasks at different intervals

    - by Nir
    A design question: I'd like to build a Windows service that executes different commands at different intervals. For simplicity's sake, let's say I want to run some batch files. The input it gets is a list of files and the intervals at which to execute. For example: a.bat - 4 minutes b.bat - 1 minute c.bat - 1 minute d.bat - 2 minutes I was thinking about sorting them according to intervals, and then setting a timer for each of the intervals. I'm not sure this is the best solution and I'd be happy to hear some feedbacks. Thanks!

    Read the article

  • numpy arange with multiple intervals

    - by Heiko Westermann
    Hi, i have an numpy array which represents multiple x-intervals of a function: In [137]: x_foo Out[137]: array([211, 212, 213, 214, 215, 216, 217, 218, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950]) as you can see, in x_foo are two intervals: one from 211 to 218, and one from 940 to 950. these are intervals, which i want to interpolate with scipy. for this, i need to adjust the spacing, e.g "211.0 211.1 211.2 ..." which you would normaly do with: arange( x_foo[0], x_foo[-1], 0.1 ) in the case of multiple intervals, this is not possible. so heres my question: is there a numpy-thonic way to do this in array-style? or do i need to write a function which loops over the whole array and split if the difference is 1? thanks!

    Read the article

  • Monitoring instantaneous network throughput at one second intervals?

    - by Shaddi
    For a testing setup I have, I need to monitor the throughput through a "router"* at regular intervals of around 5 seconds or less (sub-second intervals would be very nice, but not required). Ideally, I would be able to generate a file which contained both the number of bytes and packets seen during each interval. I will eventually be generating a time-series of throughput from this data. On a previous setup using an older version of FreeBSD, there was a tool called "bpfmon" which gave me this information. However, I need to do this under a modern version of Linux (namely, Ubuntu 11.04). I have looked at both iptraf and iftop, but these do not appear to provide the resolution I need, nor do they seem to easily allow scraping the data I need. I understand iptables statistics may be able to give me what I'm after, but the examples I've seen of this seem to rely on repeatedly reading and resetting traffic counters, which seems like it could give inaccurate as read/reset is not an atomic operation. I already capture a tcpdump trace of the traffic I'm interested in on the link I want to monitor, so I am open to approaches which simply parse that. I feel like this must be a common problem though, so I am hoping there will be a standard "best practice" tool for accomplishing this. *I say "router" in quotes because I am really talking about a machine with two bridged NICs through which all the traffic I'm interested in passes.

    Read the article

  • Calculating confidence intervals for a non-normal distribution

    - by Josiah
    Hi all, First, I should specify that my knowledge of statistics is fairly limited, so please forgive me if my question seems trivial or perhaps doesn't even make sense. I have data that doesn't appear to be normally distributed. Typically, when I plot confidence intervals, I would use the mean +- 2 standard deviations, but I don't think that is acceptible for a non-uniform distribution. My sample size is currently set to 1000 samples, which would seem like enough to determine if it was a normal distribution or not. I use Matlab for all my processing, so are there any functions in Matlab that would make it easy to calculate the confidence intervals (say 95%)? I know there are the 'quantile' and 'prctile' functions, but I'm not sure if that's what I need to use. The function 'mle' also returns confidence intervals for normally distributed data, although you can also supply your own pdf. Could I use ksdensity to create a pdf for my data, then feed that pdf into the mle function to give me confidence intervals? Also, how would I go about determining if my data is normally distributed. I mean I can currently tell just by looking at the histogram or pdf from ksdensity, but is there a way to quantitatively measure it? Thanks!

    Read the article

  • Interval tree algorithm that supports merging of intervals with no overlap

    - by Dave Griffiths
    I'm looking for an interval tree algorithm similar to the red-black interval tree in CLR but that supports merging of intervals by default so that there are never any overlapping intervals. In other words if you had a tree containing two intervals [2,3] and [5,6] and you added the interval [4,4], the result would be a tree containing just one interval [2,6]. Thanks Update: the use case I'm considering is calculating transitive closure. Interval sets are used to store the successor sets because they have been found to be quite compact. But if you represent interval sets just as a linked list I have found that in some situations they can become quite large and hence so does the time required to find the insertion point. Hence my interest in interval trees. Also there may be quite a lot of merging one tree with another (i.e. a set OR operation) - if both trees are large then it may be better to create a new tree using inorder walks of both trees rather than repeated insertions of each interval.

    Read the article

  • What is an efficient method for partitioning and aggregating intervals from timestamped rows in a da

    - by mattrepl
    From a data frame with timestamped rows (strptime results), what is the best method for aggregating statistics for intervals? Intervals could be an hour, a day, etc. I've found the aggregate function, but that doesn't help with assigning each row to an interval. I'm planning on adding a column to the data frame that denotes interval and using that with aggregate, but if there's a better solution it'd be great to hear it. Thanks for any pointers!

    Read the article

  • Create Google Maps screenshots at regular intervals

    - by Dave Jarvis
    Background People are concerned that building a pipeline to the West Coast of Canada will increase the number of oil tankers, thus increasing the probability of a major oil spill, thereby creating an environmental catastrophe. The AIS Live Ships Map website captures real-time Marine Traffic updates using a Google Maps interface. While it is possible to obtain data from an AIS data feed, often the feeds are either pay-for-use, or otherwise encumbered with license restrictions. Problem The AIS Live Ships website presents a map in the browser: The map above has had its location interactively changed to focus on the area in question: the northern straight of Vancouver Island. Question How would you create a service that captures the map every 30 minutes and that could run, with neither user-intervention nor a significant memory footprint, for a few years? Idea #1 Create a virtual machine. Install and run a light-weight browser. Use Shutter to take captures at regular intervals. Idea #2 Use Python's Ghost Webkit to automate the captures. Thank you!

    Read the article

  • iPod Touch G4 disconnects from Belkin N+ Router at random intervals

    - by leeand00
    I have an iPod Touch G4 and a Belkin N+ Router F5D8235-4 v2, and for some reason the iPod Touch disconnects from the router at random intervals. Checking the settings in the iPod, it will read that it is still connected to the router, but before I can access the internet again, I have to turn on Airplane mode and then turn it off again to get any program to work with the Internet again. I've tried upgrading the firmware in the router, but that also doesn't seem to help. I'm using the wiresless mode 802.11b&802.11g&802.11n in the 20/40MHz frequency. Is there any way of fixing this issue? It doesn't happen with any of the other devices that are connected to the router. This post has been cross-posted here

    Read the article

  • rsnapshot intervals in configuration file...

    - by Patrick
    A simple question about rsnapshot. In order to perform daily backups I'm going to add lines to cron in my Ubuntu. Then, why do I have also these lines in the rsnapshot.conf ? ######################################### # BACKUP INTERVALS # # Must be unique and in ascending order # # i.e. hourly, daily, weekly, etc. # ######################################### interval hourly 6 interval daily 7 interval weekly 4 #interval monthly 3 If I use cron, should I disable them ? thanks ps. I've just realized that in the crontab I still have "hourly" and "daily". Should I then uncomment only the one I use in the crontab ? And what's the point to specify hourly if it is already specified in cron ? I'm a bit confused. # crontab -e 0 */4 * * * /usr/local/bin/rsnapshot hourly 30 23 * * * /usr/local/bin/rsnapshot daily

    Read the article

  • Tomcat6 getting crashed at regular intervals installed in Ubuntu

    - by Milesh Rout
    I have installed Tomcat6 in Ubuntu OS and when I run my web application the server gets crashed at regular intervals. I have tried a lot but not getting the solution. I have increased the memory upto 2048mb but still getting such error. Following is the error I am getting. Any help would be really appreciated. org.apache.tomcat.util.http.Parameters processParametersINFO: Invalid chunk starting at byte [312] and ending at byte [312] with a value of [null] ignoredException in thread "Timer-1" Exception in thread "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0" Exception in thread "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2" Exception in thread "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1" Exception in thread "Timer-2" Exception in thread "http-8080-4" Exception in thread "http-8080-8" Exception in thread "http-8080-17" Exception in thread "org.hibernate.cache.StandardQueryCache.data" Exception in thread "org.hibernate.cache.UpdateTimestampsCache.data" Exception in thread "org.hibernate.cache.StandardQueryCache.data" Exception in thread "org.hibernate.cache.StandardQueryCache.data" Exception in thread "org.hibernate.cache.UpdateTimestampsCache.data" Exception in thread "org.hibernate.cache.StandardQueryCache.data" Exception in thread "org.hibernate.cache.StandardQueryCache.data" Exception in thread "org.hibernate.cache.UpdateTimestampsCache.data" Exception in thread "com.safenet.usermgmt.User.data" Exception in thread "http-8080-7" Exception in thread "http-8080-12" Exception in thread "http-8080-16" Exception in thread "http-8080-14" Exception in thread "http-8080-13" Exception in thread "http-8080-15" Exception in thread "http-8080-6" OpenJDK Client VM warning: Exception java.lang.OutOfMemoryError occurred dispatching signal SIGTERM to handler- the VM may need to be forcibly terminated

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >