Search Results

Search found 647 results on 26 pages for 'rand mate'.

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

  • How to get the records using order by and so on

    - by paulrajj
    I have a table categories containing categories id having the records of 1 to 20. when i am doing the search query by using the IN function in mysql i got the results. but i am struggling to get the results using order by. The limit may be vary for every search as this is one of the input value. For example I have tried this query to find out the search results, select * from categories where category in (20,16,12,8) order by rand(), id limit 0,6 this query is executed and the results are in random category_id. the results will be, 8 12 16 20 and following this, another two records must be 8 12 If category_id contains only one record for 8 then, it should follow from 12,16. How can i achieve this ? thanks in advance.

    Read the article

  • Problem with xor operation

    - by gavishna
    Kindly tell me why the original image is not coming with this code. The resulting image receive is yellowish in color,instead of being similar to the image Img_new Img=imread(‘lena_color.tif’); Img_new=rgb2gray(img); Send=zeroes(size(Img_new); Receive= zeroes(size(Img_new); Mask= rand(size(Img_new); for i=1 :256 for j=1:256 Send(i,j)=xor( Img_new(i,j),mask(i,j)); End End image(send); imshow(send); for i=1 :256 for j=1:256 receive(i,j)=xor( send(i,j),mask(i,j)); End End image(receive); imshow(receive); plz help

    Read the article

  • Storing a variable into a database

    - by Alekx
    In an attempt to better learn Rails and I'm building a simple Blackjack game, but I'm running into a problem of storing the variable. I understand how to store user-genereated data into the db using form_for, but I'm struggling to create a random number and put it in the db. @hand = rand(9) + 2 I have "hand" as a field in my db, just curious how to store this random number. Any help anyone could provide to point me in the right direction would be very much appreciated. Thanks.

    Read the article

  • unique random id

    - by Piyush
    I am generating unique id for my small application but I am facing some variable scope problem. my code- function create_id() { global $myusername; $part1 = substr($myusername, 0, -4); $part2 = rand (99,99999); $part3 = date("s"); return $part1.$part2.$part3; } $id; $count=0; while($count == 1) { $id; $id=create_id(); $sqlcheck = "Select * FROM ruser WHERE userId='$id';"; $count =mysql_query($sqlcheck,$link)or die(mysql_error()); } echo $id; I dont know which variable I have to declare as global

    Read the article

  • How to fetch a random record from SQLite database?

    - by Bruce
    I am working on PHP. I was working with MySQL before. Here is the code I used - $offset_result = mysqli_query($con, " SELECT FLOOR(RAND() * COUNT(*)) AS `offset` FROM students "); $offset_row = mysqli_fetch_object( $offset_result ); $offset = $offset_row->offset; $result = mysqli_query($con, " SELECT name FROM students LIMIT $offset, 1 " ); $row = mysqli_fetch_row($result); mysqli_free_result($result); What will be the corresponding set of statements for SQLite?

    Read the article

  • C++ function for picking from a list where each element has a distinct probability

    - by Stuart
    I have an array of structs and one of the fields in the struct is a float. I want to pick one of the structs where the probability of picking it is relative to the value of the float. ie struct s{ float probability; ... } sArray s[50]; What is the fastest way to decide which s to pick? Is there a function for this? If I knew the sum of all the probability fields (Note it will not be 1), then could I iterate through each s and compare probability/total_probability with a random number, changing the random number for each s? ie if( (float) (rand() / RAND_MAX) < probability)...

    Read the article

  • MySQL Rating system (calculating average from two tables).

    - by MussuR
    I have two tables, videos and videos_ratings. The videos table has an int videoid field (and many others but those fields are not important I think) and many records. The videos_ratings table has 3 int fields: videoid, rating, rated_by which has many records (multiple records for each fields from the videos table) but not for all records from the videos table. Currently I have the following mysql query: SELECT `videos`.*, avg(`videos_ratings`.`vote`) FROM `videos`, `videos_ratings` WHERE `videos_ratings`.`videoid` = `videos`.`videoid` GROUP BY `videos_ratings`.`videoid` ORDER BY RAND() LIMIT 0, 12 It selects all the records from table videos that have a rating in table video_ratings and calculates the average correctly. But what I need is to select all records from the videos table, no matter if there is a rating for that record or not. And if there aren't any records in the videos_ratings table for that particular videos record, the average function should show 0. Hope someone could understand what I want... :) Thanks!

    Read the article

  • How to ReHash a password stored into my Database ? (PHP)

    - by Vincent Roye
    Hi! I have some passwords encrypted in my database and I would like to find a way to display them. Here is how they are saved into my mysql database: function generateHash($plainText, $salt = null){ if ($salt === null) { $salt = substr(md5(uniqid(rand(), true)), 0, 25); } else { $salt = substr($salt, 0, 25); } return $salt . sha1($salt . $plainText); } $secure_pass = generateHash($this->clean_password); Then $secure_pass is saved into my database. Anyone would have an idea ?? Thank you very much ;)

    Read the article

  • Deterministic random number generator with context?

    - by user653133
    I am looking for a seeded random number generator that creates a pool of numbers as a context. It doesn't have to be too good. It is used for a game, but it is important, that each instance of the Game Engine has it's own pool of numbers, so that different game instances or even other parts of the game that use random numbers don't break the deterministic character of the generated numbers. Currently I am using rand() which obviously doesn't have this feature. Are there any c or objective-c generators that are capable of doing what I want? Best regards, Michael

    Read the article

  • Select unseen random row from MySQL table

    - by user1476925
    We have a list of questions in a MySQL database and want it to show a random approved question to the user. When you click the Random button, we want another random question to be shown, but not any of the ones the user has already seen. Right now the script looks like this: <?php mysql_connect("localhost", "username", "password") or die(mysql_error()); mysql_select_db("aldrig") or die(mysql_error()); $result = mysql_query("SELECT * FROM spg WHERE approved='1' ORDER BY RAND() LIMIT 1;") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { echo "<div class='contentTitle'><h1>"; echo $row['text']; echo "</h1></div>"; } ?>

    Read the article

  • Function to set an auth_token

    - by john mossel
    In my form I have a hidden field: <input type="hidden" name="auth_token" value="<?php echo $auth_token; ?>"> This value is also stored in a session and a variable: $_SESSION['auth_token'] = hash('sha256', rand() . time() . $_SERVER['HTTP_USER_AGENT']); # TODO: put this in a function $auth_token = $_SESSION['auth_token']; When the form is submitted the two values are compared. It's a basic form token. Should this be made into two functions or just one when refactored? set_form_token() and get_form_token(), get_form_token() returning the session value, then I can compare it in my main code. What is the proper way of doing this?

    Read the article

  • how to force browser to re-request page after history.back()

    - by yellowred
    Hi, I've got two scripts: 1.php and 1.php. Here they are: 1.php <?php header('Pragma: no-cache'); header('Cache-Control: max-age=1; no-cache'); header('Expires: Tue, 1 May 1985 01:10:00 GMT'); header('ETag: "'.md5(rand(1, 1000)).'"'); print date('H:i:s'); ?> <a href="2.php">pay</a> 2.php <a href="javascript:history.back()">back</a> Visitor lands on 1.php and then goes to 2.php. I want browser to re-request 1.php after vistor's click on "back" link. On current state it doesn't work. How it can be managed?

    Read the article

  • Special simple random number generator

    - by psihodelia
    How to create a function, which on every call generates a random integer number? This number must be most random as possible (according to uniform distribution). It is only allowed to use one static variable and at most 3 elementary steps, where each step consists of only one basic arithmetic operation of arity 1 or 2. Example: int myrandom(void){ static int x; x = some_step1; x = some_step2; x = some_step3; return x; } Basic arithmetic operations are +,-,%,and, not, xor, or, left shift, right shift, multiplication and division. Of course, no rand(), random() or similar staff is allowed.

    Read the article

  • Relative probabilities using random number gen

    - by CyberShot
    If I have relative probabilities of events A, B, C occurring. i.e P(A) = 0.45, P(B) = 0.35, P(C) = 0.20, How do I do represent this using a random number generator between 0 and 1? i.e. R = rand(0,1) if (R < 0.45) event A else if(R < 0.35) event B else if(R < 0.20) event C The above works for two events A,B but I think the above is wrong for three or more since there is overlapping. This is obviously a very simple question and the answer should be immediately evident, but I'm just too stupid to see it.

    Read the article

  • Data Quality and Master Data Management Resources

    - by Dejan Sarka
    Many companies or organizations do regular data cleansing. When you cleanse the data, the data quality goes up to some higher level. The data quality level is determined by the amount of work invested in the cleansing. As time passes, the data quality deteriorates, and you need to repeat the cleansing process. If you spend an equal amount of effort as you did with the previous cleansing, you can expect the same level of data quality as you had after the previous cleansing. And then the data quality deteriorates over time again, and the cleansing process starts over and over again. The idea of Data Quality Services is to mitigate the cleansing process. While the amount of time you need to spend on cleansing decreases, you will achieve higher and higher levels of data quality. While cleansing, you learn what types of errors to expect, discover error patterns, find domains of correct values, etc. You don’t throw away this knowledge. You store it and use it to find and correct the same issues automatically during your next cleansing process. The following figure shows this graphically. The idea of master data management, which you can perform with Master Data Services (MDS), is to prevent data quality from deteriorating. Once you reach a particular quality level, the MDS application—together with the defined policies, people, and master data management processes—allow you to maintain this level permanently. This idea is shown in the following picture. OK, now you know what DQS and MDS are about. You can imagine the importance on maintaining the data quality. Here are some resources that help you preparing and executing the data quality (DQ) and master data management (MDM) activities. Books Dejan Sarka and Davide Mauri: Data Quality and Master Data Management with Microsoft SQL Server 2008 R2 – a general introduction to MDM, MDS, and data profiling. Matching explained in depth. Dejan Sarka, Matija Lah and Grega Jerkic: MCTS Self-Paced Training Kit (Exam 70-463): Building Data Warehouses with Microsoft SQL Server 2012 – I wrote quite a few chapters about DQ and MDM, and introduced also SQL Server 2012 DQS. Thomas Redman: Data Quality: The Field Guide – you should start with this book. Thomas Redman is the father of DQ and MDM. Tyler Graham: Microsoft SQL Server 2012 Master Data Services – MDS in depth from a product team mate. Arkady Maydanchik: Data Quality Assessment – data profiling in depth. Tamraparni Dasu, Theodore Johnson: Exploratory Data Mining and Data Cleaning – advanced data profiling with data mining. Forthcoming presentations I am presenting a DQS and MDM seminar at PASS SQL Rally Amsterdam 2013: Wednesday, November 6th, 2013: Enterprise Information Management with SQL Server 2012 – a good kick start to your first DQ and / or MDM project. Courses Data Quality and Master Data Management with SQL Server 2012 – I wrote a 2-day course for SolidQ. If you are interested in this course, which I could also deliver in a shorter seminar way, you can contact your closes SolidQ subsidiary, or, of course, me directly on addresses [email protected] or [email protected]. This course could also complement the existing courseware portfolio of training providers, which are welcome to contact me as well. Start improving the quality of your data now!

    Read the article

  • Silverlight Cream for December 07, 2010 -- #1004

    - by Dave Campbell
    In this Issue: András Velvárt, Kunal Chowdhury(-2-), AvraShow, Gill Cleeren, Ian T. Lackey, Richard Waddell, Joe McBride, Michael Crump, Xpert360, keyboardP, and Pete Vickers(-2-). Above the Fold: Silverlight: "Grouping Records in Silverlight DataGrid using PagedCollectionView" Kunal Chowdhury WP7: "Phone 7 Back Button and the ListPicker control" Ian T. Lackey Shoutouts: Colin Eberhardt has some Silverlight 5 Adoption Predictions you may want to check out. Michael Crump has a post up showing lots of the goodness of Silverlight 5 from the Firestarter... screenshots, code snippets, etc: Silverlight 5 – What’s New? (Including Screenshots & Code Snippets) Kunal Chowdhury has a pretty complete Silverlight 5 feature set from the Firestarter and an embedded copy of Scott Guthrie's kenote running on the page: New Features Announced for Silverlight 5 Beta From SilverlightCream.com: Just how productive is WP7 development compared to iOS, Android and mobile Web? András Velvárt blogged about a contest he took part in to build a WP7 app in 1-1/2 hours without any prior knowledge of it's funtion. He and his team-mate were pitted against other teams on Android, IOS, and mobile Web... guess who got (almost) their entire app running? ... just too cool Andras! ... Grouping Records in Silverlight DataGrid using PagedCollectionView Kunal Chowdhury has a couple good posts up, this first one is on using the PagedCollectionView to group the records in a DataGrid... code included. Filtering Records in Silverlight DataGrid using PagedCollectionView Kunal Chowdhury then continues with another post on the PagedCollectionView only this time is showing how to do some filtering. DeepZoom Tips and Techniques AvraShow has a post up discussing using DeepZoom to explore, in his case, a Printed Circuit Board, with information about how he proceeded in doing that, and some tips and techniques along the way. The validation story in Silverlight (Part 2) Gill Cleeren has Part 2 of his Silverlight Validation series up at SilverlightShow. This post gets into IDataErrorInfo and INotifyDataErrorInfo. Lots of code and the example is available for download. Phone 7 Back Button and the ListPicker control Ian T. Lackey has a post up about the WP7 backbutton and what can get a failure from the Marketplace in that area, and how that applies to the ListPicker as well. Very Simple Example of ICommand CanExecute Method and CanExecuteChanged Event Richard Waddell has a nice detailed tutorial on ICommand and dealing with CanExecute... lots of Blend love in this post. Providing an Alternating Background Color for an ItemsControl Joe McBride has a post up discussing putting an alternating background color on an ItemsControl... you know, how you do on a grid... interesting idea, and all the code... Pimp my Silverlight Firestarter Michael Crump has a great Firestarter post up ... where and how to get the videos, the labs... a good Firestarter resource for sure. Adventures with PivotViewer Part 7: Slider control Xpert360 has part 7 of the PivotViewer series they're doing up. This time they're demonstrating taking programmatic control of the Zoom slider. Creating Transparent Lockscreen Wallpapers for WP7 I don't know keyboardP's name, but he's got a cool post up about getting an image up for the WP7 lock screen that has transparent regions on it... pretty cool actually. Windows Phone 7 Linq to XML 'strangeness' Pete Vickers has a post up describing a problem he found with Linq to XML on WP7. He even has a demo app that has the problem, and the fix... and it's all downloadable. Windows Phone 7 multi-line radio buttons Pete Vickers has another quick post up on radio buttons with so much text that it needs wrapping ... this is for WP7, but applies to Silverlight in general. Stay in the 'Light! Twitter SilverlightNews | Twitter WynApse | WynApse.com | Tagged Posts | SilverlightCream Join me @ SilverlightCream | Phoenix Silverlight User Group Technorati Tags: Silverlight    Silverlight 3    Silverlight 4    Windows Phone MIX10

    Read the article

  • Hell and Diplomacy: Notes on Software Integration

    - by ericajanine
    Well, I'm getting cabin fever and short-timer's ADD all at the same time. I haven't been anywhere outside of my greater city area in FOREVER and I'm only days away from my vacation. I have brainlock because the last few days have been non-stop diffusing amazingly hostile conversations. I think I'll write about that. So then, I "do" software. At the end of the day, software is pretty straightforward. Software is that thing we love and try to make do things not currently in play, in existence. If a process around getting software to do something is broken (like most actually are), then we should acknowledge it and move on. We are professional. We are helpful beyond the normal call of duty. We live and breathe making the lives better for those apps being active in the world. But above all--the shocker: We are SERVICE. In a service frame of mind, all perspectives shift to what is best overall for system stabilization vs. what must be in production to meet business objectives. It doesn't matter how much you like or dislike the creator of said software. It doesn't matter what time you went to bed last night or if your mate appreciates your Death March attitude. Getting a product in and when is an age-old dilemma in a software environment where more than, say, 3 people are involved. We know this. Taking a servant's perspective eliminates the drama surrounding what a group of half-baked developers forgot to tell each other in the 11th hour about their trampling changes before check-in. We, my counterparts in society, get paid to deal with that drama. I get paid to diffuse that drama and make everything integrate as smoothly as possible. At the end of the day, attacking someone over a minor detail not only makes things worse, it's against the whole point of our real existence. Being in support or software integration means you are to keep your eyes on the end game. That end game? It's making a solution work for all stakeholders, not just you or your immediate superior. Development and technology groups exist because business groups need them to exist and solve their issues. The end game? Doing what is best for those business groups ultimately. Period. Note: That does not mean you let your business users solely dictate when and if something gets changed in an environment you ultimately own. That's just crazy. Software and its environments are legitimately owned by those who manage it directly, no matter how important a business group believes it is to the existence of mankind. So, you both negotiate the terms of changing that environment and only do so upon that negotiation. Diplomacy is in order. So, to finish my thoughts: If you have no ability to keep your mouth shut in a situation where a business or development group truly need your help to make something work even beyond a deadline, find another profession. Beating up someone verbally because they screw up means a service attitude is not at the forefront of your motivation for doing what is ultimately their work and their product. Software, especially integration, requires a strong will and a soft touch to keep it on track. Not a hammer covered in broken glass.

    Read the article

  • How to remove synaptic without installing all the unwanted packages?

    - by Jay
    I am trying to uninstall synaptic. I prefer using apt-get and other command line tools to manage my packages. So I do not need synaptic and the software manager. I'm trying to remove both of them using apt-get. Its a new box. Recently installed Linux Mint mate 15. After installation, the only thing I did was, sudo apt-get update and sudo apt-get dist-upgrade After that, I did this command for removing synaptic, sudo apt-get remove --purge synaptic But this gives me a very weird output, Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: apturl-kde icoutils kate-data katepart kde-runtime kde-runtime-data kdelibs-bin kdelibs5-data kdelibs5-plugins kdesudo kdoctools kubuntu-debug-installer libattica0.4 libdlrestrictions1 libkactivities-bin libkactivities-models1 libkactivities6 libkatepartinterfaces4 libkcmutils4 libkde3support4 libkdeclarative5 libkdecore5 libkdesu5 libkdeui5 libkdewebkit5 libkdnssd4 libkemoticons4 libkfile4 libkhtml5 libkidletime4 libkio5 libkjsapi4 libkjsembed4 libkmediaplayer4 libknewstuff3-4 libknotifyconfig4 libkntlm4 libkparts4 libkpty4 libkrosscore4 libktexteditor4 libkxmlrpcclient4 libnepomuk4 libnepomukcore4abi1 libnepomukquery4a libnepomukutils4 libntrack-qt4-1 libntrack0 libphonon4 libplasma3 libpolkit-qt-1-1 libpoppler-qt4-4 libqapt2 libqapt2-runtime libqca2 libqt4-qt3support libsolid4 libsoprano4 libstreamanalyzer0 libstreams0 libthreadweaver4 libvirtodbc0 nepomuk-core nepomuk-core-data ntrack-module-libnl-0 odbcinst odbcinst1debian2 oxygen-icon-theme phonon phonon-backend-gstreamer plasma-scriptengine-javascript qapt-batch shared-desktop-ontologies soprano-daemon virtuoso-minimal virtuoso-opensource-6.1-bin virtuoso-opensource-6.1-common Use 'apt-get autoremove' to remove them. The following extra packages will be installed: apturl-kde icoutils kate-data katepart kde-runtime kde-runtime-data kdelibs-bin kdelibs5-data kdelibs5-plugins kdesudo kdoctools kubuntu-debug-installer libattica0.4 libdlrestrictions1 libkactivities-bin libkactivities-models1 libkactivities6 libkatepartinterfaces4 libkcmutils4 libkde3support4 libkdeclarative5 libkdecore5 libkdesu5 libkdeui5 libkdewebkit5 libkdnssd4 libkemoticons4 libkfile4 libkhtml5 libkidletime4 libkio5 libkjsapi4 libkjsembed4 libkmediaplayer4 libknewstuff3-4 libknotifyconfig4 libkntlm4 libkparts4 libkpty4 libkrosscore4 libktexteditor4 libkxmlrpcclient4 libnepomuk4 libnepomukcore4abi1 libnepomukquery4a libnepomukutils4 libntrack-qt4-1 libntrack0 libphonon4 libplasma3 libpolkit-qt-1-1 libpoppler-qt4-4 libqapt2 libqapt2-runtime libqca2 libqt4-qt3support libsolid4 libsoprano4 libstreamanalyzer0 libstreams0 libthreadweaver4 libvirtodbc0 libxml2-utils nepomuk-core nepomuk-core-data ntrack-module-libnl-0 odbcinst odbcinst1debian2 oxygen-icon-theme phonon phonon-backend-gstreamer plasma-scriptengine-javascript qapt-batch shared-desktop-ontologies soprano-daemon virtuoso-minimal virtuoso-opensource-6.1-bin virtuoso-opensource-6.1-common Suggested packages: libterm-readline-gnu-perl libterm-readline-perl-perl djvulibre-bin finger hspell libqca2-plugin-cyrus-sasl libqca2-plugin-gnupg libqca2-plugin-ossl phonon-backend-vlc phonon-backend-xine phonon-backend-mplayer The following packages will be REMOVED: aptoncd* apturl* mintupdate* mintwelcome* synaptic* The following NEW packages will be installed: apturl-kde icoutils kate-data katepart kde-runtime kde-runtime-data kdelibs-bin kdelibs5-data kdelibs5-plugins kdesudo kdoctools kubuntu-debug-installer libattica0.4 libdlrestrictions1 libkactivities-bin libkactivities-models1 libkactivities6 libkatepartinterfaces4 libkcmutils4 libkde3support4 libkdeclarative5 libkdecore5 libkdesu5 libkdeui5 libkdewebkit5 libkdnssd4 libkemoticons4 libkfile4 libkhtml5 libkidletime4 libkio5 libkjsapi4 libkjsembed4 libkmediaplayer4 libknewstuff3-4 libknotifyconfig4 libkntlm4 libkparts4 libkpty4 libkrosscore4 libktexteditor4 libkxmlrpcclient4 libnepomuk4 libnepomukcore4abi1 libnepomukquery4a libnepomukutils4 libntrack-qt4-1 libntrack0 libphonon4 libplasma3 libpolkit-qt-1-1 libpoppler-qt4-4 libqapt2 libqapt2-runtime libqca2 libqt4-qt3support libsolid4 libsoprano4 libstreamanalyzer0 libstreams0 libthreadweaver4 libvirtodbc0 libxml2-utils nepomuk-core nepomuk-core-data ntrack-module-libnl-0 odbcinst odbcinst1debian2 oxygen-icon-theme phonon phonon-backend-gstreamer plasma-scriptengine-javascript qapt-batch shared-desktop-ontologies soprano-daemon virtuoso-minimal virtuoso-opensource-6.1-bin virtuoso-opensource-6.1-common 0 upgraded, 78 newly installed, 5 to remove and 0 not upgraded. Need to get 60.9 MB of archives. After this operation, 146 MB of additional disk space will be used. Do you want to continue [Y/n]? n Abort. As you can see, apt-get is trying to install the same packages that it is asking me to autoremove. Could someone please tell me, how to uninstall synaptic properly? Or am I missing something? Just for the record, I also did, sudo apt-get autoremove --purge like it asked me to ... and this is what I got, Reading package lists... Done Building dependency tree Reading state information... Done 0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.

    Read the article

  • Windows mobile phone for business application - or design way out of scrolling problem

    - by Peter
    We have a business application written for Windows mobile. It has people doing inventories. The fastest way to do this is to keep one hand on the product being counted and the other on the phone. The five-way lets you hit enter to accept the current correct inventory (the norm) or to move one left to remove one. This is very fast. If I am two low, I have a quick glance at the phone- move my eyes back to count the next row - and with my right hand hit the five way "left left enter". Very fast. Our problem is that with I-Mate out of business, we cannot find a modern cell phone that has a decent size screen and a five way. Everyone is going to candy bar and flicks. That works great if it is two hands and you are looking at the phone, but not efficient for us. Other than the $1,500 ruggadized units, is there anybody who makes a business style Windows Mobile with a five way? If not, any ideas on how to design the phone to make it easier without a five way to quickly enter data like this?

    Read the article

  • problem with evolutionary algorithms degrading into simulated annealing: mutation too small?

    - by Schnalle
    i have a problem understanding evolutionary algorithms. i tried using this technique several times, but i always ran into the same problem: degeneration into simulated annealing. lets say my initial population, with fitness in brackets, is: A (7), B (9), C (14), D (19) after mating and mutation i have following children: AB (8.3), AC (12.2), AD (14.1), BC(11), BD (14.7), CD (17) after elimination of the weakest, we get A, AB, B, AC next turn, AB will mate again with a result around 8, pushing AC out. next turn, AB again, pushing B out (assuming mutation changes fitness mostly in the 1 range). now, after only a few turns the pool is populated with the originally fittest candidates (A, B) and mutations of those two (AB). this happens regardless of the size of the initial pool, it just takes a bit longer. say, with an initial population of 50 it takes 50 turns, then all others are eliminated, turning the whole setup in a more complicated simulated annealing. in the beginning i also mated canditates with themselves, worsening the problem. so, what do i miss? are my mutation rates simply too small and will it go away if i increase them? here's the project i'm using it for: http://stefan.schallerl.com/simuan-grid-grad/ yeah, the code is buggy and the interface sucks, but i'm too lazy to fix it right now - and be careful, it may lock up your browser. better use chrome, even thought firefox is not slower than chrome for once (probably the tracing for the image comparison pays off, yay!). if anyone is interested, the code can be found here. here i just dropped the ev-alg idea and went for simulated annealing. ps: i'm not even sure about simulated annealing - it is like evolutionary algorithms, just with a population size of one, right?

    Read the article

  • Does fast typing influence fast programming? [closed]

    - by Lukasz Lew
    Many young programmers think that their bottleneck is typing speed. After some experience one realizes that it is not the case, you have to think much more than type. At some point my room-mate forced me to turn of the light (he sleeps during the night). I had to learn to touch type and I experienced an actual improvement in programming skill. The most surprising was that the improvement not due to sheer typing speed, but to a change in mindset. I'm less afraid now to try new things and refactor them later if they work well. It's like having a new tool in the bag. Have anyone of you had similar experience? Now I trained a touch typing a little with KTouch. I find auto-generate lessons the best. I can use this program to create new lessons out of text files but it's only verbatim training, not auto-generated based on a language model. Do you know any touch typing program that allows creation of custom, but randomized lessons?

    Read the article

  • Is it rude to add "TODO: wtf?" in source code?

    - by mafutrct
    I encountered something ... well, you know TDWTF... something like that in an international project I'm working on. The code was written by a team mate. For a second I was tempted to add // TODO: wtf? to the infringing code but restrained myself. The project is indeed on a professional level, but for internal conversation, more colloquial language is used - but still no "bad" words as in "wtf". Usually, I'd surely not add such a comment, but I believe there are a few factors that allow consideration still: 1. It is not visible except as a comment in the source code (of course). 2. It is internal to our team - other developers may happen see it but it is not their code. 3. Comments in source code are usually accepted to be more colloquial, since it is "kept between us developers". Would you totally advise to never add such a comment? Or do you regard it as an edge case? Did you possibly add something similar yourself?

    Read the article

  • DO NOT BOTHER. THE PROBLEM IS NOT TRANSACTIONS. DUNNO HOW TO CLOSE / DELETE

    - by matti
    THE PROBLEM IS SOLVED. I DUNNO HOW TO CLOSE THIS QUESTION. ANOTHER SERVICE IS PROPABLY RUNNING AT ALMOST SAME SYNC THAT DOES THE THING. MY WORK "MATE" WILL HEAR A THING OR TWO IN THE MORNING. I have following code in windows service: data is in the dataset and it has been populated earlier and then rows are updated and inserted to dataset tables before calling code below. using (dataSetTxn = _cnctn.BeginTransaction()) { try { _somePlanAdptr.UpdateCommand.Transaction = dataSetTxn; _someLogAdptr.InsertCommand.Transaction = dataSetTxn; _someLinkAdptr.InsertCommand.Transaction = dataSetTxn; _someDataAdptr.InsertCommand.Transaction = dataSetTxn; _log.WriteDebug("Updating SomePlanAction"); _somePlanAdptr.Update(_ofDataSet, "SomePlanAction"); _log.WriteDebug(string.Format("Inserting {0} rows to SomeLog")); //error _someLogAdptr.Update(_ofDataSet, "SomeLog"); _log.WriteDebug(string.Format("Updating SomeLink with {0} rows", _ofDataSet.Tables["SomeLink"].Rows.Count)); _someLinkAdptr.Update(_ofDataSet, "SomeLink"); _log.WriteDebug(string.Format("Updating SomeData with {0} rows", _ofDataSet.Tables["SomeData"].Rows.Count)); _someDataAdptr.Update(_ofDataSet, "SomeData"); _log.WriteDebug("Commiting all changes to database."); dataSetTxn.Commit(); } catch (Exception e) { _log.WriteError("Updating database failed -> rollback", e); if (dataSetTxn != null && _cnctn.State == ConnectionState.Open) dataSetTxn.Rollback(); throw e; } } so one of the lines causes an exception log.WriteDebug(string.Format("Inserting {0} rows to SomeLog")); //error still the first adapter's data is updated to database. when debugged the data is not yet updated until the method that calls all (including this bit) exits. The method that does all is timed with System.Threading.Timer. Thanks & BR -Matti

    Read the article

  • How can i create an n-dimensional array in c

    - by shortCircuit
    I was thinking of making a function that would accept the size of array as a parameter and create a n dimensional array. My room-mate took the liberty of making it complex. He said lets write a function that takes n parameters and returns an n-dimensional array using those parameters as the dimensions. Now i realize an one-day and d array is easy to implement with pointers. For 2d array the snippet would be something like (standard way) : int** x; int* temp; x = (int**)malloc(m * sizeof(int*)); temp = (int*)malloc(m*n * sizeof(int)); for (int i = 0; i < m; i++) { x[i] = temp + (i * n); } where the array is of size m*n; But the problem lies how do we find the nested loop parameters for a n-dimensional array? Is there any way to optimize the code?

    Read the article

  • iphone app working on most devices but not a few

    - by Matt Facer
    Hi there. I have recently been rewriting some of my iphone app because a couple of users have said it was crashing on certain events. The event in question is when I add a new XIB to the view using the following code AddItemViewController * add_item = [[AddItemViewController alloc] initWithNibName:@"AddItem" bundle:[NSBundle mainBundle]]; [self presentModalViewController:add_item animated:YES]; [add_item setViewFormat:2]; [add_item release]; it works perfectly on my iphone and a mate's ipod touch (both running 3.1.3) but another user on an ipod touch also with 3.1.3 says it crashes when the function above is called. Why could this be happening? Surely if it works on one device it should work on another?! Is there a better way to add a view which maybe doesnt crash? I have also disabled all the code on the loading xib - so it literally is loading a near blank page. It's SO annoying!! Thanks for any help.

    Read the article

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