AI optimization algorithms

A drawing of a brain with one side in black and white and the other in multiple colors.
A drawing of a brain with one side in black and white and the other in multiple colors.
Photo made with Canva.

The goal of linear programming is to minimize a cost function that has some number of variables (x₁, x₂, x₃) all the way up to x𝑛. Those variables are involved in things that I want to know the values to, and they might be multiplied by a coefficient and then added together.

With linear programming, we are just dealing with linear equations, so we’re not going to square or cube anything.

Also, we’ll have some linear constraints:

  • a₁x₁ + a₂x₂ + … + a𝑛x𝑛 ≤ b
  • a₁x₁ + a₂x₂ + … + a𝑛x𝑛 = b

With the following bound for each…

Image for post
Image for post
Designed by

When you have a Next.js application you probably use Styled JSX to write the style of your components. It is because Next.js includes Styled JSX by default in your project. If this is your case or you’re just using Styled JSX by yourself and you want to implement a Dark/Light mode switch on your website this article is for you.

We will implement a simple theme toggle (Dark <-> Light ) using some techniques with this CSS-in-JS library and JavaScript in four steps.

First Step: Defining Your Themes

The first step is to choose the right colors for your dark and light themes. Defining the colors that will fit between these two themes can become a challenge. It is because you have to take care of design principles like card depth, background color, font color, usability, and accessibility (a11y). Here is a good video that shows some best practices that you (or your designer) can follow in order to create a successful color decision. …

AI Optimization Algorithm

Image for post
Image for post

The Simulated Annealing algorithm is commonly used when we’re stuck trying to optimize solutions that generate local minimum or local maximum solutions, for example, the Hill-Climbing algorithm. So we use the Simulated Annealing algorithm to have a better solution to find the global maximum or global minimum.

Why Simulated Annealing?

It’s called Simulated Annealing because it’s modeling after a real physical process of annealing something like a metal. When you heat a particular metal, there’s a lot of energy there, and you can move things around quite systematically. But over time, as the system cools down, it eventually settles into a final position.

We’re going to simulate that process of some high-temperature systems, where things can move around quite frequently but, over time, decreasing that temperature until we eventually settle at an ultimate solution. …


Cesar William Alvarenga

Software Engineer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store