Optimization Introduction

Main.OptimizationBasics History

Show minor edits - Show changes to output

January 30, 2023, at 04:13 PM by 10.35.117.248 -
Changed lines 7-8 from:
%width=550px%Attach:optimization_intro.png
to:
(:html:)
<iframe width="560" height="315" src="https://www
.youtube.com/embed/a4CgoOqFimw" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
(:htmlend:)

Changed lines 87-94 from:
Python Gekko is a package for optimization and testing of dynamic systems. It is a powerful open-source software package that allows users to easily solve complex nonlinear optimization problems. It is used in a variety of fields, including engineering, economics, finance, and operations research. Python Gekko provides a comprehensive suite of features and algorithms to help users solve difficult optimization problems with ease. It also has a user-friendly interface that makes it easy to quickly set up and solve problems. Python Gekko has been used in a variety of research fields, including energy systems, aerospace engineering, and machine learning. See additional [[https://apmonitor.com/wiki/index.php/Main/GekkoPythonOptimization|Python Gekko tutorials]].

'''Optimization Basics'''

(:html:)
<iframe width="560" height="315" src="https://www
.youtube.com/embed/Q2dewZweAtU?list=PLLK3oSbvdxFdF67yVxF_1FQO9SbBY3yTL" frameborder="0" allowfullscreen></iframe>
(:htmlend:)

to:
Python Gekko is a package for optimization and testing of dynamic systems. It is a powerful open-source software package that allows users to easily solve complex nonlinear optimization problems. It is used in a variety of fields, including engineering, economics, finance, and operations research. Python Gekko provides a comprehensive suite of features and algorithms to help users solve difficult optimization problems with ease. It also has a user-friendly interface that makes it easy to quickly set up and solve problems. Python Gekko has been used in a variety of research fields, including energy systems, aerospace engineering, and machine learning. See additional [[https://apmonitor.com/wiki/index.php/Main/GekkoPythonOptimization|Python Gekko tutorials]] and the [[Main/OptimizationDesign|introduction to optimization]].
Added lines 143-144:

%width=550px%Attach:optimization_intro.png
Changed lines 132-134 from:
** [[https://software.sandia.gov/trac/coopr/wiki/Documentation/RelatedProjects | Python Optimization Packages]]

** Additional tutorials available for the [[Main/TwoBarTruss | Two Bar Truss]] Problem
to:

See [[Main/OptimizationTools|Optimization Software]] for a review of Open-Source Modeling Languages.
Changed lines 107-111 from:
** [[https://apmonitor.com/online/view_pass.php?f=lp.apm | Linear programming (LP)]]
** [[https://apmonitor.com/online/view_pass.php?f=qp2.apm | Quadratic programming (QP)]]
** [[https://apmonitor.com/online/view_pass.php?f=nlp.apm | Nonlinear programming (NLP)]]
** [[https://apmonitor.com/online/view_pass.php?f=milp.apm | Mixed integer linear programming (MILP)]]
** [[https://apmonitor.com/online/view_pass.php?f=minlp.apm | Mixed integer nonlinear programming (MINLP)]]
to:
** [[https://en.wikipedia.org/wiki/Linear_programming | Linear programming (LP)]]
** [[https://en.wikipedia.org/wiki/Quadratic_programming | Quadratic programming (QP)]]
** [[https://en.wikipedia.org/wiki/Nonlinear_programming | Nonlinear programming (NLP)]]
** [[https://en.wikipedia.org/wiki/Linear_programming#Integer_unknowns | Mixed integer linear programming (MILP)]]
** [[https://apmonitor.com/wiki/index.php/Main/IntegerBinaryVariables | Mixed integer nonlinear programming (MINLP)]]
Changed line 7 from:
%width=550px%Attach:optimize_with_python.png
to:
%width=550px%Attach:optimization_intro.png
Changed line 1 from:
(:title Optimization Platforms:)
to:
(:title Optimization Introduction:)
Added lines 6-7:

%width=550px%Attach:optimize_with_python.png
Deleted lines 5-8:

(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/6YpENqAMB2A" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
(:htmlend:)
Added lines 6-9:

(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/6YpENqAMB2A" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
(:htmlend:)
Added line 129:
** [[https://apmonitor.com/wiki/index.php/Main/GekkoPythonOptimization| Python Gekko]]
Added lines 48-56:

The solution satisfies the constraints and minimizes the objective function.

    Optimal cost: 3.1999999556
    x1: 2.0
    x2: 0.99999994451
    x3: 2.0

Because Python Gekko uses numerical methods, the solution is accepted within a specified tolerance that balances solution time with accuracy. The exact solution is x1=2, x2=1, x3=2 and optimal cost=3.2.
Added lines 6-7:

'''Python Gekko Example'''
Changed line 1 from:
(:title ME 575 Optimization Basics:)
to:
(:title Optimization Platforms:)
Changed lines 7-8 from:
The following is an example of using Gekko to solve an optimization problem in Python. The problem is to minimize the cost of a product given the cost of the components.
to:
The following is an example of using [[https://gekko.readthedocs.io/en/latest/|Python Gekko]] to solve an optimization problem in Python. The problem is to minimize the cost of a product given the cost of the three components that are required to produce the product.
Changed lines 16-17 from:
2️⃣ Next, define the variables to be optimized. In this problem, there are three components with prices x1, x2, and x3:
to:
2️⃣ Next, define the variables to be optimized. In this problem, there are three components with prices x1, x2, and x3 that have lower (lb) and upper (ub) bounds.
Changed lines 19-21 from:
x1 = m.Var(value=2)
x2
= m.Var(value=3)
x3
= m.Var(value=4)
to:
x1 = m.Var(value=2,lb=0,ub=2)
x2 =
m.Var(value=3,lb=0,ub=2)
x3 =
m.Var(value=4,lb=0,ub=2)
Changed lines 24-25 from:
3️⃣ Define the objective function to minimize the cost of the product:
to:
3️⃣ Define an equation or other constraints:
Changed lines 27-28 from:
m.Minimize(x1 + x2 + x3)
to:
m.Equation(x1 + x2 + x3 == 5)
m.Equation(x2 + x3 <= 4
)
Changed lines 31-32 from:
4️⃣ Finally, solve the optimization problem and print the optimal values of the components:
to:
4️⃣ Define the objective function to minimize the cost of the product:
Added lines 34-39:
m.Minimize(0.5*x1 + 0.8*x2 + 0.7*x3)
(:sourceend:)

5️⃣ Finally, solve the optimization problem and print the optimal values of the components:

(:source lang=python:)
Changed lines 47-74 from:
!!! Optimization Basics
to:
(:toggle hide gekko button show="Full Source Code":)
(:div id=gekko:)

(:source lang=bash:)
pip install gekko
(:sourceend:)

(:source lang=python:)
from gekko import GEKKO
m = GEKKO()
x1 = m.Var(value=2,lb=0,ub=2)
x2 = m.Var(value=3,lb=0,ub=2)
x3 = m.Var(value=4,lb=0,ub=2)
m.Equation(x1 + x2 + x3 == 5)
m.Equation(x2 + x3 <= 4)
m.Minimize(0.5*x1 + 0.8*x2 + 0.7*x3)
m.solve(disp=False)

print('Optimal cost: ' + str(m.options.objfcnval))
print('x1: ' + str(x1.value[0]))
print('x2: ' + str(x2.value[0]))
print('x3: ' + str(x3.value[0]))
(:sourceend:)
(:divend:)

Python Gekko is a package for optimization and testing of dynamic systems. It is a powerful open-source software package that allows users to easily solve complex nonlinear optimization problems. It is used in a variety of fields, including engineering, economics, finance, and operations research. Python Gekko provides a comprehensive suite of features and algorithms to help users solve difficult optimization problems with ease. It also has a user-friendly interface that makes it easy to quickly set up and solve problems. Python Gekko has been used in a variety of research fields, including energy systems, aerospace engineering, and machine learning. See additional [[https://apmonitor.com/wiki/index.php/Main/GekkoPythonOptimization|Python Gekko tutorials]].

'''Optimization Basics'''
Added lines 4-38:

Engineering optimization platforms in Python are an important tool for engineers in the modern world. They allow engineers to quickly and easily optimize complex engineering problems and tasks, such as design optimization, resource allocation, and route planning. Engineering optimization platforms typically offer powerful algorithms, such as constraint satisfaction algorithms, genetic algorithms, or artificial neural networks, to help engineers find the best solutions to their problems. Additionally, many engineering optimization platforms also provide tools for data visualization and interactive exploration, allowing engineers to gain a better understanding of their optimization results.

The following is an example of using Gekko to solve an optimization problem in Python. The problem is to minimize the cost of a product given the cost of the components.

1️⃣ Import Gekko and create a new model:

(:source lang=python:)
from gekko import GEKKO
m = GEKKO()
(:sourceend:)

2️⃣ Next, define the variables to be optimized. In this problem, there are three components with prices x1, x2, and x3:

(:source lang=python:)
x1 = m.Var(value=2)
x2 = m.Var(value=3)
x3 = m.Var(value=4)
(:sourceend:)

3️⃣ Define the objective function to minimize the cost of the product:

(:source lang=python:)
m.Minimize(x1 + x2 + x3)
(:sourceend:)

4️⃣ Finally, solve the optimization problem and print the optimal values of the components:

(:source lang=python:)
m.solve(disp=False)
print('Optimal cost: ' + str(m.options.objfcnval))
print('x1: ' + str(x1.value[0]))
print('x2: ' + str(x2.value[0]))
print('x3: ' + str(x3.value[0]))
(:sourceend:)
June 21, 2020, at 04:44 AM by 136.36.211.159 -
Deleted lines 64-82:

----

(:html:)
 <div id="disqus_thread"></div>
    <script type="text/javascript">
        /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
        var disqus_shortname = 'apmonitor'; // required: replace example with your forum shortname

        /* * * DON'T EDIT BELOW THIS LINE * * */
        (function() {
            var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
            dsq.src = 'https://' + disqus_shortname + '.disqus.com/embed.js';
            (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
        })();
    </script>
    <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
    <a href="https://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
(:htmlend:)
April 24, 2017, at 04:24 PM by 10.5.113.121 -
Added lines 6-9:

(:html:)
<iframe width="560" height="315" src="https://www.youtube.com/embed/Q2dewZweAtU?list=PLLK3oSbvdxFdF67yVxF_1FQO9SbBY3yTL" frameborder="0" allowfullscreen></iframe>
(:htmlend:)
January 11, 2013, at 02:30 PM by 69.169.188.188 -
Changed line 51 from:
* What resources (at least 3) did you find particularly useful or informative as you reviewed the tutorials, documentation, videos, or other online material?
to:
* What resources (at least 3) did you find particularly useful or informative as you reviewed the tutorials, documentation, videos, or other online material? Please enter any that you'd like to share below in the comments section.
January 11, 2013, at 02:19 PM by 69.169.188.188 -
Changed line 37 from:
* Review information on optimization platforms such as (2 or 3 is fine):
to:
* Review information on optimization platforms (2 or 3 is fine) such as:
January 11, 2013, at 02:12 PM by 69.169.188.188 -
Changed line 7 from:
# Complete the [[Main/InfoSheet | information sheet]] to tell me a little more about your background and interests
to:
* Complete the [[Main/InfoSheet | information sheet]] to tell me a little more about your background and interests
Changed lines 9-25 from:
# Think of an optimization problem. Define the following for this optimization problem of your choice:
## Objective
## Analysis variables (Parameters)
## Design variables (Variables)
## Equality constraints
## Inequality constraints
## Continuous variables
## Discrete variables

# Optimizers sometimes report that the optimization problem is infeasible. What does infeasible mean and how can it generally be corrected?

# Give the general form of the following types of problems and list at least one method that is used to solve them.
## [[https://apmonitor.com/online/view_pass.php?f=lp.apm | Linear programming (LP)]]
## [[https://apmonitor.com/online/view_pass.php?f=qp2.apm | Quadratic programming (QP)]]
## [[https://apmonitor.com/online/view_pass.php?f=nlp.apm | Nonlinear programming (NLP)]]
## [[https://apmonitor.com/online/view_pass.php?f=milp.apm | Mixed integer linear programming (MILP)]]
## [[https://apmonitor.com/online/view_pass.php?f=minlp.apm | Mixed integer nonlinear programming (MINLP)]]
to:
* Think of an optimization problem. Define the following for this optimization problem of your choice:
** Objective
** Analysis variables (Parameters)
** Design variables (Variables)
** Equality constraints
** Inequality constraints
** Continuous variables
** Discrete variables

* Optimizers sometimes report that the optimization problem is infeasible. What does infeasible mean and how can it generally be corrected?

* Give the general form of the following types of problems and list at least one method that is used to solve them.
** [[https://apmonitor.com/online/view_pass.php?f=lp.apm | Linear programming (LP)]]
** [[https://apmonitor.com/online/view_pass.php?f=qp2.apm | Quadratic programming (QP)]]
** [[https://apmonitor.com/online/view_pass.php?f=nlp.apm | Nonlinear programming (NLP)]]
** [[https://apmonitor.com/online/view_pass.php?f=milp.apm | Mixed integer linear programming (MILP)]]
** [[https://apmonitor.com/online/view_pass.php?f=minlp.apm | Mixed integer nonlinear programming (MINLP)]]
Changed lines 28-51 from:
# Define the following and tell how it is relevant to optimization:
## Equation residuals
## [[https://en.wikipedia.org/wiki/Global_optimization | Global (vs. local) optimization techniques]]
## [[https://en.wikipedia.org/wiki/Lagrange_multiplier | Lagrange multiplier]]
## [[https://en.wikipedia.org/wiki/Jacobian_matrix | Jacobian matrix]]
## [[https://en.wikipedia.org/wiki/Hessian_matrix | Hessian matrix]]
## [[https://en.wikipedia.org/wiki/Sensitivity_analysis | Sensitivity analysis]]
## [[https://en.wikipedia.org/wiki/Robust_optimization | Optimization under uncertainty]]

# Review information on optimization platforms such as (2 or 3 is fine):
## [[https://www.aimms.com | AIMMS]]
## [[https://www.ampl.com | AMPL]]
## [[https://www.apmonitor.com | APMonitor]]
## [[https://www.solver.com/optimization-tutorial | Frontline Excel Solver]]
## [[https://www.gams.com | GAMS]]
## [[https://www.mathworks.com/products/optimization/ | MATLAB Optimization Toolbox]]
## [[https://apmonitor.com/me575/index.php/Main/OptimizationTools | OptdesX - see OptdesX section]]
## [[https://software.sandia.gov/trac/coopr/wiki/Documentation/RelatedProjects | Python Optimization Packages]]

## Additional tutorials available for the [[Main/TwoBarTruss | Two Bar Truss]] Problem

# What optimization software tutorials did you review?

# What resources (at least 3) did you find particularly useful or informative as you reviewed the tutorials, documentation, videos, or other online material?
to:
* Define the following and tell how it is relevant to optimization:
** Equation residuals
** [[https://en.wikipedia.org/wiki/Global_optimization | Global (vs. local) optimization techniques]]
** [[https://en.wikipedia.org/wiki/Lagrange_multiplier | Lagrange multiplier]]
** [[https://en.wikipedia.org/wiki/Jacobian_matrix | Jacobian matrix]]
** [[https://en.wikipedia.org/wiki/Hessian_matrix | Hessian matrix]]
** [[https://en.wikipedia.org/wiki/Sensitivity_analysis | Sensitivity analysis]]
** [[https://en.wikipedia.org/wiki/Robust_optimization | Optimization under uncertainty]]

* Review information on optimization platforms such as (2 or 3 is fine):
** [[https://www.aimms.com | AIMMS]]
** [[https://www.ampl.com | AMPL]]
** [[https://www.apmonitor.com | APMonitor]]
** [[https://www.solver.com/optimization-tutorial | Frontline Excel Solver]]
** [[https://www.gams.com | GAMS]]
** [[https://www.mathworks.com/products/optimization/ | MATLAB Optimization Toolbox]]
** [[https://apmonitor.com/me575/index.php/Main/OptimizationTools | OptdesX - see OptdesX section]]
** [[https://software.sandia.gov/trac/coopr/wiki/Documentation/RelatedProjects | Python Optimization Packages]]

** Additional tutorials available for the [[Main/TwoBarTruss | Two Bar Truss]] Problem

* What optimization software tutorials did you review?

* What resources (at least 3) did you find particularly useful or informative as you reviewed the tutorials, documentation, videos, or other online material?
January 11, 2013, at 02:06 PM by 69.169.188.188 -
January 11, 2013, at 02:05 PM by 69.169.188.188 -
Added lines 61-62:

----