|
csammis posted:But along those lines: Wherever you're adding an entry to the dictionary, how about you just add a check to see if the key that's being added satisfies the property you want, and save it? I think I am going to go with this method. On a related note, (although this is VB specific), if I wanted an array or a dictionary to be accessible by any function in any part of my code (even if it is in a different class), what would I need to put in my main to do that? I would prefer the array/dictionary to be read only, but this is not crucial.
|
# ¿ Feb 22, 2008 16:41 |
|
|
# ¿ May 8, 2024 00:18 |
|
I am trying to generate a bunch of combinations(?) as follows: I have three groups: GROUP 1: 2 3 4 GROUP 2: 5 6 GROUP 3: 0 1 The twelve combinations I generate are found by picking one memeber from each group and are: 250 251 260 261 350 351 360 361 450 451 460 461 I generated them using the following MATLAB code: code:
|
# ¿ May 23, 2009 05:28 |
|
I have a bunch of pdf files that I want to put online for someone to be able to access, but I do not want to have to manually type in the names of all the files as: <a href="filename.pdf">Filename</a> since the names of the files are pretty long and involved and there are 45 or so of them. The way I was thinking of doing this is to write some sort of script(?) that will look in a particular folder and generate a text file that has an entry like the one above for each pdf file in the folder. Then all I have to do is copy that information and paste it in my .html file. Is this even feasible? And if so, where can I look to get some basic info on how to accomplish this?
|
# ¿ Feb 3, 2010 20:14 |
|
Avenging Dentist posted:Why not just upload them all to a directory and allow the directory itself to be viewed? That would be the easiest way, but I do not know how to do this. I am using the personal webpage given to me by my university. If you could point me in the right direction I would appreciate it.
|
# ¿ Feb 3, 2010 23:31 |
|
Avenging Dentist posted:http://www.javascriptkit.com/howto/htaccess11.shtml Thanks for the link. Although I was not able to get it to work I did manage to write a script to accomplish what I need.
|
# ¿ Feb 4, 2010 22:51 |
|
I have the following problem, and I do not know how to logically approach it: I have N different time intervals of the form [a,b] (e.g. the time interval [5,9] consists of the times 5, 6, 7, 8, and 9). The problem is to determine the intersection of these N time intervals, where some will overlap, and some will not. For example, if I have [19,23], [3,7], [5,19], and [44,48], the resulting intersection I want is [3,23], [44,48]. Right now I am able to take all the start and end points of each time interval and sort them in ascending order [3, 5, 7, 19, 19, 23, 44, 48] and have an accompanying vector [s, s, e, s, e, e, s, e] of which point is a start or end. I am lost as to how to use this information to come up with the resulting intersection, and I am open to new strategies. Any ideas?
|
# ¿ Apr 27, 2010 05:05 |
|
shrughes posted:You're talking about the union. Doh! Of course I meant union. I do not understand the code you wrote, but I will try and implement the 'score' keepeing procedure you outlined, and see how I fare. EDIT: I am working in C++, and I implemented what I think you meant. It seems to work for the examples I have tried on it, but I am at a loss to explain why this method of keeping score works. DO you have any explanation, or a link to an explanation of why this works? Jose Cuervo fucked around with this message at 05:59 on Apr 27, 2010 |
# ¿ Apr 27, 2010 05:33 |
|
shrughes posted:Imagine yourself walking along the number line, from left to right. Every time you enter one of the intervals, you add 1. Every time you leave one, you subtract 1. Scaevolus is gay. Gotcha. Thanks so much.
|
# ¿ Apr 27, 2010 14:37 |
|
I have written a small program in C++ using Microsoft Visual Studio. The inputs to the program are 4 different integers (number of machines, number of machine groups, number of workers, number of jobs). I want to run the program with 2000 different combinations of these inputs on another computer that does not have Visual Studio. I have heard that I can compile my program into an exe file (?), and then pass each combination of inputs to it using a batch file, but I cannot find any help as to how to do this. Can anyone give me some help/advice on how to do this, or point me to some resources that would help me with this issue?
|
# ¿ Apr 28, 2010 13:04 |
|
I am writing a program in Visual Studio (C++) (this is my first time really using pointers) and I finally have it at the point where I am running big problems on it. Running big problems slows my system way down - my music player halts while the program is running, etc. From looking at Windows Task Manager, it seems like at some points up to 1,500,000K in the Memory (Private Working Set) is being used by my program. Is this an accurate measure of the amount of memory (RAM) my program is using? And is this an indication that I have memory leaks due to the fact that I have not deleted all pointers I created? I went back and made sure to add delete statements after I was done with any pointer I have created, but this continues to be a problem. Ideas?
|
# ¿ May 2, 2010 16:24 |
|
PDP-1 posted:Maybe, maybe not. Have you tried estimating how much memory your Big Problem should be using? My code has two parts - part one develops a lower bound for a schedule using a network flow approach, and part two is a schedule builder. If I run the program without using the lower bound computation, the maximum memory used by the program is 60,000K. If I use the lower bound computation, then the program takes 1,500,000K. The network flow computation requires me to have 7 different long int arrays. For the problem I am running, on average they are of size 1x10,000. The network flow code is called 17 times for the problem, and the memory being used increases by 80,000K-120,000K each time the network flow code is called (which is how the program ends up using 1,500,000K total). But I am calling the delete function on all 7 arrays each time I am done with a call to the network flow code, so in my mind the amount of memory I am using should be 60,000K+120,000K at the very maximum, and should fluctuate between 180,000K if the network flow code has been called and the arrays are being used, and 60,000K if the network flow code has deleted the arrays. Is this not correct thinking? Let me know if you need more information.
|
# ¿ May 2, 2010 19:38 |
|
Mustach posted:Are you calling delete or delete [] I call delete if I have a pointer declared as code:
code:
code:
code:
|
# ¿ May 2, 2010 21:00 |
|
I have a program that creates graphs which runs from the command line. The commandcode:
Is there a way to do this? I am using Win7 if that makes a difference.
|
# ¿ Feb 15, 2011 05:17 |
|
The batch files idea worked perfectly. I now just have to double click the batch file and I have 30 different graphs 10 seconds later. Thank you.
|
# ¿ Feb 15, 2011 19:57 |
|
Mistakenly posted this. Sorry.
|
# ¿ Feb 27, 2011 06:44 |
|
I have the following problem. Each night I want to create a backup of a project I am working on. The way I do it now is, I use WinSCP to access the J drive (remote drive) my university gives me, and then copy over the latest version of the 6 files that make up my project to a folder on my J drive. I was wondering if there was any way to automate that process - i.e., could I potentially write a script(?) that, when run, would automatically log into WinSCP and then copy over the 6 files to the specified folder? Really I am looking for some pointers as to what tools can be used to accomplish the task, and I will go read up and try to figure it out.
|
# ¿ Mar 28, 2011 14:55 |
|
TasteMyHouse posted:this should be pretty trivial! there are a million different ways to do this, but since you're already familiar with WinSCP... Doh! Did not even think of looking at their website. Thank you.
|
# ¿ Mar 28, 2011 17:49 |
|
I am in an Industrial Engineering program, but as part of my research I came up with a piece of code that takes a set of jobs and a set of machines and then uses some scheduling logic to build an actual schedule. I have now been asked to look at the time complexity of the code - from looking this up online it seems that I need to determine how long the code would take to run if it had an input that was 'n' units big. I am not sure how to start doing this, and was wondering if anyone had any pointers as to how I would go about figuring out the time complexity. For example, do I write the code as pseudocode first and then estimate the number of operations each line takes, or ...? And what defines an operation?
|
# ¿ Jul 16, 2011 03:45 |
|
I am not sure if I can achieve what I want, so hopefully you all will be able to tell me if what I want to do is impossible. I have 4 different papers that I am writing that are each located in a separate folder. Each paper has it's own local plain text bib file with the citation information of the citations needed for that paper. The citation information is stored in the BibTeX format. A number of the citations overlap - i.e., the citation is used in more than one paper. The two questions are: 1. Is it possible to write some code/script so that I would have one master plain text bib file with all the citations, and whenever I made a change to a citation, I could run the code/script so that the citation information gets updated in each local paper's plain text bib file? 2. Can someone with limited coding ability (me) write this code given a plan of how to do it? I have been doing the updating manually, but sometimes I do not update everything, or I misspell something and it is getting to be very aggravating.
|
# ¿ Jul 3, 2012 21:22 |
|
ToxicFrog posted:This is possible, and given the simplicity of the BibTeX format, not even very hard, but it also sounds a lot like overkill compared to the other possibilities: The issue with the first solution (which is how I was doing things to start) is that I have co-authors and need to upload the files to a single folder that they can then use to compile the latex files. Unless I force them to use the same relative file structure as I do, and have them download the master bib file each time this option does not work. Hammerite posted:Yes, that is something that you could do reasonably straightforwardly with the scripting language of your choice. Do you have any experience using a scripting language like Python, Perl, Lua, etc etc.? I don't know any of the scripting languages you mentioned, but with the sketch of how to accomplish this I think I can fumble my way through. Thanks for the insight into how to attack this problem. Lysidas posted:You could concatenate all of the .bib files together, symlink the single .bib file into each paper's directory, and fix the 'duplicate citation' errors/warnings if and when they happen. Not quite sure what this means, but I think I will go with the Hammerite's solution.
|
# ¿ Jul 3, 2012 23:01 |
|
ToxicFrog posted:How does splitting it into multiple files (that they still need to re-download each time they change) address this? When I have a separate *.bib file for each paper, the *.bib file is contained in the same folder that contains the *.tex files for the paper. When I send them the latest version of the paper, all the necessary files are zipped in one folder so that all they need to do is extract the files to a single folder and can go from there. With the master bib file idea, they would then need to put the master bib file in the appropriate (relative) folder, which is one step to many for my advisors. ToxicFrog posted:Hammerite's solution may be overkill, honestly. BibTeX is a pretty simple format and you don't really need (or want) a separate, non-BibTeX master file that gets processed into BibTeX. Revised version: I know what I want is probably overkill, but I would like to make certain that each time I make a change to a citation, that exact change occurs everywhere. If you wouldn't mind putting together the example implementation I would appreciate it.
|
# ¿ Jul 3, 2012 23:34 |
|
ToxicFrog posted:In that case the symlink idea will work perfectly. Merge all of the files, create a symlink in each paper's folder to the master file. When you zip the folder, the zip file will contain the master file the symlink pointed to when you zipped it, so anyone unzipping it will have the right file in the right place, no fuss. Thanks for this. I am going to look at the example and read up on the symlink stuff.
|
# ¿ Jul 4, 2012 00:32 |
|
Although it is overkill, I managed to code up a script(?) in python based on the help provided here. Thanks for the guidance.
|
# ¿ Jul 5, 2012 14:28 |
|
I am trying to find a better way to do the following because the solution I use is impractical when the number of groups (numGroups) gets large. I have a target number of workers (targetWorkerNumber) that I want, and I have numGroups number of groups where I can place workers. I also know the minimum and maximum number of workers I can place in each group (if it helps the maximum number of workers for each groups is the same, but the minimum number of workers can differ based on the group in question). I want to determine all possible permutations of workers that add up to targetWorkerNumber but also respect the minimum and maximum worker restrictions of each group. The code I am using now is given below. It begins with allocating the maximum number of workers to each group, and then performs a check to see if the number of workers in that permutation adds up to targetWorkerNumber. If not, it decrements the number of workers in the last group, and performs the check on the new permutation. However if the number of workers in the last group is decremented below the minimum number of workers for that group the number of workers in that group is reset to the maximum number of workers, and the number of workers in the next to last group is decremented, and so forth. Unfortunately I have found out that this is a horribly inefficient way of doing things. I now have 20 groups and each has a maximum of 8 workers, and this brings everything to a standstill. Any ideas on how I can improve the code/ an alternate way to do things? C++ code:
|
# ¿ Feb 12, 2013 04:58 |
|
HappyHippo posted:Do you need to do something for each permutation, or do you just need one that works? Because your code makes it look like you just need one (with the break; statement after the //do stuff). The number of permutations can get impractically large quite quickly, so doing something for each one might just not be possible no matter how efficiently you find them. Sorry I do need all of them, not just the one. The Gripper I will take a look at your code tomorrow morning, thank you for the help. Time for bed.
|
# ¿ Feb 12, 2013 06:48 |
|
HappyHippo posted:OK, so just to give you some perspective: DOH! Should have thought about the numbers involved. I guess anything I come up with will end up taking a very long time. Thanks for the help.
|
# ¿ Feb 12, 2013 14:39 |
|
I have what is similar to a knapsack problem, but with a twist: I have a list of volumes of different (non-mixable) liquids each with a priority score (lower denotes the liquid is more important), and a list of containers. For example the list of liquids and priorities is [(30gal, 1), (27gal, 2), (40gal, 1.5), (15gal, 3)] and the list of containers is [5gal, 5gal, 8gal, 10gal, 10gal, 10gal]. In this example there is not enough volume in the containers to accommodate all of the liquid. I want to determine how to assign the liquids to containers to maximize the weighted amount of volume carried. I cannot mix the liquids but it is okay to not take the full volume of one liquid and it is okay to not fully fill up a container. Does this sound like a problem that already has a solution I can use?
|
# ¿ Jul 11, 2013 21:25 |
|
ultrafilter posted:What's the exact objective function that you're trying to maximize? It's not obvious how the priority scores should be interpreted. If I have [(1, 1), (100, 2)] and a single 100 gallon container, I need to know whether it's better to take the one gallon of the high priority liquid or the 100 gallons of the low priority liquid. This is a good question, and not something I had completely defined yet. To be honest I need to define the 'priority score' precisely as well before I can define the exact objective function. I will have to think carefully about it and get back to you. Thanks for the initial help/ pointers.
|
# ¿ Jul 11, 2013 22:30 |
|
I have a small program I am writing that contains custom objects in it. For example I have a container object that has a name, maximum amount of liquid it can hold, types of liquid it can hold, cost of holding each type of liquid, and the current amount and type of liquid being held. I want to store this information (not hard code it into the program), and was wondering if there are any best practices for how to do this. Would I be best of using a text file and writing all the data in a specific format that I can then read in, or is there something better?
|
# ¿ Jul 24, 2013 15:38 |
|
Bunny Cuddlin posted:It depends on the language you're writing in. Some of them have built in facilities for storing and reading a configuration file. For instance, python has ConfigParser. The .NET way is generally to use an XML file. A json file would work too. Use something you can easily parse with features built into your language's standard library is my advice. Sorry I should have specified that Python is what I am using. I will look into ConfigParser.
|
# ¿ Jul 24, 2013 15:59 |
|
I have an idea for a programming project (hopefully in Python) but I am not sure on how to get started. I was hoping to get some ideas on how to accomplish the following: Given a Google maps route (road trip), I would like to produce a list of the counties that the chosen route passes through. I think that what I need to have is a list of all the US counties and the coordinates that define each county. Then somehow iterate over the route (say 500 feet at a time) and keep checking what county that part of the road is in. However I don't know how I would be able to accomplish this. Any thoughts/ pointers?
|
# ¿ Jan 4, 2014 19:25 |
|
I am trying to modify a bash script that looks like this:Bash code:
I am having trouble understanding what the line Bash code:
EDIT: Figured this out. Posting here in case anyone wants to know: Bash code:
Jose Cuervo fucked around with this message at 16:10 on Aug 14, 2014 |
# ¿ Aug 14, 2014 15:14 |
|
Jose Cuervo posted:EDIT: Figured this out. Posting here in case anyone wants to know: Another question. Right now if there are 10 lines in the param_file, ten processes will be started almost simultaneously. Is there a way to say that I want the first line to be done running before I begin the second line?
|
# ¿ Aug 14, 2014 17:37 |
|
Working in Python, but I think this is more of a general question. I have 2 lists of intervals (where an interval is a start and an end point and both the start and end points are inclusive). What I want is a single list of intervals that is the union of the two lists, but which identifies where the intervals overlap. For example if:Python code:
Python code:
Any ideas on how to do this (or if there is existing code that does this) would be welcome. Jose Cuervo fucked around with this message at 22:41 on Mar 10, 2015 |
# ¿ Mar 10, 2015 22:30 |
|
This question concerns implementing Common Random Numbers in a simulation model (coded in Python, but I think the question is language agnostic). The simulation is a small supply chain which has 4 factories producing goods and where I would like to be able to compare inventory policies. The amount of raw material used each day at each factory is a random variable (so 4 numbers drawn from the random number stream). The inventory policy at each factory determines when new raw material will be ordered so that the factory does not run out of raw materials, and the time it takes the raw material to arrive at the factory is a random variable (a single number drawn from the random number stream). In order to implement common random numbers I need to make sure that the amount of raw material used at each factory each day is the same regardless of the policy being used, however I cannot think of a way to ensure this happens using a single random number stream: under different policies the random number used as the time it takes a reorder to arrive at the factory can be a different random number in the random number stream. For example, if under policy_1 raw material is not reordered until day 6 at Factory 1, but under policy_2 it is reordered on day 4, and assuming that no other factories reorder, then under policy_1 the random number used as the time it takes a reorder to arrive is the twenty-fifth number in the random number stream, but under policy_2 it is the 17th. Thus it appears I need five random number streams (one for the amount of raw material used, and one each for the amount of time it takes a reorder to arrive at the factory). Am I missing something?
|
# ¿ Apr 21, 2015 17:50 |
|
Jabor posted:Using a unique random number stream for each factory's time-to-arrive doesn't seem anything like using common random numbers. Surely you just need two streams, one for each purpose the random numbers get used for? What I am concerned with achieving is (from the Wikipedia link): code:
The only way I can think of to guarantee that the same time-to-arrive is used in both (or really in all) policies is to have a unique random number stream for each factory's time-to-arrive.
|
# ¿ Apr 22, 2015 03:10 |
|
Jabor posted:Ah, sure. Absolutely no objection. My next question is how to successfully implement this. I need s = 5 unique random number streams for each simulation replication r. I also need to use the same s = 5 unique random number streams for the r-th simulation replication of the p-th policy. In Python I could initialize a single random number stream using r (the index of the simulation replication). Then the first of the s unique random number streams would be initialized using the first s draws from that random number stream: Python code:
|
# ¿ Apr 22, 2015 16:08 |
|
|
# ¿ May 8, 2024 00:18 |
|
I know that I can use the Google Maps Directions API to return a json file containing the directions from point A to point B, including waypoints and alternative routes if so desired. Doing this requires formatting a string to the specifications provided (e.g.: https://maps.googleapis.com/maps/api/directions/json?origin=New+York,NY&destination=Orlando,FL), and then sending a request:code:
|
# ¿ Feb 12, 2017 01:05 |