New answers tagged

1

Bloch's rules on optimization are just a variation on "premature optimization is the root of all evil" which, correctly interpreted, means "Measure first, before you optimize. Make sure that your optimization is actually going to give you the performance benefit you are seeking, before you spend the time and money optimizing." I don't necessarily agree with ...


1

I took the liberty of adapting a portion of my thesis work to more clearly articulate what Particle Swarm Optimization is and how it works. Many existing resources on PSO are not really that great or useful, in my experience. Hopefully this is more clear. It's comprehensive and has some additional references which might be helpful. The following is the ...


4

Compilers routinely engage in strength reduction. One common example of which is reducing multiples to adds (as adds are typically faster than multiplies). i*2 transformed to i+i is faster on many machines, (and this is sometimes transformed to i<<1 instead). Implicit multiplies commonly happen in for-loops over arrays (whose element size is > 1 ...


3

I think I found the solution -- the key is to follow deferred execution of sequences (iterables). Count should not return int type, but some Counted type which would keep reference to the sequence. With implicit conversion to int it would integrate smoothly, but having overloaded some operators it could process even infinite sequences.


0

Ok so the code for Count() in C# would be: public static int Count<T>(this IEnumerable<T> enumerable) { var count = 0; using (var enumerator = enumerable.GetEnumerator()) { while (enumerator.MoveNext()) count += 1; } } It's pretty easy to imagine that if this gets inlined, the predicate is pushed into the ...


1

Do you absolutely need these huge collections in your business layer? Where do these huge collections come from? If for instance, they come from a database, then it might be a good idea to filter/count/sum the result on the database-side of things. This will save loads of processing-power and memory. Is your program absolutely required to handle these ...


1

I did a stint at a huge printing company. I believe we ran into the same problem. Let me rephrase it. The constraints: An industrial printing plate costs X dollars to layout and fabricate. It's not an insignificant amount. Each printed sheet costs Y dollars. It's a smaller number but can add up. There are N unique "rectangles" to print. For the sake of ...


4

What you are trying to do is variation on a Bin packing problem. Effectively you are placing items into bins (plaques) and trying to minimize the wasted space, since in your example wasted space directly corresponds to lost money. The wikipedia article shows how this can be done/solved. You may end up with an optimization problem on top of this, because you ...


6

First, reduce the problem to a test of availabilities "per day". All your examples are using ranges for only one day, but if you also want to support a range like "Monday 10:00 to Wednesday 14:00", break this down into three tests for "Monday 10:00 to 23:59", "Thursday 00:00 to 23:59" and "Wednesday 00:00 to 10:00". For each day, store an interval ...



Top 50 recent answers are included