Wolfram.com
WolframAlpha.com
WolframCloud.com
Wolfram Language
Example Repository
Ready-to-use examples of Wolfram Language
Primary Navigation
Categories
Algebra
Astronomy
Audio Processing
Calculus
Cellular Automata
Chemistry
Complex Systems
Computer Science
Computer Vision
Control Systems
Creative Arts
Data Science
Engineering
Finance & Economics
Finite Element Method
Food & Nutrition
Geography
Geometry
Graphs & Networks
Image Processing
Life Sciences
Machine Learning
Mathematics
Optimization
Physics
Probability & Statistics
Puzzles and Recreation
Quantum Computation
Signal Processing
Social Sciences
System Modeling
Tabular Processing
Text & Language Processing
Time-Related Computation
Video Processing
Visualization & Graphics
Alphabetical List
Submit a New Example
Learn More about
Wolfram Language
Related Pages
Related Symbols
NMinimize
NMaximize
Minimize
Maximize
KnapsackSolve
FindMinimum
FindMaximum
FindFit
ConvexOptimization
Related Categories
Optimization
Mathematics
Optimizing a Path to Avoid Obstacles
Example Notebook
Open in Cloud
Download Notebook
Find a path through circular obstacles such that the distance between the start and end points is minimized.
Define the positions and radii of the obstacles and the start and end points of the path. Visualize the setup:
I
n
[
1
]
:
=
{
G
r
a
p
h
i
c
s
[
{
P
i
n
k
,
D
i
s
k
[
]
}
]
,
G
r
a
p
h
i
c
s
[
{
E
d
g
e
F
o
r
m
[
T
h
i
c
k
]
,
P
i
n
k
,
D
i
s
k
[
]
}
]
,
G
r
a
p
h
i
c
s
[
{
E
d
g
e
F
o
r
m
[
D
a
s
h
e
d
]
,
P
i
n
k
,
D
i
s
k
[
]
}
]
,
G
r
a
p
h
i
c
s
[
{
E
d
g
e
F
o
r
m
[
D
i
r
e
c
t
i
v
e
[
T
h
i
c
k
,
D
a
s
h
e
d
,
B
l
u
e
]
]
,
P
i
n
k
,
D
i
s
k
[
]
}
]
}
I
n
[
2
]
:
=
p
=
{
{
2
,
2
}
,
{
7
,
6
}
,
{
3
,
5
}
,
{
4
,
8
}
,
{
8
,
9
}
,
{
6
,
2
.
5
}
}
;
r
=
{
1
,
1
.
3
,
1
.
5
,
1
,
0
.
7
,
1
.
5
}
;
{
s
t
a
r
t
,
e
n
d
}
=
{
{
0
,
0
}
,
{
1
0
,
1
0
}
}
;
d
o
m
a
i
n
=
G
r
a
p
h
i
c
s
[
{
E
d
g
e
F
o
r
m
[
D
i
r
e
c
t
i
v
e
[
T
h
i
c
k
,
B
l
u
e
]
]
,
L
i
g
h
t
e
r
[
B
l
u
e
,
0
.
8
]
,
,
M
a
p
T
h
r
e
a
d
[
D
i
s
k
[
#
1
,
#
2
]
&
,
{
p
,
r
}
]
,
{
P
o
i
n
t
S
i
z
e
[
0
.
0
2
]
,
P
o
i
n
t
[
{
s
t
a
r
t
,
e
n
d
}
]
}
}
,
F
r
a
m
e
T
r
u
e
]
O
u
t
[
2
]
=
The path is discretized into
n
points with distance of
l
e
n
/
n
between points, where
l
e
n
is the trajectory length being minimized:
I
n
[
3
]
:
=
n
=
7
5
;
d
i
s
t
a
n
c
e
C
o
n
s
t
r
a
i
n
t
s
=
T
a
b
l
e
[
I
n
a
c
t
i
v
e
[
N
o
r
m
]
[
x
[
i
]
-
x
[
i
-
1
]
]
≤
l
e
n
/
n
,
{
i
,
n
}
]
;
The points cannot be inside the circular objects:
I
n
[
4
]
:
=
o
b
j
e
c
t
C
o
n
s
t
r
a
i
n
t
s
=
T
a
b
l
e
[
N
o
r
m
[
-
p
〚
j
〛
+
x
[
i
]
]
≥
r
〚
j
〛
,
{
i
,
1
,
n
}
,
{
j
,
1
,
6
}
]
;
The start and end points are known:
I
n
[
5
]
:
=
p
o
s
i
t
i
o
n
C
o
n
s
t
r
a
i
n
t
s
=
{
x
[
0
]
s
t
a
r
t
,
x
[
n
]
e
n
d
}
;
Collect the variables:
I
n
[
6
]
:
=
v
a
r
s
=
A
p
p
e
n
d
[
T
a
b
l
e
[
x
[
i
]
∈
V
e
c
t
o
r
s
[
2
,
R
e
a
l
s
]
,
{
i
,
0
,
n
}
]
,
l
e
n
∈
R
e
a
l
s
]
;
Minimize the length
l
e
n
subject to the constraints:
I
n
[
7
]
:
=
S
h
o
r
t
[
r
e
s
=
N
M
i
n
i
m
i
z
e
[
{
l
e
n
,
d
i
s
t
a
n
c
e
C
o
n
s
t
r
a
i
n
t
s
,
o
b
j
e
c
t
C
o
n
s
t
r
a
i
n
t
s
,
p
o
s
i
t
i
o
n
C
o
n
s
t
r
a
i
n
t
s
}
,
v
a
r
s
,
M
e
t
h
o
d
"
D
i
f
f
e
r
e
n
c
e
O
f
C
o
n
v
e
x
"
]
,
2
]
O
u
t
[
7
]
/
/
S
h
o
r
t
=
{
1
4
.
5
8
4
2
,
{
x
[
0
]
{
4
.
0
6
3
5
9
×
-
9
1
0
,
4
.
0
3
1
9
9
×
-
9
1
0
}
,
x
[
1
]
{
0
.
1
7
7
1
4
9
,
0
.
0
8
0
1
9
8
2
}
,
x
[
2
]
{
0
.
3
5
4
2
9
7
,
0
.
1
6
0
3
9
6
}
,
x
[
3
]
{
0
.
5
3
1
4
4
6
,
0
.
2
4
0
5
9
5
}
,
x
[
4
]
{
0
.
7
0
8
5
9
4
,
0
.
3
2
0
7
9
3
}
,
6
8
,
x
[
7
3
]
{
9
.
7
2
4
0
6
,
9
.
7
2
5
9
4
}
,
x
[
7
4
]
{
9
.
8
6
2
0
3
,
9
.
8
6
2
9
7
}
,
x
[
7
5
]
{
1
0
.
,
1
0
.
}
,
l
e
n
1
4
.
5
8
4
2
}
}
Visualize the result:
I
n
[
8
]
:
=
p
t
s
=
v
a
r
s
〚
1
;
;
-
2
,
1
〛
/
.
r
e
s
〚
2
〛
;
S
h
o
w
[
d
o
m
a
i
n
,
G
r
a
p
h
i
c
s
[
{
R
e
d
,
P
o
i
n
t
[
p
t
s
]
}
]
]
O
u
t
[
8
]
=
See Also
AntColonyOptimization
MaximizeOverPermutations
MinSumPermutation
Related Symbols
NMinimize
NMaximize
Minimize
Maximize
KnapsackSolve
FindMinimum
FindMaximum
FindFit
ConvexOptimization
Publisher Information
Contributed by:
Paco Jain (Wolfram Research)