-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathplot_optimization.py
48 lines (38 loc) · 1.72 KB
/
plot_optimization.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# This file is part of DmpBbo, a set of libraries and programs for the
# black-box optimization of dynamical movement primitives.
# Copyright (C) 2014 Freek Stulp, ENSTA-ParisTech
#
# DmpBbo is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# DmpBbo is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with DmpBbo. If not, see <http://www.gnu.org/licenses/>.
""" Script for plotting the optimization. """
import argparse
from pathlib import Path
from matplotlib import pyplot as plt
from dmpbbo.bbo_of_dmps.LearningSessionTask import LearningSessionTask
def main():
""" Main function that is called when executing the script. """
parser = argparse.ArgumentParser()
parser.add_argument("directory", type=str, help="directory to read results from")
# parser.add_argument("--show", action="store_true", help="show result plots")
parser.add_argument("--save", action="store_true", help="save result plots to png")
args = parser.parse_args()
session = LearningSessionTask.from_dir(args.directory)
session.plot()
if args.save:
plt.gcf().suptitle(args.directory)
filename = Path(args.directory, "optimization.png")
print(f"Saving png to: {filename}")
plt.gcf().savefig(filename)
plt.show()
if __name__ == "__main__":
main()