Search Results

Search found 2372 results on 95 pages for 'relational theory'.

Page 21/95 | < Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >

  • Adjusting for compass wrap around in a navigation application

    - by chris12892
    I have a application where I am guiding a vehicle on compass headings and I am having an issue when the vehicle is crossing from 360 degrees to 0 degrees. In this case, there are no smarts in the control loop to compute that the nearest way to turn to follow a heading. For example, if the vehicle is instructed to follow a heading of 360 degrees, it will inevitably drifts a few degrees to ether side. If it drifts over to 0+ degrees, the control loop will go nuts and try to steer the vehicle all the way around to get it to 360 degrees again. Is there a graceful way to deal with this? The way the navigate function is written, I use an external PID controller class and I calculate the heading like this: lock (steering) { if (!Engaged) { return; } double mv = 90 + Trim + pidController.CalculateCorrection(flyHeading, currentHeading); steering.Degree = mv; } Thanks!

    Read the article

  • SRAM Cell Diagram - Can someone explain this a bit more clearly? ( From COMP1917 @ UNSW: Lecture 2 o

    - by Kristina
    I've begun watching a series of first year lectures from the University of New South Wales (UNSW) in Australia, and I'm a bit perplexed by the instructors explanation of how an SRAM gate works. I realize this isn't exactly "programming-related" but since it comes from a series of lectures relating to computing and programming, I thought StackOverflow may be able to help (reddit failed me entirely). In this lecture beginning at around 32:12, Richard (the lecturer) tries to explain how a "latch gate" works within SRAM. Although his students seem to keep up, I feel I'm missing something crucial which is preventing the concept from really "clicking" in my brain. For convenience, I've added the image from the video below: Thanks in advance for any help you can provide, but if this question doesn't fit your view of "programming-related" could you please provide an alternate forum for this in a comment when you cast your close vote? Thanks!

    Read the article

  • Creating relationship between two model instances

    - by Lowgain
    This is probably pretty simple, but here: Say I've got two models, Thing and Tag class Thing < ActiveRecord::Base has_and_belongs_to_many :tags end class Tag < ActiveRecord::Base has_and_belongs_to_many :things end And I have an instance of each. I want to link them. Can I do something like: @thing = Thing.find(1) @tag = Tag.find(1) @thing.tags.add(@tag) If not, what is the best way to do this? Thanks!

    Read the article

  • Enumerating all hamiltonian paths from start to end vertex in grid graph

    - by Eric
    Hello, I'm trying to count the number of Hamiltonian paths from a specified start vertex that end at another specified vertex in a grid graph. Right now I have a solution that uses backtracking recursion but is incredibly slow in practice (e.g. O(n!) / 3 hours for 7x7). I've tried a couple of speedup techniques such as maintaining a list of reachable nodes, making sure the end node is still reachable, and checking for isolated nodes, but all of these slowed my solution down. I know that the problem is NP-complete, but it seems like some reasonable speedups should be achievable in the grid structure. Since I'm trying to count all the paths, I'm sure that the search must be exhaustive, but I'm having trouble figuring out how to prune out paths that aren't promising. Does anyone have some suggestions for speeding the search up? Or an alternate search algorithm?

    Read the article

  • circles and triangles problem

    - by Faken
    Hello everyone, I have an interesting problem here I've been trying to solve for the last little while: I have 3 circles on a 2D xy plane, each with the same known radius. I know the coordinates of each of the three centers (they are arbitrary and can be anywhere). What is the largest triangle that can be drawn such that each vertice of the triangle sits on a separate circle, what are the coordinates of those verticies? I've been looking at this problem for hours and asked a bunch of people but so far only one person has been able to suggest a plausible solution (though i have no way of proving it). The solution that we have come up with involves first creating a triangle about the three circle centers. Next we look at each circle individually and calculate the equation of a line that passes through the circle's center and is perpendicular to the opposite edge. We then calculate two intersection points of the circle. This is then done for the next two circles with a result of 6 points. We iterate over the 8 possible 3 point triangles that these 6 points create (the restriction is that each point of the big triangle must be on a separate circle) and find the maximum size. The results look reasonable (at least when drawn out on paper) and it passes the special case of when the centers of the circles all fall on a straight line (gives a known largest triangle). Unfortunate i have no way of proving this is correct or not. I'm wondering if anyone has encountered a problem similar to this and if so, how did you solve it? Note: I understand that this is mostly a math question and not programming, however it is going to be implemented in code and it must be optimized to run very fast and efficient. In fact, I already have the above solution in code and tested to be working, if you would like to take a look, please let me know, i chose not to post it because its all in vector form and pretty much impossible to figure out exactly what is going on (because it's been condensed to be more efficient). Lastly, yes this is for school work, though it is NOT a homework question/assignment/project. It's part of my graduate thesis (abet a very very small part, but still technically is part of it). Thanks for your help.

    Read the article

  • The limits of parallelism

    - by psihodelia
    Is it possible to solve a problem of O(n!) complexity within a reasonable time given infinite number of processing units and infinite space? The typical example of O(n!) problem is brute-force search: trying all permutations (ordered combinations).

    Read the article

  • Fastest way to perform subset test operation on a large collection of sets with same domain

    - by niktech
    Assume we have trillions of sets stored somewhere. The domain for each of these sets is the same. It is also finite and discrete. So each set may be stored as a bit field (eg: 0000100111...) of a relatively short length (eg: 1024). That is, bit X in the bitfield indicates whether item X (of 1024 possible items) is included in the given set or not. Now, I want to devise a storage structure and an algorithm to efficiently answer the query: what sets in the data store have set Y as a subset. Set Y itself is not present in the data store and is specified at run time. Now the simplest way to solve this would be to AND the bitfield for set Y with bit fields of every set in the data store one by one, picking the ones whose AND result matches Y's bitfield. How can I speed this up? Is there a tree structure (index) or some smart algorithm that would allow me to perform this query without having to AND every stored set's bitfield? Are there databases that already support such operations on large collections of sets?

    Read the article

  • Step by Step / Deep explain: The Power of (Co)Yoneda (preferably in scala) through Coroutines

    - by Mzk
    some background code /** FunctorStr: ? F[-]. (? A B. (A -> B) -> F[A] -> F[B]) */ trait FunctorStr[F[_]] { self => def map[A, B](f: A => B): F[A] => F[B] } trait Yoneda[F[_], A] { yo => def apply[B](f: A => B): F[B] def run: F[A] = yo(x => x) def map[B](f: A => B): Yoneda[F, B] = new Yoneda[F, B] { def apply[X](g: B => X) = yo(f andThen g) } } object Yoneda { implicit def yonedafunctor[F[_]]: FunctorStr[({ type l[x] = Yoneda[F, x] })#l] = new FunctorStr[({ type l[x] = Yoneda[F, x] })#l] { def map[A, B](f: A => B): Yoneda[F, A] => Yoneda[F, B] = _ map f } def apply[F[_]: FunctorStr, X](x: F[X]): Yoneda[F, X] = new Yoneda[F, X] { def apply[Y](f: X => Y) = Functor[F].map(f) apply x } } trait Coyoneda[F[_], A] { co => type I def fi: F[I] def k: I => A final def map[B](f: A => B): Coyoneda.Aux[F, B, I] = Coyoneda(fi)(f compose k) } object Coyoneda { type Aux[F[_], A, B] = Coyoneda[F, A] { type I = B } def apply[F[_], B, A](x: F[B])(f: B => A): Aux[F, A, B] = new Coyoneda[F, A] { type I = B val fi = x val k = f } implicit def coyonedaFunctor[F[_]]: FunctorStr[({ type l[x] = Coyoneda[F, x] })#l] = new CoyonedaFunctor[F] {} trait CoyonedaFunctor[F[_]] extends FunctorStr[({type l[x] = Coyoneda[F, x]})#l] { override def map[A, B](f: A => B): Coyoneda[F, A] => Coyoneda[F, B] = x => apply(x.fi)(f compose x.k) } def liftCoyoneda[T[_], A](x: T[A]): Coyoneda[T, A] = apply(x)(a => a) } Now I thought I understood yoneda and coyoneda a bit just from the types – i.e. that they quantify / abstract over map fixed in some type constructor F and some type a, to any type B returning F[B] or (Co)Yoneda[F, B]. Thus providing map fusion for free (? is this kind of like a cut rule for map ?). But I see that Coyoneda is a functor for any type constructor F regardless of F being a Functor, and that I don't fully grasp. Now I'm in a situation where I'm trying to define a Coroutine type, (I'm looking at https://www.fpcomplete.com/school/to-infinity-and-beyond/pick-of-the-week/coroutines-for-streaming/part-2-coroutines for the types to get started with) case class Coroutine[S[_], M[_], R](resume: M[CoroutineState[S, M, R]]) sealed trait CoroutineState[S[_], M[_], R] object CoroutineState { case class Run[S[_], M[_], R](x: S[Coroutine[S, M, R]]) extends CoroutineState[S, M, R] case class Done[R](x: R) extends CoroutineState[Nothing, Nothing, R] class CoroutineStateFunctor[S[_], M[_]](F: FunctorStr[S]) extends FunctorStr[({ type l[x] = CoroutineState[S, M, x]})#l] { override def map[A, B](f : A => B) : CoroutineState[S, M, A] => CoroutineState[S, M, B] = { ??? } } } and I think that if I understood Coyoneda better I could leverage it to make S & M type constructors functors way easy, plus I see Coyoneda potentially playing a role in defining recursion schemes as the functor requirement is pervasive. So how could I use coyoneda to make type constructors functors like for example coroutine state? or something like a Pause functor ?

    Read the article

  • How to add an additional field to a queryset?

    - by Mark
    I've got a list of affiliates (users who have referred someone to the site): affiliates = User.objects.annotate(referral_count=Count('referrals')).filter(referral_count__gt=0) And a count of the number of users each affiliate has referred within a time frame: new_users = User.objects.filter(date_joined__gt=sd, date_joined__lte=ed) new_referrals = User.objects.filter(referrals__user__in=new_users).annotate(referral_count=Count('referrals')) How can I do something like new_referrals['affiliate.username'].referral_count from within my template? Note that this is not just a syntax issue, I also need to index new_referrals somehow so that I'm able to do this. Either this, or if I can somehow add a new_referral_count to the first query, that'd work too.

    Read the article

  • Mapping enum to a table with hibernate annotation

    - by Thierry-Dimitri Roy
    I have a table DEAL and a table DEAL_TYPE. I would like to map this code: public class Deal { DealType type; } public enum DealType { BASE("Base"), EXTRA("Extra"); } The problem is that the data already exist in the database. And I'm having a hard time mapping the classes to the database. The database looks something like that: TABLE DEAL { Long id; Long typeId; } TABLE DEAL_TYPE { Long id; String text; } I know I could use a simple @OneToMany relationship from deal to deal type, but I would prefer to use an enum. Is this possible? I almost got it working by using a EnumType.ORDINAL type. But unfortunately, my IDs in my deal type table are not sequential, and do not start at 1. Any suggestions?

    Read the article

  • Is it possible to "learn" a regular expression by user-provided examples?

    - by DR
    Is it possible to "learn" a regular expression by user-provided examples? To clarify: I do not want to learn regular expressions. I want to create a program which "learns" a regular expression from examples which are interactively provided by a user, perhaps by selecting parts from a text or selecting begin or end markers. Is it possible? Are there algorithms, keywords, etc. which I can Google for? EDIT: Thank you for the answers, but I'm not interested in tools which provide this feature. I'm looking for theoretical information, like papers, tutorials, source code, names of algorithms, so I can create something for myself.

    Read the article

  • Hibernate - EhCache - Which region to Cache associations/sets/collections ??

    - by lifeisnotfair
    Hi all, I am a newcomer to hibernate. It would be great if someone could comment over the following query that i have: Say i have a parent class and each parent has multiple children. So the mapping file of parent class would be something like: parent.hbm.xml <hibernate-mapping > <class name="org.demo.parent" table="parent" lazy="true"> <cache usage="read-write" region="org.demo.parent"/> <id name="id" column="id" type="integer" length="10"> <generator class="native"> </generator> </id> <property name="name" column="name" type="string" length="50"/> <set name="children" lazy="true"> <cache usage="read-write" region="org.demo.parent.children" /> <key column="parent_id"/> <one-to-many class="org.demo.children"/> </set> </class> </hibernate-mapping> children.hbm.xml <hibernate-mapping > <class name="org.demo.children" table="children" lazy="true"> <cache usage="read-write" region="org.demo.children"/> <id name="id" column="id" type="integer" length="10"> <generator class="native"> </generator> </id> <property name="name" column="name" type="string" length="50"/> <many-to-one name="parent_id" column="parent_id" type="integer" length="10" not-null="true"/> </class> </hibernate-mapping> So for the set children, should we specify the region org.demo.parent.children where it should cache the association or should we use the cache region of org.demo.children where the children would be getting cached. I am using EHCache as the 2nd level cache provider. I tried to search for the answer to this question but couldnt find any answer in this direction. It makes more sense to use org.demo.children but I dont know in which scenarios one should use a separate cache region for associations/sets/collections as in the above case. Kindly provide your inputs also let me know if I am not clear in my question. Thanks all.

    Read the article

  • rails: has_many :through + polymorphism validation?

    - by ramonrails
    I am trying to achieve this. Any hints? A project has many users through join model A user has many projects through join model Admin class inherits User class. It also has some Admin specific stuff. Admin like inheritance for Supervisor and Operator Project has one Admin, One supervisor and many operators. Now I want to 1. submit data for project, admin, supervisor and operator in a single project form 2. validate all and show errors on the project form. Project has_many :users, :through = :projects_users User has_many :projects, :through = :projects_users ProjectsUser = :id integer, :user_id :integer, :project_id :integer, :user_type :string ProjectUser belongs_to :project, belongs_to :user, :polymorphic = true Admin < User Supervisor < User Operator < User Is the approach correct? Any and all suggestions are welcome.

    Read the article

  • Getting tree construction with ANTLR

    - by prosseek
    As asked and answered in http://stackoverflow.com/questions/2999755/removing-left-recursion-in-antlr , I could remove the left recursion E - E + T|T T - T * F|F F - INT | ( E ) After left recursion removal, I get the following one E - TE' E' - null | + TE' T - FT' T' - null | * FT' Then, how to make the tree construction with the modified grammar? With the input 1+2, I want to have a tree ^('+' ^(INT 1) ^(INT 2)). Or similar. grammar T; options { output=AST; language=Python; ASTLabelType=CommonTree; } start : e - e ; e : t ep - ??? ; ep : | '+' t ep - ??? ; t : f tp - ??? ; tp : | '*' f tp - ??? ; f : INT | '(' e ')' - e ; INT : '0'..'9'+ ; WS: (' '|'\n'|'\r')+ {$channel=HIDDEN;} ;

    Read the article

  • Purpose of singletons in programming

    - by thecoshman
    This is admittedly a rather loose question. My current understanding of singletons is that they are a class that you set up in such a way that only one instance is ever created. This sounds a lot like a static class to me. The main differnce being that with a static class you don't / can't instance it, you just use it such as Math.pi(). With a singletong class, you would still need to do something like singleton mySingleton = new singleton(); mysingleton.set_name("foo"); singleton otherSingleton = new singleton(); // correct me if i am wrong, but mysingleton == othersingleton right now, yes? // this the following should happen? otherSingleston.set_name("bar"); mysingleton.report_name(); // will output "bar" won't it? Please note, I am asking this language independently, more about the concept. So I am not so worried about actually how to coed such a class, but more why you would wan't to and what thing you would need to consider.

    Read the article

  • Nested loop with dependent bounds trip count

    - by aaa
    hello. just out of curiosity I tried to do the following, which turned out to be not so obvious to me; Suppose I have nested loops with runtime bounds, for example: t = 0 // trip count for l in 0:N for k in 0:N for j in max(l,k):N for i in k:j+1 t += 1 t is loop trip count is there a general algorithm/way (better than N^4 obviously) to calculate loop trip count? I am working on the assumption that the iteration bounds depend only on constant or previous loop variables.

    Read the article

  • Fast path cache generation for a connected node graph

    - by Sukasa
    I'm trying to get a faster pathfinding mechanism in place in a game I'm working on for a connected node graph. The nodes are classed into two types, "Networks" and "Routers." In this picture, the blue circles represent routers and the grey rectangles networks. Each network keeps a list of which routers it is connected to, and vice-versa. Routers cannot connect directly to other routers, and networks cannot connect directly to other networks. Networks list which routers they're connected to Routers do the same I need to get an algorithm that will map out a path, measured in the number of networks crossed, for each possible source and destination network excluding paths where the source and destination are the same network. I have one right now, however it is unusably slow, taking about two seconds to map the paths, which becomes incredibly noticeable for all connected players. The current algorithm is a depth-first brute-force search (It was thrown together in about an hour to just get the path caching working) which returns an array of networks in the order they are traversed, which explains why it's so slow. Are there any algorithms that are more efficient? As a side note, while these example graphs have four networks, the in-practice graphs have 55 networks and about 20 routers in use. Paths which are not possible also can occur, and as well at any time the network/router graph topography can change, requiring the path cache to be rebuilt. What approach/algorithm would likely provide the best results for this type of a graph?

    Read the article

  • Why should "miter" joints be slower than others?

    - by Hanno Fietz
    I'm having a graphics problem on drawing lines in Flash Player, where two lines drawn on top of each other with different thickness don't align properly if I use any other JointStyle than MITER. For pictures of the effect, and for the graphics oriented part of the question, see my post over on doctype. However, there's also a second angle on this problem, which is: why should drawing the "mitered" joints be so much slower than others? This seems to be a problem since at least FP 8, but I couldn't find any detailed info on what the problem might be. Is this just an ordinary bug that didn't get fixed yet, or is there something inherently slower about drawing these joints? For example, they seem to have something to do with square roots, but I seriously lack understanding of what this joint style thing is all about, technically. It just looks like some minor detail a graphic designer might worry about. I'm asking because I'm wondering if I can do something to mitergate, er, mitigate, the problem.

    Read the article

  • What SQL ORM may i use to replace this old code

    - by acidzombie24
    Sorry since this question is specific to my problem. While learning reflections i did a mini SQL ORM in a week then minor tweaks while using it for another week. Since it has very little work put into it, its really only compatibility with sqlite. I havent had problems with the code so far but i would like to port it to something that supports TSQL or MySql. The example code is here which is outdated but has the most used functions in my class. What library can i port that code over too with the smallest about of pain. Note that it must support foreign keys.

    Read the article

  • m:n relationship must have properties?

    - by nax
    I'm doing a E/R model for a project. I finished the ER model and, for me, all is okay. Maybe not perfect, but it's okay. When I gave the ER model to my teacher, he told me this: "the m:n relations MUST HAVE some properties" He said if the m:n relationship doesn't have the properties it will be wrong. In my opinion m:n doesn't need forcer attributes to the relationship, but if you have someone that can fit in it, just put there. What do you think? Who is wrong in this, me, or my teacher? NOTE: Reading again, it seems what he said was not due to my ER diagram, but was a general statement. The diagram I gave him doesn't have relations yet, so there where just entities and atributes.

    Read the article

  • Database schema to store AND, OR relation, association

    - by user455387
    Many thanks for your help on this. In order for an entreprise to get a call for tender it must meet certain requirements. For the first example the enterprise must have a minimal class 4, and have qualification 2 in sector 5. Minimal class is always one number. Qualification can be anything (single, or multiple using AND, OR logical operators) I have created tables in order to map each number to it's given name. Now I need to store requirements in the database. minimal class 4 Sector Qualification 5.2 minimal class 2 Sector Qualifications 3.9 and 3.10 minimal class 3 Sector Qualifications 6.1 or 6.3 minimal class 1 Sector Qualifications (3.1 and 3.2) or 5.6 class Domain < ActiveRecord::Base has_many :domain_classes has_many :domain_sectors has_many :sector_qualifications, :through => :domain_sectors end class DomainClass < ActiveRecord::Base belongs_to :domain end class DomainSector < ActiveRecord::Base belongs_to :domain has_many :sector_qualifications end class SectorQualification < ActiveRecord::Base belongs_to :domain_sector end create_table "domains", :force => true do |t| t.string "name" end create_table "domain_classes", :force => true do |t| t.integer "number" t.integer "domain_id" end create_table "domain_sectors", :force => true do |t| t.string "name" t.integer "number" t.integer "domain_id" end create_table "sector_qualifications", :force => true do |t| t.string "name" t.integer "number" t.integer "domain_sector_id" end

    Read the article

  • rais belong_to which class to choose

    - by Small Wolf
    There is a model relation like this. class A belongs_to :ref_config,:class_name => 'User' end My question is : the A has a attribute named flag, now i want to create a function like this: if flag == 1, I want the class A like this belongs_to :ref_config,:class_name => 'Department and if flag == 2, i want the class A like this belongs_to :ref_config,:class_name => 'User' How can I implement the function Thank you!

    Read the article

< Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >