r/optimization

▲ 14 r/optimization+1 crossposts

Learning optimization

Hi, I am new to optimization. I am reading an introduction to optimization by P.G. Ciarlet. It gives me all theorical aspects.

In parallel, I would like to learn how to use optimization. I might implement the algorithms in Python for the practical aspect. But I guess that in general, we use library to solve optimization problems. Where should I look ? Are there any library to know how to use ?

reddit.com
u/Taendyr — 1 day ago
▲ 20 r/optimization+8 crossposts

Hi everyone,

I’m currently working on a game called Arrow Puzzle Escape. It’s a kind of puzzle/maze game where you solve levels by “pulling out” arrow chains and figuring out how they interact to complete the puzzle.

Right now I’m developing a procedural level generator for the game. The idea is that the generator takes a user-selected area on a grid and fills it with arrow-based structures to create a playable puzzle.

The generator works in two main phases:

  1. It first splits the selected area into “chains of cells”, somewhat similar to Tetris-like shapes.
  2. Then it tries to assign directions to these shapes, effectively turning them into arrows that form a solvable level.

The main issue I’m running into is that the first phase doesn’t currently include any logic to prevent “deadlocks” — situations where arrows end up blocking each other in a way that makes the level impossible to solve.

For small grids (like 10x10 or 30x30), everything works fine. However, for larger grids (40x40, 50x50 and above), the generation time grows exponentially, and the number of invalid layouts increases significantly. At that point, generation becomes practically unusable.

I feel like the issue is not just optimization, but more about the structure of the algorithm itself. I’m looking for ideas on how this approach could be redesigned so it can reliably generate larger solvable levels without exponential retries or deadlock situations.

Also, stepping back a bit — I’m starting to wonder if this kind of approach is even fundamentally scalable in general. Is it actually possible to design a procedural system like this that reliably produces valid 50×50+ solvable levels without falling into exponential failure rates?

I’ve attached a video showing a quick demonstration of how the generator currently works in Unity. If anyone is interested in digging deeper or experimenting with ideas, I can also share the source code of the project.

Any suggestions or feedback would be greatly appreciated. Also, I would be very happy to credit anyone who helps significantly with improving or solving this algorithm inside the game.

u/custybeam — 5 days ago

Hi there,

I'm kind of concerned about that since the moment I decided to focus my masters degree in hyper-heuristics. I'm coming from logic/computational complexity background, and recently I re-discovered optimization and all these related stuff. I like the fact that here in optimization we are really near of those theoretical aspects of computing, but from a more pragmatic perspective, and research in this area is almost always easily translated into practical terms.

My point: all those specialized techniques in optimization relies in the fact that at the core, there's an NP problem for that we don't have a poly-time algo to get its solution. And that's one of the biggest motivations of all these interesting theoretical frameworks.

However, P vs NP is an open question. So I've been trying to imagine the scenario where someone proves that P=NP. In that case, what would be the consequences for this field?

I asked my professor about this, and he said (joking) "I might lost my job".

What do you think?

reddit.com
u/r_card_ — 10 days ago
▲ 2 r/optimization+1 crossposts

I have a question about genetic algorithms in practice.

As far as I understand, they have the advantage of not needing derivatives and not getting stuck easily in local maximum/minimum, but they are relatively slow due to the large number of evaluations.

I wonder if anyone has tried using a neural network in parallel, so that after a certain point it “filters” candidate solutions before they are properly evaluated.

In other words, something like a surrogate model that learns which solutions are worth considering.

Has anyone worked on something like this in practice? Does it really help or does it end up making things more complicated?

In

As

reddit.com
u/Opt4Deck — 11 days ago
▲ 7 r/optimization+1 crossposts

>This post presents the use of the Adjoint method for parameter estimation in an R–L circuit.

Hi everyone! 👋

Lately, I have been exploring the possibilities of the Adjoint Method in optimization! Specifically, the above example uses the method to estimate two parameters and I wanted to share it with the community.

I’m solving a parameter estimation problem in an R–L circuit, where the goal is to recover source frequency (ω) and phase (φ) by minimizing the error between fitting and aim curves.

What struck me is how efficient gradient-based approaches are in such well-defined physical problems, especially compared to "black-box" tools that require much more evaluations.

I was also excited by the fact that the method guarantees the smallest possible number of calls to the objective function to calculate the gradient-vector, regardless of the number of variables! 🚀

Questions:

  • Does anyone have experience with Adjoint vs other sensitivity analysis methods?
  • Does anyone want the mathematical proof of the method?

P.S.: I'd be happy to share the code and notes if anyone’s interested.! ✍️

u/Opt4Deck — 8 days ago

The problem. You have a dataset of B rows. Each row is an input x (n numbers) and a measured response y (one number). You want to find the rows with the smallest and largest y.

Step 1: Lift. Take each row (x, y) and place it as a point p in (n+1)-dimensional space, choosing the position so that the distance from the origin equals R + y (where R is a large positive offset, big enough that R + y > 0 for every row). After this step:

  • big y → point is far from origin
  • small y → point is close to origin
  • "compare two y values" is now the same as "compare two distances to origin"

https://preview.redd.it/578u4myhjbzg1.png?width=1560&format=png&auto=webp&s=f8c94f189281f2860dd0423a900c8118bfb35164

Step 2: Fold. Push every point through a sequence of Householder reflections (mirror-flips across hyperplanes). The key property: a reflection preserves the distance to the origin. So no matter how many times you fold, each point stays on its own hypersphere of radius R + y. The fold sequence is precomputed once for each input dimension n and stored in data_householder/dim_NNN.npz.

https://preview.redd.it/70w1032mjbzg1.png?width=2200&format=png&auto=webp&s=96b862bde5c3cc24f3432808074313753a477951

Step 3: Read off. Compute ||folded_p|| for each row. The row with the smallest norm is argmin(y); the row with the largest norm is argmax(y). The folds preserved norm, so ||folded_p|| = R + y.

Step 4: Recover the original row. You now know the value of R + y for the optimum, but you still need which row it came from. A hashmap built ahead of time maps quantized |R + y| values back to row indices.

Step 5: Fallback. Floating-point drift can occasionally make the hash lookup miss. When that happens, fall back to a recursive split: chop the dataset in half and recurse until the optimum row is unambiguously located.

That's the whole pipeline: lift → fold → norm → recover (→ fallback if needed).

Repository: https://github.com/BoolHak/pizza-fold

reddit.com
u/Rich_Yam5419 — 8 days ago

Hello everyone!

I'm looking for resources on optimization algorithms for black-box objective functions that are expensive to evaluate.

In my case, a single evaluation takes about 6 hours because it involves an FEA simulation. I also have access to a cluster, so I can run 3–5 evaluations simultaneously.

I have already tried Bayesian optimization and obtained good results, but I wonder whether there are other good alternatives, especially for cases where several trial points can be evaluated in parallel.

reddit.com
u/CryptographerAny4589 — 10 days ago