Optimization is the process of improving an existing program to make it work more efficiently or/and using less resources.

learn more… | top users | synonyms (1)

0
votes
0answers
13 views

Coerce optBlock in AlgDesign R package to only show certain treatments per row of blocks

Using the optBlock function of the AlgDesing R package, I can create a block design with 16 treatments, 12 blocks (columns), and 4 treatment per block (rows) with the following code: optBlock(~.,...
40
votes
7answers
7k views

In software programming, would it be possible to have both CPU and GPU loads at 100%?

This is a general question on a subject I've found interesting as a gamer: CPU/GPU bottlenecks and programming. If I'm not mistaken, I've come to understand that both CPU and GPU calculate stuff, but ...
4
votes
1answer
88 views

Do I need to declare a delay timer variable as volatile even if I access it from another module

This is a question more about using volatile to prevent optimization than about caching write/read of a variable. Particularly timer delay variables since I don't want to declare everything volatile ...
6
votes
0answers
223 views

What lambda function optimizations, if any, are planned for Java 9 and beyond?

I'm working on a high-performance project where Java 8's lambda functions are enormously useful. I've found, however, that they're memory inefficient when used en masse. For example, suppose I need to ...
5
votes
3answers
155 views

Do Javascript minifiers optimize for gzip?

Case1: There are two snippets of code that are very similar and very gzip-able, one at the start of the document and the other is beyond 32kb at the end of the document. Does the minifier bring the ...
0
votes
0answers
32 views

Optimal Simplification of Transposition Products

I am looking to take a product of a large number of transpositions, and boil it down to a smaller number of products. I have the following code, and would like some input on efficient ways to boil ...
2
votes
1answer
55 views

Pre-computation strategies when solving multiple linear equations with the same matrix?

Often in modeling, data processing, and optimization; the intensive portions of the code can often reduce to solving a lot of linear equations. e.g. solve for x1 in A x1 = b1 solve for x2 in A x2 =...
-2
votes
0answers
196 views

Is early optimization the root of much evil? [duplicate]

I believe that perfomance optimization must start as soon as possible. I think that the classical reasons to put it off are fundamentally wrong. The main points why the optimization activity has to ...
0
votes
0answers
13 views

Latency in creating configuration in apache commons configuration

I am planning to use Apache commons configuration (https://commons.apache.org/proper/commons-configuration/) to merge various configuration files. Since for me, the configuration file names are ...
3
votes
5answers
110 views

Use Exceptions for control flow in order to increase performance?

I add a lot of elements to a list of lists. If the list of lists my element should be saved to, does not exist yet, I handle this by catching an exception and adding a new list to my list of lists. ...
0
votes
0answers
20 views

How to calculate a lookup table index from comparing 3 variables treating equality as distinct cases

My code needs to use different lookup table values depending on the relative order of 3 simple input numeric variables a,b,c. If any of a,b,c are equal that's considered a distinct case. I'm looking ...
6
votes
5answers
384 views

Is it wise to rely on optimizations?

Should I write my code to be clear what I am doing and rely on the optimizer to clean up my code efficiency, or should I be obsessive about getting every last ounce of power out of my code? And how ...
1
vote
1answer
47 views

The optimal way to reschedule appointments

Let's say I have the following appointments: Appointment 1 = 1:00 Appointment 2 = 2:00 Appointment 3 = 3:00 Appointment 4 = 4:00 I need to reschedule all of these one hour later: Appointment 1 = 2:...
5
votes
5answers
271 views

My brute force solution is too slow, needed DP solution [closed]

Concise problem definition: given n and {a,b,c}; (1 ≤ n, a, b, c ≤ 4000); Constraint -> a*i + b*j + c*k==n (i,j,k>=0); Objective-> maximize(i,j,k) Examples: n=47 and a=7,b=5,c=8 -> ...
4
votes
1answer
138 views

Word ladder efficency problem

I have a problem dealing with word ladders. The problem is: given two words and a dictionary file, find the shortest word ladder between the two words. So if given the words cat and pot: cat -> ...
1
vote
1answer
79 views

Clairvoyance in caching - optimal strategies?

This question relates to the question here, but I'll generalise it so that you can answer effectively without reading all of that. Context: Imagine you had a large set of data greater than your ...
25
votes
11answers
2k views

How to deal with misconceptions about “premature optimization is the root of all evil”?

I've encountered many people who are dogmatically against anything which can be considered "optimization" in the general English-language sense of the word, and they very often quote verbatim the (...
2
votes
1answer
59 views

How to optimize a bloated entity that causes a huge query

I have an application that exposes a series of Web services. One of my entities has a bunch of one-to-many and many-to-many relations to other entities. My transactionality level is at DAO, and I'd ...
2
votes
4answers
95 views

How does a query execution plan affect query execution?

I have read some articles on SQL Server query optimization. The point I get is SQL Server generates a query execution plan for each stored procedure when it's executed for the first time. Those ...
0
votes
1answer
42 views

python snippet optimization explanation

I'm attempting optimize and figure out why for input n a function I wrote f(n) appears to never finish executing when n > 26. TL;DR I need to figure out how to find the complexity of various python ...
0
votes
0answers
58 views

Using counter or constant for parameter position

Suppose that I have the following Java code: int i = 0; PreparedStatement statement = con.prepareStatement("SELECT * FROM table " + "WHERE field1 = ?, field2 = ?, field3 = ?..."); statement.set**...
1
vote
1answer
84 views

Recieving errors without engaging in excessive communication when using sockets

I'm currently writing a program that communicates with a server over TCP sockets. I originally planned for the communication to include a message confirming successful communication at the end of ...
2
votes
3answers
138 views

Is denormalising a data structure essentially a code optimisation, to which the normal rules apply?

One of Bloch's Effective Java items 55: Optimize judiciously extends Jackson's rules on optimization: Rule no. 1: Don't optimise! Rule no. 2 (for experts): Don't optimise yet! Extra ...
0
votes
1answer
187 views

Approaching Particle Swarm Optimization with optimization problem, how to use PSO with it?

I am learning Particle Swarm Optimization. The problem is to find the pair of number whose sum is lowest. Lets say we have some numbers z1,z2,z3,z4 Number Value z1 -2 z2 -3 z3 3 ...
0
votes
0answers
84 views

Decision making algorithm

I'm currently solving an optimisation problem of my own design, just to experiment and learn a little something. Here's the concept: I have a user that starts at home. The objective of this user is ...
0
votes
1answer
140 views

Are there compilers which optimize the use of mathematical functions?

Today while programming I stumbled upon the following question - are there any compilers which optimize based on mathematical assumptions? For instance in cases like unsigned int i,b; (i,b not ...
0
votes
3answers
77 views

How to optimize iterable queries with external arguments

I will use C# here as an example, but my question is about any language. My question is from framework to compiler perspective (i.e the solution can be by implementing given idea inside compiler) ...
0
votes
2answers
158 views

Optimization problem where to start, what algorithms to use? [closed]

I have an optimization problem and I was wondering where to start from to be able resolve it. I think it can be solved with an NP-complete algorithm but I am not sure where to start from. The problem ...
2
votes
1answer
113 views

Improving sampling algorithm

I am having a bit of trouble designing a new feature at the moment. It is part of a resource management system. I was wondering if anyone has experience doing anything similar. I'll try to explain: ...
3
votes
3answers
127 views

What can qualify for potential tail call recursion (TCO) optimization or tail recursion elimination (TRE)

Short question is: what can qualify for potential tail call recursion optimization (TCO) or tail recursion elimination (TRE) if the compiler or interpreter supports it. The summary of this question ...
2
votes
0answers
79 views

Program to select N integers with constraints [closed]

I need to write a program which takes 4 inputs as follows N = The number of integers to be generated (10 < N < 10000) Start = The minimum value of the integers (100 < Start) End = The ...
2
votes
1answer
139 views

Maximizing Value and Volume, minimizing weight - Knapsack

Trying out a Knapsack variant where the rules are Any item you take must fit completely in the bag Usable metrics of the bag are length(l),width(w),height(h) and you can assume that if the products ...
3
votes
1answer
138 views

How to safely and cheaply delete a directory's contents that are constantly being deleted/overwritten

I'm coding something that will check a specific static location's directory, and if it exists, and a certain process has not run in n minutes, it deletes that directory's files and all sub-directory ...
5
votes
1answer
237 views

Combinatorial Optimization: Filling a Bag with Sand

I have an interesting "real-world" combinatorial optimization problem that I need to solve programmatically, however I have yet been able to whiteboard a good strategy. The task is similar to the ...
-1
votes
1answer
103 views

Sorting an array based on another array's order, quickly [closed]

There are two arrays of maps. The first array contains maps of ID values in a specific order (but not necessarily either pure ASC or DESC ordering): // pseudo code first := [ {"id": 1}, {"...
0
votes
1answer
121 views

Optimization: How much time saved is considered worth it? [closed]

I was reading up about branch predictions and cache misses, and have decided to read what every programmer should know about memory. But I'm not sure how much low level knowledge do I need to have to ...
0
votes
1answer
74 views

Multiple variable assignment vs HashTable lookup

I'm writing a CUIT ( Coded UI Test ) and I'm replacing variables with data fetched from a csv. Example: this.UIMap.IDBParams.UITboxFsEditText = TestContext.DataRow["num_fs"].ToString(); this.UIMap....
0
votes
1answer
127 views

storing single character value use string or int C# [closed]

While storing single character value for the purpose of status, gender, delete_flag etc. which is better data type string or int. Suppose :: status = A/I or status = 1/0 gender = M/F or gender = 1/0 ...
2
votes
2answers
203 views

Do nested conditionals have a significant performance impact? [duplicate]

This is a question that lives in my mind from a long time. Does the use of multiple nested conditional statements impact the performance of a taken code? So far I know that programmers have created a ...
3
votes
0answers
154 views

How to distribute a number of elements in a bucket so that it is within a range?

I have 50 elements n1, n2, n3, ... , n50 and a limited number of buckets, say 5 buckets and each bucket can hold a range from, say 100 to 150 only (which is nothing but the sum of the elements in that ...
1
vote
0answers
45 views

Cost of cache coherency/sharing data across multiple cores?

If I have two CPU cores, one is writing a particular cache line and the other core wishes to Read Write the same cache line, what are the costs (in cycles) for doing so? I am a little unsure ...
3
votes
3answers
79 views

Premature memoization on obvious cases

In the code below there will be several instances of MainClass. class MainClass(object): def f(self, x): # expensive operations. # ... return 'something' Each instance ...
1
vote
3answers
3k views

Linking two or more different programming languages

I would like to ask how optimizer software written in C/C++ can be linked to simulator software written in FORTRAN or any other language. I have copied the section of journal article of Singh and ...
4
votes
2answers
87 views

How do you avoid dominant solutions in multi-objective simulated annealing?

Imagine an RPG game were you can cary N items, and you want to maximise your damage, attack speed and armour, given a set of items. I implemented simulated annealing where a permutation simply ...
0
votes
0answers
62 views

Microcontroller oLED Display Buffering Optimizations or Alternatives For Speed?

I'm developing a UI/Layout for a 128 x 64 oLED Monochrome Pixel Display. I've got a small netMF microcontroller driving the display via SPI at 40mhz. I'm using some basic methods, like these here, to ...
6
votes
5answers
368 views

Can a pimpl variation be implemented without any performance penalty?

One of the issues of pimpl is the performance penalty of using it (additional memory allocation, non-contiguous data members, additional indirections, etc..). I would like to propose a variation on ...
0
votes
1answer
100 views

Optimizing instant notifications

Scenario To deliver instant notifications to the client, I'm sending an AJAX request to a PHP page that checks if there are new notifications: if there are, it outputs them, otherwise it sleeps for ...
3
votes
1answer
112 views

Can fast, optimized server calls collapse a server?

I've followed a series of optimizations to make our APIs faster. We microoptimized a lot of PHP code to faster, native methods, we unsed variables where they were not being used anymore, and basically ...
9
votes
3answers
2k views

My algorithm that extracts the largest box that can be made from smaller boxes, is too slow

Imagine a cube based world (such as Minecraft, Trove, or Cube World) where everything is made up of identically sized cubes and all the cubes are of the same kind. The goal is to represent the world ...
3
votes
2answers
101 views

Reducing a sequence of array modification operations (insert, sort, replace, remove)

Given a plain array of values, e.g. ["Apple", "Orange", "Banana", "Strawberry"] and a list of operations from the set of [insert, delete, sort and replace], e.g. [ {cmd: "insert", index: 2, ...