Rajath Ramakrishna

Constraint relaxation as a mental model

Posted on — | 2 min read

Like my previous post about knapsack problem, constraint relaxation is another mental model I read about in book Algorithms to Live By. When I read it, I again felt the same way I did for the knapsack problem - it’s common and we do it all the time.

Constraint relaxation is when you encounter a problem that seems complex enough (think too many constraints) that you feel a little overwhelmed to tackle it head on. So, instead you decide to tackle a smaller/simpler version of the problem. Once you figure out how to do that, you add more and more complexities (or constraints) until you get to the original problem statement.

A simple example is when you’re trying to implement a feature or a business logic that is complex for which you have to learn something new, you usually implement a smaller/simpler version of it (thereby relaxing constraints) and then work your way forward.

Where this has helped me is sometimes I get stuck thinking about the problem at hand and after a while I remind myself to relax the constraints and start making progress. Again, it’s something we do automatically a lot of times. But having it as a mental model that we can pull out whenever we get stuck really does come in handy.