Search Results

Search found 1947 results on 78 pages for 'science'.

Page 15/78 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • Netlogo Programming question - Chemical Equilibrium temperature and pressure implementation

    - by user286190
    Hi I am trying to code something in Netlogo..I am using an existing model Chemical Equilibrium and am trying to implement the following: turtles-own [speed ] ask turtles [ ;; set velocity ( ambient-temperature = 30 ) ;; fd velocity if temp > 40 [ "speed" increases of turtles ] ifelse temperature < 30 [ speed of turtles decreases] ] ;; to temp but it does not seem to work (it temperature is more than 40 the speed of the turtles increases if the temperature is less than 30 the speed of the turtles decreases) temperature is a slider on the model the same for pressure ask turtles [ ;; if pressure > 50 then speed increases of turtles ;; if pressure < 50 then speed decreases of turtles ] ;; to pressure thanks

    Read the article

  • Can Haskell's Parsec library be used to implement a recursive descent parser with backup?

    - by Thor Thurn
    I've been considering using Haskell's Parsec parsing library to parse a subset of Java as a recursive descent parser as an alternative to more traditional parser-generator solutions like Happy. Parsec seems very easy to use, and parse speed is definitely not a factor for me. I'm wondering, though, if it's possible to implement "backup" with Parsec, a technique which finds the correct production to use by trying each one in turn. For a simple example, consider the very start of the JLS Java grammar: Literal: IntegerLiteral FloatingPointLiteral I'd like a way to not have to figure out how I should order these two rules to get the parse to succeed. As it stands, a naive implementation like this: literal = do { x <- try (do { v <- integer; return (IntLiteral v)}) <|> (do { v <- float; return (FPLiteral v)}); return(Literal x) } Will not work... inputs like "15.2" will cause the integer parser to succeed first, and then the whole thing will choke on the "." symbol. In this case, of course, it's obvious that you can solve the problem by re-ordering the two productions. In the general case, though, finding things like this is going to be a nightmare, and it's very likely that I'll miss some cases. Ideally, I'd like a way to have Parsec figure out stuff like this for me. Is this possible, or am I simply trying to do too much with the library? The Parsec documentation claims that it can "parse context-sensitive, infinite look-ahead grammars", so it seems like something like I should be able to do something here.

    Read the article

  • Dynamic programming solution to the subset-sum decision problem

    - by Gail
    How can a dynamic programming solution for the unbounded knapsack decision problem be used to come up with a dynamic programming solution to the subset-sum decision problem? This limitation seems to render the unbounded knapsack problem useless. In the unbounded knapsack, we simply store true or false for if some subset of integers sum up to our target value. However, if we have a limit on the frequency of the use of these integers, the optimal substructure at least appears to fail. How can this be done?

    Read the article

  • Is the Unix Philosophy still relevant in the Web 2.0 world?

    - by David Titarenco
    Introduction Hello, let me give you some background before I begin. I started programming when I was 5 or 6 on my dad's PSION II (some primitive BASIC-like language), then I learned more and more, eventually inching my way up to C, C++, Java, PHP, JS, etc. I think I'm a pretty decent coder. I think most people would agree. I'm not a complete social recluse, but I do stuff like write a virtual machine for fun. I've never taken a computer course in college because I've been in and out for the past couple of years and have only been taking core classes; never having been particularly amazing at school, perhaps I'm missing some basic tenet that most learn in CS101. I'm currently reading Coders at Work and this question is based on some ideas I read in there. A Brief (Fictionalized) Example So a certain sunny day I get an idea. I hire a designer and hammer away at some C/C++ code for a couple of months, soon thereafter releasing silvr.com, a website that transmutes lead into silver. Yep, I started my very own start-up and even gave it a clever web 2.0 name with a vowel missing. Mom and dad are proud. I come up with some numbers I should be seeing after 1, 2, 3, 6, 9, 12 months and set sail. Obviously, my transmuting server isn't perfect, sometimes it segfaults, sometimes it leaks memory. I fix it and keep truckin'. After all, gdb is my best friend. Eventually, I'm at a position where a very small community of people are happily transmuting lead into silver on a semi-regular basis, but they want to let their friends on MySpace know how many grams of lead they transmuted today. And they want to post images of their lead and silver nuggets on flickr. I'm losing out on potential traffic unless I let them log in with their Yahoo, Google, and Facebook accounts. They want webcam support and live cock fighting, merry-go-rounds and Jabberwockies. All these things seem necessary. The Aftermath Of course, I have to re-write the transmuting server! After all, I've been losing money all these months. I need OAuth libraries and OpenID libraries, JSON support, and the only stable Jabberwocky API is for Java. C++ isn't even an option anymore. I'm just one guy! The Java binary just grows and grows since I need some legacy Apache include for the JSON library, and some antiquated Sun dependency for OAuth support. Then I pick up a book like Coders at Work and read what people like jwz say about complexity... I think to myself.. Keep it simple, stupid. I like simple things. I've always loved the Unix Philosophy but even after trying to keep the new server source modular and sleek, I loathe having to write one more line of code. It feels that I'm just piling crap on top of other crap. Maybe I'm naive thinking every piece of software can be simple and clever. Maybe it's just a phase.. or is the Unix Philosophy basically dead when it comes to the current state of (web) development? I'm just kind of disheartened :(

    Read the article

  • Which operating systems book should I go for?

    - by pecker
    Hi, I'm in a confusion. For our course (1 year ago) I used Stallings. I read it. It was fine. But I don't own any operating system's book. I want to buy a book on operating systems. I'm confused!! which one to pick? Modern Operating Systems (3rd Edition) ~ Andrew S. Tanenbaum (Author) Operating System Concepts ~ Abraham Silberschatz , Peter B. Galvin, Greg Gagne Operating Systems: Internals and Design Principles (6th Edition) ~ William Stallings I've plans of getting into development of realworld operating systems : Linux, Unix & Windows Driver Development. I know that for each of these there are specific books available. But I feel one should have a basic book on the shelf. So, which one to go for?

    Read the article

  • Proving that the distance values extracted in Dijkstra's algorithm is non-decreasing?

    - by Gail
    I'm reviewing my old algorithms notes and have come across this proof. It was from an assignment I had and I got it correct, but I feel that the proof certainly lacks. The question is to prove that the distance values taken from the priority queue in Dijkstra's algorithm is a non-decreasing sequence. My proof goes as follows: Proof by contradiction. Fist, assume that we pull a vertex from Q with d-value 'i'. Next time, we pull a vertex with d-value 'j'. When we pulled i, we have finalised our d-value and computed the shortest-path from the start vertex, s, to i. Since we have positive edge weights, it is impossible for our d-values to shrink as we add vertices to our path. If after pulling i from Q, we pull j with a smaller d-value, we may not have a shortest path to i, since we may be able to reach i through j. However, we have already computed the shortest path to i. We did not check a possible path. We no longer have a guaranteed path. Contradiction.

    Read the article

  • Generating All Permutations of Character Combinations when # of arrays and length of each array are

    - by Jay
    Hi everyone, I'm not sure how to ask my question in a succinct way, so I'll start with examples and expand from there. I am working with VBA, but I think this problem is non language specific and would only require a bright mind that can provide a pseudo code framework. Thanks in advance for the help! Example: I have 3 Character Arrays Like So: Arr_1 = [X,Y,Z] Arr_2 = [A,B] Arr_3 = [1,2,3,4] I would like to generate ALL possible permutations of the character arrays like so: XA1 XA2 XA3 XA4 XB1 XB2 XB3 XB4 YA1 YA2 . . . ZB3 ZB4 This can be easily solved using 3 while loops or for loops. My question is how do I solve for this if the # of arrays is unknown and the length of each array is unknown? So as an example with 4 character arrays: Arr_1 = [X,Y,Z] Arr_2 = [A,B] Arr_3 = [1,2,3,4] Arr_4 = [a,b] I would need to generate: XA1a XA1b XA2a XA2b XA3a XA3b XA4a XA4b . . . ZB4a ZB4b So the Generalized Example would be: Arr_1 = [...] Arr_2 = [...] Arr_3 = [...] . . . Arr_x = [...] Is there a way to structure a function that will generate an unknown number of loops and loop through the length of each array to generate the permutations? Or maybe there's a better way to think about the problem? Thanks Everyone!

    Read the article

  • Finding the nth number of primes

    - by Braxton Smith
    I can not figure out why this won't work. Please help me from math import sqrt pN = 0 numPrimes = 0 num = 1 def checkPrime(x): '''Check\'s whether a number is a prime or not''' prime = True if(x==2): prime = True elif(x%2==0): prime=False else: root=int(sqrt(x)) for i in range(3,root,2): if(x%i==0): prime=False break return prime n = int(input("Find n number of primes. N being:")) while( numPrimes != n ): if( checkPrime( num ) == True ): numPrimes += 1 pN = num print("{0}: {1}".format(numPrimes,pN)) num += 1 print("Prime {0} is: {1}".format(n,pN))

    Read the article

  • Context-sensitive grammar for specific language

    - by superagio
    How can I construct a grammar that generates this language? Construct a grammar that generates L: L = {a^n b^m c^k|k>n, k>m} I believe my productions should go along this lines: S-> ABCC A-> a|aBC|BC B-> b|bBC C-> c|Cc CB->BC The idea is to start with 2 c and keep always one more c, and then with C-c|Cc ad as much c as i want. How can my production for C remember the numbers of m and n.

    Read the article

  • Cropping image with ImageScience

    - by fl00r
    ImageScience is cool and light. I am using it in my sinatra app. But I can't understand how can I crop image with not square form and how can I make thumbnail with two dimensions. As I found on ImageScience site: ImageScience.with_image(file) do |img| img.cropped_thumbnail(100) do |thumb| thumb.save "#{file}_cropped.png" end img.thumbnail(100) do |thumb| thumb.save "#{file}_thumb.png" end img.resize(100, 150) do |img2| img2.save "#{file}_resize.png" end end I can crop thumb and resize thumb only with ONE dimension but I want to use two, as in RMagick. For example I want to crop 100x200px box from image, or I want to make thumbnail with width or height not bigger then 300 (width) or 500 (height) pixels.

    Read the article

  • Using Dijkstra's algorithm with negative edges?

    - by Riddler
    Most books explain the reason the algorithm doesn't work with negative edges as nodes are deleted from the priority queue after the node is arrived at since the algorithm assumes the shortest distance has been found. However since negative edges can reduce the distance, a future shorter distance might be found; but since the node is deleted it cannot be updated. Wouldn't an obvious solution to this be to not delete the node? Why not keep the node in the queue, so if a future shorter distance is found, it can be updated? If I am misunderstanding the problem, what is preventing the algorithm from being used with negative edges?

    Read the article

  • Why is it useful to count the number of bits?

    - by Scorchin
    I've seen the numerous questions about counting the number of set bits in a insert type of input, but why is it useful? For those looking for algorithms about bit counting, look here: http://stackoverflow.com/questions/1517848/counting-common-bits-in-a-sequence-of-unsigned-longs http://stackoverflow.com/questions/472325/fastest-way-to-count-number-of-bit-transitions-in-an-unsigned-int http://stackoverflow.com/questions/109023/best-algorithm-to-count-the-number-of-set-bits-in-a-32-bit-integer

    Read the article

  • Examples of monoids/semigroups in programming

    - by jkff
    It is well-known that monoids are stunningly ubiquitous in programing. They are so ubiquitous and so useful that I, as a 'hobby project', am working on a system that is completely based on their properties (distributed data aggregation). To make the system useful I need useful monoids :) I already know of these: Numeric or matrix sum Numeric or matrix product Minimum or maximum under a total order with a top or bottom element (more generally, join or meet in a bounded lattice, or even more generally, product or coproduct in a category) Set union Map union where conflicting values are joined using a monoid Intersection of subsets of a finite set (or just set intersection if we speak about semigroups) Intersection of maps with a bounded key domain (same here) Merge of sorted sequences, perhaps with joining key-equal values in a different monoid/semigroup Bounded merge of sorted lists (same as above, but we take the top N of the result) Cartesian product of two monoids or semigroups List concatenation Endomorphism composition. Now, let us define a quasi-property of an operation as a property that holds up to an equivalence relation. For example, list concatenation is quasi-commutative if we consider lists of equal length or with identical contents up to permutation to be equivalent. Here are some quasi-monoids and quasi-commutative monoids and semigroups: Any (a+b = a or b, if we consider all elements of the carrier set to be equivalent) Any satisfying predicate (a+b = the one of a and b that is non-null and satisfies some predicate P, if none does then null; if we consider all elements satisfying P equivalent) Bounded mixture of random samples (xs+ys = a random sample of size N from the concatenation of xs and ys; if we consider any two samples with the same distribution as the whole dataset to be equivalent) Bounded mixture of weighted random samples Which others do exist?

    Read the article

  • Real world example of Unification in First Order Logic?

    - by Sebi
    I know this is only part of a programming question, but at the moment, I'm doing a little bit of logic programming. One thing I still don't understand correctly is Unification in First Order Logic. I read the Wikipedia article and it is more or less clear that the purpose is searching a term that unifies two sentences... There are also examples in this article but I just don't get the point why this should be useful. Can anyone give an example with real world objects instead of A, B, C,, etc.? I hope this will help me to understand. Thanks

    Read the article

  • Moderating computer-addiction through programming

    - by every_answer_gets_a_point
    i have an addiction to be on the computer all the time. it doesn't matter what i am doing as long as i am in front of it. i feel like the whole world is here and this is all that matters. i found that through some intellectual stimulation, like writing algorithms, it has helped me to be more satisfied with the time on the computer and i dont need it as much. if any of you have had experience with reliving your computer anxiety through writing code, can you tell me exactly what you wrote, and what you may recommend i work on? thank you for your programming advice

    Read the article

  • Rules Engine vs Expert System

    - by User1
    What is the difference between a rules engine and an expert system? Example1: Let's say that I have a program that determines the expiration date of a new driver's license. It takes inputs like visa expiration date, passport number, birthday, etc. It determines the expiration date of the driver's license from this input. It can even give an error if the input did not have enough valid identifications to allow a new driver's license. Example2: Let's say I am making an online version of the game Monopoly. I want the ability to change the rules of the game (say $400 for passing go or no one can buy properties until they land on the same property twice, etc). I have a module in the code to handle these rules. Are these both rules engines or are they expert systems? They both seem so similar. Is it just a synonym?

    Read the article

  • Solving the water jug problem

    - by Amit
    While reading through some lecture notes on preliminary number theory, I came across the solution to water jug problem (with two jugs) which is summed as thus: Using the property of the G.C.D of two numbers that GCD(a,b) is the smallest possible linear combination of a and b, and hence a certain quantity Q is only measurable by the 2 jugs, iff Q is a n*GCD(a,b), since Q=sA + tB, where: n = a positive integer A = capacity of jug A B= capacity of jug B And, then the method to the solution is discussed Another model of the solution is to model the various states as a state-space search problem as often resorted to in Artificial Intelligence. My question is: What other known methods exist which models the solution, and how? Google didn't throw up much.

    Read the article

  • Undefined Variable in Matlab

    - by OrangeRind
    The Following is the basic skeleton for my MATLAB program. Each box is a class definition. Scroll down for the error. Note: Each Class has a custom constructor which does not require an external parameter The Error Undefined function or variable 'Troom'. Error in == wallwall.wall at 31 function o = wall(Tr) Error in == mainfile at 5 w1 = wall(); This comes when I create an object of Class wall from another file "mainfile" Question Why is this happening? Am I getting wrong in the concepts of OOP for Matlab specific? How do I resolve this? Thanks in Advance!

    Read the article

  • Algorithm for optimally choosing actions to perform a task

    - by Jules
    There are two data types: tasks and actions. An action costs a certain time to complete, and a set of tasks this actions consists of. A task has a set of actions, and our job is to choose one of them. So: class Task { Set<Action> choices; } class Action { float time; Set<Task> dependencies; } For example the primary task could be "Get a house". The possible actions for this task: "Buy a house" or "Build a house". The action "Build a house" costs 10 hours and has the dependencies "Get bricks" and "Get cement", etcetera. The total time is the sum of all the times of the actions required to perform. We want to choose actions such that the total time is minimal. Note that the dependencies can be diamond shaped. For example "Get bricks" could require "Get a car" (to transport the bricks) and "Get cement" would also require a car. Even if you do "Get bricks" and "Get cement" you only have to count the time it takes to get a car once. Note also that the dependencies can be circular. For example "Money" - "Job" - "Car" - "Money". This is no problem for us, we simply select all of "Money", "Job" and "Car". The total time is simply the sum of the time of these 3 things. Mathematical description: Let actions be the chosen actions. valid(task) = ?action ? task.choices. (action ? actions ? ?tasks ? action.dependencies. valid(task)) time = sum {action.time | action ? actions} minimize time subject to valid(primaryTask)

    Read the article

  • Divide and conquer method to compute roots [SOLVED]

    - by hellsoul153
    Hello, Knowing that we can use Divide-and-Conquer algorithm to compute large exponents, for exemple 2 exp 100 = 2 exp(50) * 2 exp(50), which is quite more efficient, is this method efficient using roots ? For exemple 2 exp (1/100) = (2 exp(1/50)) exp(1/50) ? In other words, I'm wondering if (n exp(1/x)) is more efficient to (n exp(1/y)) for x < y and where x and y are integers.

    Read the article

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >