Skip to content

Linear Programming Solver (2D): Implement a simple linear program solver for problems with two variables. You can visualize the feasible region (it'll be a polygon) and the objective function, and then implement an algorithm (like the simplex method or a graphical method) to find the optimal solution.

Notifications You must be signed in to change notification settings

Rrakeshkrrakesh/LPsolver2D

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

LPsolver2D

Let's start learning about convex optimization! We'll begin with the fundamentals and gradually explore more advanced concepts, using practical examples along the way.

What is Optimization?

Optimization is the process of finding the best set of inputs (variables) to achieve a desired outcome, subject to certain constraints. The "best" outcome is typically defined by a function we aim to minimize (like cost, error, risk) or maximize (like profit, performance).

Example: The Lemonade Stand

Imagine you're running a lemonade stand. You want to maximize your profit. Your variables might be:

x1: Price per cup

x2: Number of lemons to buy

x3: Amount spent on advertising

Your profit function (f) might look something like this (this is a simplified example):

f(x1, x2, x3) = x1 * (a - bx1) - cx2 - x3 content_copy Use code with caution.

where a and b are constants related to customer demand (higher price, lower demand), and c is the cost per lemon. You have constraints:

You can't buy a negative number of lemons: x2 >= 0

You have a limited budget for lemons and advertising: c*x2 + x3 <= budget

This is an optimization problem! You want to find the values of x1, x2, and x3 that maximize f, subject to your constraints.

Why Convex Optimization?

Not all optimization problems are created equal. Some are incredibly difficult to solve, while others are relatively easy. Convex optimization problems fall into the "easy" category. They have two key properties:

Convex Objective Function: Imagine the graph of your objective function. If you connect any two points on the graph with a straight line, the line segment lies above or on the graph. Think of a bowl shape.

Convex Constraint Set: The set of feasible solutions (points that satisfy your constraints) is convex. This means if you connect any two feasible points with a straight line, every point on that line is also feasible.

Example: The Lemonade Stand Revisited

Our lemonade stand profit function might not be convex (depending on the values of a and b). However, a simpler cost function, like the cost of ingredients cost = cx2, is convex (it's a straight line!). And our constraints (x2 >= 0 and cx2 + x3 <= budget) define a convex set (in this case, a triangle in the x2-x3 plane).

The Power of Convexity:

If a problem is convex, any locally optimal solution (a point that's better than all its nearby neighbors) is also globally optimal (the absolute best solution across all feasible points). This is huge! It means we can use efficient algorithms to find the best solution, and we can be confident we've actually found it.

What's Next?

In the next lessons, we'll delve deeper into:

Convex sets: We'll explore different types of convex sets like polyhedra, ellipsoids, and cones.

Convex functions: We'll learn how to recognize and construct convex functions.

Optimization algorithms: We'll study algorithms like gradient descent and Newton's method for solving convex optimization problems.

This is just the beginning! We'll also explore duality, a powerful concept in convex optimization that provides alternative problem formulations and valuable insights. And we'll see how convex optimization is applied in various fields, from machine learning and statistics to finance and control.

Let me know when you're ready to move on to the next topic, and feel free to ask any questions you have along the way. We'll go step-by-step, building a solid understanding of convex optimization.

About

Linear Programming Solver (2D): Implement a simple linear program solver for problems with two variables. You can visualize the feasible region (it'll be a polygon) and the objective function, and then implement an algorithm (like the simplex method or a graphical method) to find the optimal solution.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages