|
I suggested that a well-known algorithm may be applicable, and from the posting I guessed that the OP would not be aware that tried and tested source code was available - so I posted a link to one. It would be silly for a professional programmer to try to solve the multiple knapsack problem without at least considering the standard codes. Get offended if you like - it's your blood pressure.
From re-reading the original post, the fact that the standard lengths are not fixed but come in increments of 5' means that the multiple knapsack is not optimal. It would give you an efficient way of quickly testing different bundles - e.g. if you need 73' as in my example, you could try your inventory plus 3 lengths of 25', 3 of 30' and see if a solution existed.
If the number of lengths is small then the problem can be efficiently solved with an exhaustive search, but the complexity quickly escalates as the number of lengths increases.
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
Hey everyone,
I've been working on a bit of code that will calculate the time difference (hours/minutes) between two times, but only include business hours in that calculation. I have an iterative solution that works alright as long as "work hours" start and end on even hour boundaries. I could get the minute calculation to work by decreasing the size of my iterative step from hours to minutes, but it seems to me there must be a better way.
I've tried a couple of methods, and done some research on the problem, but haven't been able to come up with anything that really satisfies me. Any ideas?
Again, the problem in essence: calculate the amount of time (down to minutes) between two arbitrary date-times, counting only an arbitrary set of "working hours." All without simply looping over every minute in between start and end.
Don't sweat too much: at this point, it's more of an intellectual exercise than a practical necessity.
--
Chris Wilson
|
|
|
|
|
Convert the times into minutes after an arbitrary starting point.
Calculate the number of minutes the employee worked without taking non working periods into account.
Do an overlap test between period worked and the each sequential non work period. IF there's an overlap subtract the amount from the total.
--
If you view money as inherently evil, I view it as my duty to assist in making you more virtuous.
|
|
|
|
|
Hello,
I must calculate the lateral acceleration of a vehicle ( auto / motorbike ) using the data from a gps. can you help me? How information I have only the speed, which is the corrected formula?
Thanks
|
|
|
|
|
assume that you have 3 points: (X1,Y1)[sampled at time T1], (X2,X2)[sampled at time T2] and (X3,Y3)[sampled at time T3]
let semplify the problem: Y1=0; Y2=0.
Then, if there is null lateral acceleration Y3 must be =0, if not compute it as
a=Y3/(T^2) where T is the time difference T3-T2
If Y1 and Y2 are different from 0 then you have only to estimate the linear path and compute the lateral offset gained at the point 3. Divide it by T^2 again.
I hope
Russell
|
|
|
|
|
Back to 1st year physics:
Velocity (speed) = delta (change in) position over time
Acceleration = delta velocity over time
single point iterative solutions are innacurate without exact position, and gps does not give you exact position, but it will give you a noisy approximation:
newvelocityx = (newpositionx - oldpositionx)/sampletime
newaccelerationx = (newvelocityx - oldvelocityx)/sampletime
http://230nsc1.phy-astr.gsu.edu/hbase/mot.html[^]
The better way is to filter the data, especially from a GPS simultaneously with calculating the velocity. but then you get into a whole new field of calculations. The correct formula is the one that matches your data and your need. There are many ways to solve this, so many formulas.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
can you help me with example?
Alex
|
|
|
|
|
AlexB47 wrote: can you help me with example?
Kalman filters
Alpha Beta Gamma Filters (sometimes called improved Alpha Beta Filters)
if real-time is not a problem, then you can go with least-squares curve fit and similar constructs.
You're talking about extracting 2nd order functions from noisy data if all you have is GPS.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Hi, i am currently doing a project that require my .net website to be able to make some medical diagnosis given a set of symptoms.
Is neural network the way to go?
or shld i try other stuff like prolog?
if neural network is the way to go, how can i go about doing it?
is matlab the correct tool to use?
pls help
thks alot
|
|
|
|
|
This is an Expert System.
Try using one of the languages like Lisp
But I dont know how to use them in the web.
|
|
|
|
|
Hi,
i understand tt matlab sw has a neural network toolkit that enable developers to simply train the nodes and use the network.
and we can simply interface the create program file by means of com
it tt really possible ?
tt means i dun have to do much coding?
|
|
|
|
|
I'm not entirely sure what to even Google for this particular algorithm, so any insight would be much appreciated.
The following is the problem I need to solve:
Say I have a list of many raw items, with some repeats (the number doesn't matter, just assume it's more than three or 4. It could be several hundred, it could be 5).
I have ANOTHER list of possible combinations of those items. We'll call these recipes. Each recipe can be created out of 3 of the other items.
The algorithm I need to create will do the following:
* Determine which recipes can be created out of the list of raw items.
* Determine the OPTIMAL combination of recipes. That is, I want to minimize the number of remaining items.
Yes, I could do this the brute force way - if I wanted my program to run all night. I KNOW there are implementations of this algorithm that will run in mere seconds.
It has been 6 years since I took my CS class on algorithms, so I no longer remember what this is called. Doesn't it have something to do with Hamiltonians? Consequently, it's hard to search Google for it
If you remember what this is and/or can point me the right direction, I'd appreciate it!
More Info
This is a problem I've set for myself simply to re-develop these skills. This is not homework or work, I just want to figure out how to do it.
Also, this actually IS a way to figure out how to make real food recipes. I have a game I play where I can get lots and lots of raw ingredients, and I can make recipes out of those ingredients. I've gotten sick of referring back to the list of recipes, so I wanted to make a program that will do the crunching for me. I figured this would be a perfect opportunity to use to remind myself how to solve these types of problems.
The early bird who catches the worm works for someone who comes in late and owns the worm farm. -- Travis McGee
|
|
|
|
|
You might be looking for the Simplex algorithm. I think the restriction is that the combinations have to be linear to be able to use it. I'm assuming that since it's called "linear optimization".
Save an endangered species. The American Engineer.
|
|
|
|
|
That's it!
Thanks!
I don't know if this problem is even solvable - seems so simple, but then, so does the Traveling Salesman. I suspect this problem is probably NP if it doesn't have sufficient initial conditions. But at least I know where to look now
The early bird who catches the worm works for someone who comes in late and owns the worm farm. -- Travis McGee
|
|
|
|
|
In .Net the Image class has a GetThumbnailImage method, which returns a thumbnail image of the image in question. Now I know next to nothing about math, but can anyone suggest a good resource which explains how this thumb nailing process works?
Me: Can you see the "up" arrow?
User:Errr...ummm....no.
Me: Can you see an arrow that points upwards?
User: Oh yes, I see it now!
-Excerpt from a support call taken by me, 08/31/2007
|
|
|
|
|
|
Interesting tool - unfortunately it only shows that the .Net funtion wraps a GDI+ funtion:
internal static extern int GdipGetImageThumbnail(HandleRef image, int thumbWidth, int thumbHeight, out IntPtr thumbImage, Image.GetThumbnailImageAbort callback, IntPtr callbackdata);
Me: Can you see the "up" arrow?
User:Errr...ummm....no.
Me: Can you see an arrow that points upwards?
User: Oh yes, I see it now!
-Excerpt from a support call taken by me, 08/31/2007
|
|
|
|
|
That method is used to define a status object. It that calls another function, but it still might be pointing to a wrapper.
|
|
|
|
|
for a component we are using we need a color to be converted to a hex number (this is no problem my college wrote the code for it) but now we need that number (wich is stored in a sql db) to be converted back to a color (for displaying purposes)
this is the code to convert a color to number:
Dim R As Byte = &HFF - color.R
Dim G As Byte = &HFF - color.G
Dim B As Byte = &HFF - color.B
Dim co, cn As Integer
co = R + 256 * G + 256 * 256 * B
cn = &HFFFFFF - co
Return cn
anyone know how I can 'revert' this conversion so that I get the color back
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistaks.
|
|
|
|
|
have a look at Color.FromArgb()
TDDragon wrote: The only way we learn is by making mistaks
You can also learn from reading documentation.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Luc Pattyn wrote: have a look at Color.FromArgb()
that was the first thing I tried but it doesn't return the correct color
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistaks.
|
|
|
|
|
TDDragon wrote: it doesn't return the correct color
if you create a Color from its RGB components (within their valid range) and then extract
its components again, you get the same RGB values you started with. This proves nothing
is wrong with FromArgb().
If it does not work for you, you did something wrong elsewhere. Why does your code invert the
color components (0xFF-...)? Did you forget to invert them a second time?
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
well we are working with a component (datawindows) and in order to get that component to display the same color as was picked in .NET we need to convert them (that is what the above code does).
But now I have to display the color that has been saved to the db (in this converted state) in .NET. And that is where I'm stuck.
The problem is that I can't get the RGB and A extracted back from the converted integer
maybe an example would help
I used the color red for this one:
color.toargb(color.red) = -65536
put red true the conversion for the component and we get: 255
conversion: (255-255)+(256*(255-0))+(256*256*(255-0)) = 16776960
16777215-16776960=255
now getting the number in bold back isn't a problem the problem is that I don't know how to get R,G and B back from the above formula.
once I have these it's indeed a simply putting them thru the fromargb methode
hope this clears things up a bit
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistaks.
|
|
|
|
|
I am using C# syntax here:
So what you are saying is you have a hex integer c=0x00bbggrr where rr,gg,bb are the
255-complement of R,G,B and you need to figure out the values for R, G and B?
int r=c%255;
int b=(c>>8)%255;
int g=(c>>16)%255;
Color col=Color.FromArgb(255-r,255-g,255-b);
BTW there is no need for magic constants such as 16777215 (which is 0x00FFFFFF)
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
somehow that doesn't work I think that this line of code (from the conversion) is the cause off all this trouble:
co = R + 256 * G + 256 * 256 * B
if I use you're code I keep getting 0-values for R,G,B nomatter wich color I'm using
Luc Pattyn wrote: BTW there is no need for magic constants such as 16777215 (which is 0x00FFFFFF)
I know but on paper it's easier to look at the number
to make it easier to read here is the entire code again
Dim R As Byte = &HFF - color.R
Dim G As Byte = &HFF - color.G
Dim B As Byte = &HFF - color.B
Dim co, cn As Integer
co = R + 256 * G + 256 * 256 * B
cn = &HFFFFFF - co
Return cn
'cn' is the value stored in the db and also the value that needs to be converted back to a color
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistaks.
|
|
|
|