APM.NODES - APMonitor Option

Main.OptionApmNodes History

Hide minor edits - Show changes to output

August 09, 2020, at 03:38 AM by 136.36.211.159 -
Changed lines 16-28 from:
In this example illustration, the number of nodes is 4 and the number of time segments is 3 such as defined by these 4 time points: [0,1,2,3]. Successive endpoints of the time segments are merged to form a chain of model predictions. Increasing the number of nodes will generally improve the solution accuracy but also increase the problem size and computation time. Solution accuracy can also be improved by adding more time segments. A more detailed description of NODES is given in the lecture material on [[https://apmonitor.com/do/index.php/Main/OrthogonalCollocation|Orthogonal Collocation on Finite Elements]] with the associated example problems.
to:
In this example illustration, the number of nodes is 4 and the number of time segments is 3 such as defined by these 4 time points: [0,1,2,3]. Successive endpoints of the time segments are merged to form a chain of model predictions. The ''`end`'' designation can be used for the polynomial segments or the nodes with ''`p(3)=p(end)`'' and ''`n(4)=n(end)`'' for the example above. Increasing the number of nodes will generally improve the solution accuracy but also increase the problem size and computation time. Solution accuracy can also be improved by adding more time segments. APMonitor and APM Matlab use index-1 for the polynomial time positions while Gekko and Python use index-0. The node positions are index-1 for both APMonitor and Gekko. To facilitate common functions to fix or free initial or end points, the following Gekko functions are available.

(:source lang=python:)
from gekko import GEKKO
m = GEKKO()
x = m.Var()
m.fix_initial(x)
m.fix_final(x)
m.free_initial(x)
m.free_final(x)
(:sourceend:)

A more detailed description of NODES is given in the lecture material on [[https://apmonitor.com/do/index.php/Main/OrthogonalCollocation|Orthogonal Collocation on Finite Elements]] with example problems. An additional example problem is shown below
.
August 09, 2020, at 03:30 AM by 136.36.211.159 -
Changed line 24 from:
and show the internal node solutions.
to:
with initial condition {`y_0=5`}. Show the internal node solutions.
August 09, 2020, at 03:29 AM by 136.36.211.159 -
Changed lines 16-17 from:
In this example illustration, the number of nodes is 4 and the number of time segments is 3 such as defined by these 4 time points: [0,1,2,3].
to:
In this example illustration, the number of nodes is 4 and the number of time segments is 3 such as defined by these 4 time points: [0,1,2,3]. Successive endpoints of the time segments are merged to form a chain of model predictions. Increasing the number of nodes will generally improve the solution accuracy but also increase the problem size and computation time. Solution accuracy can also be improved by adding more time segments. A more detailed description of NODES is given in the lecture material on [[https://apmonitor.com/do/index.php/Main/OrthogonalCollocation|Orthogonal Collocation on Finite Elements]] with the associated example problems.

!!!! Example Problem

Solve the equation with NODES=4 at time points [0,1,2,3]:

Changed lines 24-54 from:
Successive endpoints of the time segments are merged to form a chain of model predictions. Increasing the number of nodes will generally improve the solution accuracy but also increase the problem size and computation time. Solution accuracy can also be improved by adding more time segments. A more detailed description of NODES is given in the lecture material on [[https://apmonitor.com/do/index.php/Main/OrthogonalCollocation|Orthogonal Collocation on Finite Elements]] with the associated example problems.
to:
and show the internal node solutions.

'''Solution'''

%width=550px%Attach:results_all.png

(:source lang=python:)
from gekko import GEKKO
m = GEKKO(remote=False) # create GEKKO model
y = m.Var(5.0,name='y') # create GEKKO variable
m.Equation(y.dt()==-y)  # create GEKKO equation
m.time = [0,1,2,3]      # time points
m.options.IMODE = 4    # simulation mode
m.options.NODES = 4    # set NODES=4
m.options.CSV_WRITE=2  # write results_all.json
                        #  with internal nodes
m.solve()              # solve
m.open_folder()        # open run folder to see
                        #  source and results files

import matplotlib.pyplot as plt
# plot at [0,1,2,3]
plt.plot(m.time,y,'ro')

# retrieve internal nodes from results_all.json
import json
with open(m.path+'//results_all.json') as f:
    results = json.load(f)
plt.plot(results['time'],results['y'],'bx')   
plt.show()
(:sourceend:)
August 09, 2020, at 03:24 AM by 136.36.211.159 -
Changed lines 16-20 from:
In this example illustration, the number of nodes is 4 and the number of time segments is 3 such as defined by these 4 time points: [0,1,2,3]. Successive endpoints of the time segments are merged to form a chain of model predictions. Increasing the number of nodes will generally improve the solution accuracy but also increase the problem size and computation time. Solution accuracy can also be improved by adding more time segments. A more detailed description of NODES is given in the lecture material on [[https://apmonitor.com/do/index.php/Main/OrthogonalCollocation|Orthogonal Collocation on Finite Elements]] with the associated example problems.
to:
In this example illustration, the number of nodes is 4 and the number of time segments is 3 such as defined by these 4 time points: [0,1,2,3].

{$\frac{dy}{dt}=-y$}

Successive endpoints of the time segments are merged to form a chain of model predictions. Increasing the number of nodes will generally improve the solution accuracy but also increase the problem size and computation time. Solution accuracy can also be improved by adding more time segments. A more detailed description of NODES is given in the lecture material on [[https://apmonitor.com/do/index.php/Main/OrthogonalCollocation|Orthogonal Collocation on Finite Elements]] with the associated example problems.
August 09, 2020, at 02:07 AM by 136.36.211.159 -
Changed lines 12-16 from:
NODES are the number of collocation points in the span of each time segment. For dynamic problems, the time segments are linked together into a time horizon. Successive endpoints of the time segments are merged to form a chain of model predictions. Increasing the number of nodes will generally improve the solution accuracy but also increase the problem size and computation time. Solution accuracy can also be improved by adding more time segments. A more detailed description of NODES is given in the lecture material on [[https://apmonitor.com/do/index.php/Main/OrthogonalCollocation|Orthogonal Collocation on Finite Elements]] with the associated example problems.
to:
NODES are the number of collocation points in the span of each time segment. For dynamic problems, the time segments are linked together into a time horizon as shown in the figure below.

%width=550px%Attach:nodes.png

In this example illustration, the number of nodes is 4 and the number of time segments is 3 such as defined by these 4 time points: [0,1,2,3]
. Successive endpoints of the time segments are merged to form a chain of model predictions. Increasing the number of nodes will generally improve the solution accuracy but also increase the problem size and computation time. Solution accuracy can also be improved by adding more time segments. A more detailed description of NODES is given in the lecture material on [[https://apmonitor.com/do/index.php/Main/OrthogonalCollocation|Orthogonal Collocation on Finite Elements]] with the associated example problems.
March 09, 2019, at 12:52 AM by 10.35.117.63 -
Changed line 12 from:
NODES are the number of collocation points in the span of each time segment. For dynamic problems, the time segments are linked together into a time horizon. Successive endpoints of the time segments are merged to form a chain of model predictions. Increasing the number of nodes will generally improve the solution accuracy but also increase the problem size and computation time. Solution accuracy can also be improved by adding more time segments.
to:
NODES are the number of collocation points in the span of each time segment. For dynamic problems, the time segments are linked together into a time horizon. Successive endpoints of the time segments are merged to form a chain of model predictions. Increasing the number of nodes will generally improve the solution accuracy but also increase the problem size and computation time. Solution accuracy can also be improved by adding more time segments. A more detailed description of NODES is given in the lecture material on [[https://apmonitor.com/do/index.php/Main/OrthogonalCollocation|Orthogonal Collocation on Finite Elements]] with the associated example problems.
Added line 9:
 Allowable Range: 2-6
June 09, 2017, at 12:26 AM by 10.5.113.159 -
Added lines 12-13:

See also [[Main/OptionApmCtrlHor|CTRL_HOR]], [[Main/OptionApmCtrlTime|CTRL_TIME]], [[Main/OptionApmCtrlUnits|CTRL_UNITS]], [[Main/OptionApmHistUnits|HIST_UNITS]], [[Main/OptionApmPredHor|PRED_HOR]],  [[Main/OptionApmPredTime|PRED_TIME]]
June 09, 2017, at 12:25 AM by 10.5.113.159 -
Changed line 5 from:
%width=50px%Attach:apm.png
to:
%width=50px%Attach:apm.png [[Main/DbsGlobal|Global Options]] | %width=30px%Attach:fv.png %width=30px%Attach:mv.png %width=30px%Attach:sv.png %width=30px%Attach:cv.png[[Main/DbsVariable|Local Options]]
June 01, 2017, at 07:43 PM by 45.56.3.173 -
Added lines 1-11:
(:title APM.NODES - APMonitor Option:)
(:keywords APM.NODES, Optimization, Estimation, Option, Configure, Default, Description:)
(:description Nodes in each horizon step:)

%width=50px%Attach:apm.png

 Type: Integer, Input
 Default Value: 3
 Description: Nodes in each horizon step

NODES are the number of collocation points in the span of each time segment. For dynamic problems, the time segments are linked together into a time horizon. Successive endpoints of the time segments are merged to form a chain of model predictions. Increasing the number of nodes will generally improve the solution accuracy but also increase the problem size and computation time. Solution accuracy can also be improved by adding more time segments.