Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
traffic-scratch
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mehtank
traffic-scratch
Commits
1bb2cd51
Commit
1bb2cd51
authored
8 years ago
by
mehtank
Browse files
Options
Downloads
Patches
Plain Diff
Generalize sweep
parent
b5b0080c
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
idmsweep.py
+79
-43
79 additions, 43 deletions
idmsweep.py
with
79 additions
and
43 deletions
idmsweep.py
+
79
−
43
View file @
1bb2cd51
from
idmlin
import
IDMLin
from
matplotlib
import
pyplot
as
plt
from
numpy
import
arange
from
scipy
import
signal
from
scipy
import
sqrt
,
linspace
,
exp
,
pi
,
polymul
,
sinh
,
cosh
,
arange
,
ones
,
size
,
array
from
idmlin
import
IDMLin
def
linfty
(
re
,
n
=
25
,
tmax
=
100
,
dt
=
0.1
,
timeplot
=
False
):
def
go
(
t
,
a
,
b
,
s
,
v
,
fmt
=
None
):
idm
=
IDMLin
(
t
=
t
,
a
=
a
,
b
=
b
,
s0
=
s
)
idm
.
go
(
v
,
re
)
sys
=
idm
.
sys
()
T
=
linspace
(
0
,
tmax
,
num
=
tmax
/
dt
)
U
=
ones
(
size
(
T
))
A
=
[
0
]
*
n
Us
=
ones
((
len
(
T
),
n
))
for
i
in
range
(
n
):
_
,
U
,
_
=
signal
.
lsim
(
sys
,
U
,
T
)
A
[
i
]
=
max
(
U
)
Us
[:,
i
]
=
U
if
timeplot
:
if
fmt
is
None
:
return
T
,
array
(
Us
)
else
:
return
T
,
array
(
Us
),
fmt
else
:
if
fmt
is
None
:
return
arange
(
n
)
+
1
,
A
else
:
return
arange
(
n
)
+
1
,
A
,
fmt
return
go
def
idmgo
(
t
,
a
,
b
,
s
,
v
,
fmt
=
None
):
idm
=
IDMLin
(
t
=
t
,
a
=
a
,
b
=
b
,
s0
=
s
)
...
...
@@ -11,44 +43,48 @@ def idmgo(t, a, b, s, v, fmt=None):
else
:
return
res
,
idm
.
os
(),
fmt
def
sweep
():
names
=
(
"
T
"
,
"
a
"
,
"
b
"
,
"
s_0
"
,
"
v_0
"
)
defaults
=
(
1.5
,
1
,
3
,
2
,
30
)
trng
=
[
0.5
,
1
,
2
,
2.5
]
arng
=
[
0.3
,
0.5
,
0.8
,
1.5
]
brng
=
[
1
,
2
,
4
,
5
]
srng
=
[
0.5
,
1
,
2.5
,
3
]
vrng
=
[
10
,
20
,
40
,
50
]
rngs
=
[
trng
,
arng
,
brng
,
srng
,
vrng
]
colors
=
[
'
r
'
,
'
g
'
,
'
b
'
,
'
m
'
,
'
c
'
]
dots
=
[
'
:
'
,
'
--
'
,
'
-
'
,
'
.-
'
]
'''
for i in range(len(rngs)):
plt.plot(*idmgo(*defaults, fmt=
'
k
'
))
print names[i], rngs[i][:2], defaults[i], rngs[i][2:]
args = list(defaults)
for n, arg in enumerate(rngs[i]):
args[i] = arg
plt.plot(*idmgo(*args, fmt=colors[i]+dots[n]))
plt.axis([0,1,-.2,.2])
plt.show()
'''
plt
.
plot
(
*
idmgo
(
*
defaults
,
fmt
=
'
k
'
))
print
"
a =
"
,
for
arg
in
range
(
20
):
args
=
list
(
defaults
)
a
=
arg
/
20.
+
0.2
print
a
,
args
[
1
]
=
a
plt
.
plot
(
*
idmgo
(
*
args
))
print
plt
.
axis
([
0
,
0.1
,
-
.
05
,.
45
])
plt
.
show
()
sweep
()
def
sweep
(
fn
,
rngs
):
defaults
=
[
x
[
"
default
"
]
for
x
in
rngs
]
for
i
,
r
in
enumerate
(
rngs
):
if
"
values
"
in
r
and
r
[
"
values
"
]
is
not
None
:
plt
.
plot
(
*
fn
(
*
defaults
,
fmt
=
'
k
'
))
print
r
[
"
name
"
],
defaults
[
i
],
r
[
"
values
"
]
args
=
list
(
defaults
)
for
dot
,
arg
in
zip
(
r
[
"
dots
"
],
r
[
"
values
"
]):
args
[
i
]
=
arg
plt
.
plot
(
*
fn
(
*
args
,
fmt
=
r
[
"
color
"
]
+
dot
))
# plt.axis([0,1,-.2,.2])
plt
.
show
()
avals
=
arange
(
20
)
/
20.
+
0.2
dots
=
[
"
-
"
]
*
len
(
avals
)
arng
=
{
"
name
"
:
"
a
"
,
"
color
"
:
""
,
"
dots
"
:
dots
,
"
default
"
:
1.0
,
"
values
"
:
avals
}
trng
=
{
"
name
"
:
"
T
"
,
"
default
"
:
1.5
}
brng
=
{
"
name
"
:
"
b
"
,
"
default
"
:
3.0
}
srng
=
{
"
name
"
:
"
s_0
"
,
"
default
"
:
2.0
}
vrng
=
{
"
name
"
:
"
v_0
"
,
"
default
"
:
30.
}
rngs
=
[
trng
,
arng
,
brng
,
srng
,
vrng
]
sweep
(
idmgo
,
rngs
)
dots
=
(
'
:
'
,
'
--
'
,
'
-
'
,
'
.-
'
)
trng
=
{
"
name
"
:
"
T
"
,
"
color
"
:
"
r
"
,
"
dots
"
:
dots
,
"
default
"
:
1.5
,
"
values
"
:
(
0.5
,
1
,
2
,
2.5
)
}
arng
=
{
"
name
"
:
"
a
"
,
"
color
"
:
"
g
"
,
"
dots
"
:
dots
,
"
default
"
:
1.0
,
"
values
"
:
(
0.3
,
0.5
,
0.8
,
1.5
)
}
brng
=
{
"
name
"
:
"
b
"
,
"
color
"
:
"
b
"
,
"
dots
"
:
dots
,
"
default
"
:
3.0
,
"
values
"
:
(
1
,
2
,
4
,
5
)
}
srng
=
{
"
name
"
:
"
s_0
"
,
"
color
"
:
"
m
"
,
"
dots
"
:
dots
,
"
default
"
:
2.0
,
"
values
"
:
(
0.5
,
1
,
2.5
,
3
)
}
vrng
=
{
"
name
"
:
"
v_0
"
,
"
color
"
:
"
c
"
,
"
dots
"
:
dots
,
"
default
"
:
30.
,
"
values
"
:
(
10
,
20
,
40
,
50
)
}
rngs
=
[
trng
,
arng
,
brng
,
srng
,
vrng
]
sweep
(
idmgo
,
rngs
)
'''
go = linfty(0.1, n=20, tmax=200)
sweep(go, rngs)
'''
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment