1 '''
2 Created on 08.06.2010
3
4 @author: Robert Fischbach
5 @author: Tobias Heimpold
6
7 This module contains several parameters for the GUI. They are provided in a "crypted" form using dictionaries and lists.
8 That seems complicated at the first time. But: Lists and dictionaries can be easily iterated. So the code in the GUI module need not to be programmed
9 with several controls like if elif else.
10 For example a algorithm has different parameters, which should all stand together in one group box. The parameters have different values, step sizes etc.
11 Without a list the GUI must handle every single parameter on its own. With a list, the GUI just reads the correct entry from the list where it is told what to do.
12
13 - list of supported data structures
14 - list of working benchmarks
15 - list of optimization approaches
16 - list of parameters of optimization approaches
17 - list of data type of these parameters (linked with PyQt)
18 - list of functions to edit parameters (linked with PyQt)
19 - list of functions to read parameters (linked with PyQt)
20 - list of evaluation options
21
22 Hint: Linking to PyQt without import ! --> string must be run with eval(string) in main program
23 '''
24
25 from dsc_suite.ds.slicing_tree import SlicingTree
26 from dsc_suite.ds.sequence_triple import SequenceTriple
27 from dsc_suite.ds.sequence_quintuple import SequenceQuintuple
28 from dsc_suite.ds.o_sequence import OSequence
29 from dsc_suite.ds.t_tree import TTree
30 from dsc_suite.ds.data_structure import COST_CRITERIA_LIST
31
32 """ dictionary of functional implemented data structures
33 key ... name
34 value ... [DataStructureClass, 'Information']
35 """
36 DATA_STRUCTURE_LIST = {'3D Slicing Tree' : [SlicingTree, 'bla bla slicing tree'],
37 'Sequence Triple' : [SequenceTriple, 'bla bla sequence triple'],
38 'Sequence Quintuple' : [SequenceQuintuple, 'bla bla sequence quintuple'],
39 'O-Sequence' : [OSequence, 'bla bla o sequence'],
40 'T-Tree' : [TTree, 'bla bla t tree']}
41
42
43
44 from dsc_suite.tools.benchmarks import YAL
45 from dsc_suite.tools.benchmarks import ACADEMIC
46
47 """ dictionary of tested benchmarks
48 key ... name
49 value ... [BenchmarkClass, num_blocks, 'Information']
50 usage: bm = BenchmarkClass(name)
51 """
52 BENCHMARK_LIST = {'apte.yal' : [YAL, 9, 'apte\n\n number of blocks:\t 9\n benchmarkclass:\t YAL'],
53 'xerox.yal' : [YAL, 10, 'xerox\n\n number of blocks:\t 9\n benchmarkclass:\t YAL'],
54 'hp.yal' : [YAL, 11, 'hp\n\n number of blocks:\t 11\n benchmarkclass:\t YAL'],
55 'M198.yal' : [YAL, 33, 'M198\n\n number of blocks:\t 33\n benchmarkclass:\t YAL'],
56 'ami33.yal' : [YAL, 33, 'ami33\n\n number of blocks:\t 33\n benchmarkclass:\t YAL'],
57 'ami49.yal' : [YAL, 49, 'ami49\n\n number of blocks:\t 49\n benchmarkclass:\t YAL'],
58 'playout.yal' : [YAL, 56, 'playout\n\n number of blocks:\t 56\n benchmarkclass:\t YAL'],
59 'cube.academic' :[ACADEMIC, 7, 'cube\n\n number of blocks:\t 7\n benchmarkclass:\t ACADEMIC'],
60 'sim_cube.academic' :[ACADEMIC, 4, 'sim_cube\n\n number of blocks:\t 4\n benchmarkclass:\t ACADEMIC'],
61 'layer.academic' :[ACADEMIC, 10, 'layer\n\n number of blocks:\t 10\n benchmarkclass:\t ACADEMIC']}
62
63
64
65 from dsc_suite.opt.monte_carlo_adjusted import generate_monte_carlo_data
66 from dsc_suite.opt.evolutionary_algorithm import generate_evolution_data
67 from dsc_suite.opt.simulated_annealing_2 import generate_simulated_annealing_data
68 from dsc_suite.opt.great_deluge_algorithm import generate_great_deluge_data
69
70 """ dictionary of working optimization approaches
71 key ... name
72 value ... [generation_function, 'Information']
73 usage: generation_function(parameters**)
74 Detailed info about the generation_function should be found
75 in the corresponding docstring.
76 """
77 OPTIMIZATION_LIST = {'Monte Carlo' : [generate_monte_carlo_data,
78 'Evenly distributed sampling of the given solution space.'],
79 'Simulated Annealing' : [generate_simulated_annealing_data, 'add nice text'],
80 'Evolutionary Algorithm' : [generate_evolution_data, 'add nice text'],
81 'Great Deluge Algorithm': [generate_great_deluge_data, 'add nice text']}
82
83 """ this dictionary contains the different parameters of the algorithms
84 PARAMETER_LIST[name_of_algorithm] returns a dictionary:
85 keys : parameter name used in algorithm
86 value : list with detailed information about parameter
87
88 index and refered information:
89 0 : data type -> see DATATYPE_LIST
90 1 : description for tool tip
91 2 : list with limits --> MUST be correlated with functions in LIMITFUNCTION_LIST !
92
93 that means: the first object in the list is used as a parameter for the first function for that datatype
94 """
95
96 PARAMETER_LIST = {"Monte Carlo" : {"samples" : ["int", "Samples to be created", [1000,10000000,1000,10000]]},
97
98 "Simulated Annealing" : {"Tsamples" : ["int", "samples per temperature", [50,2000,5,100]],
99 "Tsteps" : ["int", "temperature steps", [10,100,5,25]],
100 "Tstart" : ["int", "start temperature", [1300,5000,100,1300]],
101 "Tend" : ["int", "end temperature",[50,350,50,100]],
102 "correct_factor" : ["float" , "correct factor e-function", [6,0.000001,0.1,0.000005,0.0001]]},
103
104 "Evolutionary Algorithm" : {"parents" : ["int", "number of parent individuals per generation",[2,50,2,8]],
105 "children" : ["int", "number of created children per recombination",[1,20,1,4]],
106 "generations" : ["int", "number of created generations", [5,100,5,50]]},
107
108 "Great Deluge Algorithm": {"vapor_samples": ["int", "samples of new solutions tried",[500,100000,100,3000]],
109 "vapor_value" : ["float", "amount of 'vaporized' water after new solution",[3,0.001,0.02,0.001,0.005]]}}
110
111
112 """ this dictionary contains the different data types which are used in the algorithms and combines them with the Qt-Framework
113 keys : used data type
114 value : used Qt Widget
115
116 for example:
117 to set a integer based parameter a QtSpinBox is used
118 """
119 DATATYPE_LIST = {"int" : "QtGui.QSpinBox()",
120 "float" : "QtGui.QDoubleSpinBox()",
121 "str" : "QtGui.QLineEdit()"}
122
123
124 """ this dictionary contains the different functions to set the limits of the parameters
125 keys : used data type
126 value : list of functions for setting the limits
127
128 MUST be correlated to the limits in PARAMETER_LIST
129
130 for example:
131 to set a integer based parameter a QtSpinBox is used
132 """
133 LIMITFUNCTION_LIST = {"int" : ["setMinimum",
134 "setMaximum",
135 "setSingleStep",
136 "setValue"],
137
138 "float" : ["setDecimals",
139 "setMinimum",
140 "setMaximum",
141 "setSingleStep",
142 "setValue"],
143 "str" : ["setText"]}
144
145
146 """ this dictionary contains the different functions to read the parameters
147 keys : used data type --> used as cast operator
148 value : list of functions to read the parameter
149
150
151 for example:
152 to read a integer based parameter from a QSpinBox is used function value
153 """
154 READFUNCTION_LIST = {"int" : "value",
155 "float" : "value",
156 "str" : "text"}
157
158
159 """ this list contains the names of parameters which are used from every algorithm
160 cost_criteria is replaced by the cost criteria key list in datastructure module
161 """
162
163 HEADER_LIST = ["#", "trial name" , "datastructure", "benchmark", "algorithm", "z-Dimension"]
164 for key in COST_CRITERIA_LIST.keys():
165 HEADER_LIST += [key, "weight factor "+key, "norm value "+key]
166
167
168 from dsc_suite.analyses.cost_distribution import plot_cost_distribution
169 from dsc_suite.analyses.cost_distribution_2D import plot_2d_cost_distribution
170 from dsc_suite.analyses.cost_development import plot_costdata_development
171 from dsc_suite.analyses.scatter_plot_2D import plot_2D_scatter_plot
172 from dsc_suite.analyses.histogram import plot_histogramm
173
174 """ dictionary of evaluation methods which generate a plot
175 key ... name
176 value ... [generation_function, 'Information']
177 usage: generation_function(parameters**)
178 Detailed info about the generation_function should be found
179 in the corresponding docstring.
180 """
181 EVALUATION_PLOT_LIST = {'Cost Distribution' : [plot_cost_distribution,
182 'Plot distribution of costs given by data entries.'],
183 '2D Cost Distribution' : [plot_2d_cost_distribution,
184 'Contrast two cost distributions in a single diagram'],
185 'Cost development': [plot_costdata_development,
186 'Plot cost data over their index in data file'],
187 'Scatter plot' : [plot_2D_scatter_plot,
188 'Contrast two cost distributions in a single diagram'],
189 'Histogram' : [plot_histogramm, 'Plots histogramm']}
190 """dictionary of diagram options which can be adjusted
191 keys ... will create tabs (as first level) and group boxes all sub-levels
192 value ... dictionary --> next level of group box, list --> information about parameter
193 usage: similar to parameter list
194 The DSC construts a dialog with a special layout. The first level keys create tabs.
195 If the value referenced by the key is a dictionary, all sub-level keys will create a group box and include all next sub-level keys.
196 If the value referenced by the key is a list, the key is a parameter and the DSC will create a PyQt item for adjustment (see DATATYPE_LIST).
197 The other items in the list are tooltip and limits (if needed) --> see limit function list).
198 """
199 DIAGRAM_PARAMETER_LIST = {'labels' : {'title' : ["str" , "The title of the diagram.", ""],
200 'legend-position' : ["str" , "The position of the legend. Possible options:\nbest\nupper right\nupper left\nlower left\nlower right\nright\ncenter left\ncenter right\nlower center\nupper center\ncenter", "best"],
201 'legend-title' : ["str" , "The title of the legend.", ""],
202 'legend-parameter' : ["str" , "The parameter which is different in the selected files. Only one supported!", ""],
203 'x-label' : ["str" , "The label for the x-axe.", ""],
204 'y-label' : ["str" , "The label for the y-axe.", ""]},
205
206 'sizes' : {'dimensions' : {'length' : ["int" , "The length of the diagram.", 1, 30, 1, 10],
207 'width' : ["int" , "The width of the diagram.", 1, 30, 1, 8]},
208 'margins' : {'left' : ["float" , "The left white margin in percent", 2, 0.05, 0.3, 0.05, 0.1],
209 'right' : ["float" , "The right white margin in percent", 2, 0.7, 1.0, 0.05, 0.9],
210 'bottom' : ["float" , "The bottom white margin in percent", 2, 0.05, 0.3, 0.05, 0.1],
211 'top' : ["float" , "The top white margin in percent", 2, 0.7, 1.0, 0.05, 0.9]}},
212 'axes' : {'x-axe' : {'xmin' : ["str" , "The minimum x-value. Auto = 0", "auto"],
213 'xmax' : ["str" , "The maximum x-value. Auto = searches maximum", "auto"], },
214 'y-axe' : {'ymin' : ["str" , "The minimum y-value. Auto = 0", "auto"],
215 'ymax' : ["str" , "The maximum y-value. Auto = searches maximum", "auto"]}}}
216