本文整理汇总了Python中Analyzer.Analyzer.setPareto方法的典型用法代码示例。如果您正苦于以下问题:Python Analyzer.setPareto方法的具体用法?Python Analyzer.setPareto怎么用?Python Analyzer.setPareto使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Analyzer.Analyzer
的用法示例。
在下文中一共展示了Analyzer.setPareto方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MainWindow
# 需要导入模块: from Analyzer import Analyzer [as 别名]
# 或者: from Analyzer.Analyzer import setPareto [as 别名]
#.........这里部分代码省略.........
bottomDock.setWidget(self.metrics)
bottomDock.setFeatures(QDockWidget.DockWidgetFloatable | QDockWidget.DockWidgetMovable)
self.addDockWidget(Qt.BottomDockWidgetArea, bottomDock)
# Actions
exitAction = QAction("&Exit", self)
exitAction.setShortcut("Ctrl+Q")
exitAction.setStatusTip("Exit application")
exitAction.triggered.connect(qApp.quit)
copyAction = QAction("&Copy", self)
copyAction.setShortcut("Ctrl+C")
copyAction.setStatusTip("Copy metrics")
copyAction.triggered.connect(self.metrics.copyMetrics)
aboutAction = QAction("&About", self)
aboutAction.setStatusTip("About MOOI")
aboutAction.triggered.connect(self.helpAbout)
# Menus
menubar = self.menuBar()
fileMenu = menubar.addMenu("&File")
fileMenu.addAction(copyAction)
fileMenu.addAction(aboutAction)
fileMenu.addSeparator()
fileMenu.addAction(exitAction)
def _loadSettings(self):
settings = QSettings()
self.restoreState(settings.value(MainWindow.__PREF_STATE__).toByteArray())
self.restoreGeometry(settings.value(MainWindow.__PREF_GEOM__).toByteArray())
paretoDirectory = __RESOURCES_DIR__ + Analyzer.__PARETO__
self.analyzer.setPareto(paretoDirectory)
currentDirs = settings.value(MainWindow.__PREF_DIR__)
if currentDirs is not None:
self.analyzer.setResultDirectories([directory.toString() for directory in currentDirs.toList()])
self._updateSolutionSelection()
def exportImage(self):
settings = QSettings()
filename = settings.value(MainWindow.__PREF_SAVE__)
if filename is None:
filename = os.path.dirname(__file__)
else:
filename = os.path.abspath(os.path.join(str(filename.toString()), os.path.pardir)) + "/"
filename += "%s_%s.png" % (
self.currentSolution.functionName,
"fun" if self.isFunctionSpaceSelected() else "var",
)
filename = QFileDialog.getSaveFileName(self, "Export image as", filename, ("PNG image (*.png)"))
if filename is None or filename == "":
return
settings.setValue(MainWindow.__PREF_SAVE__, QVariant(filename))
self._exportCurrentImage(filename)
self.statusBar().showMessage("Image saved!", 5000)
def isFunctionSpaceSelected(self):
return self.showSolutionsRadio.isChecked()
def _exportCurrentImage(self, filename=None):
generation = self.generationSlider.value()
self.generationLabel.setText("Run: %d" % generation)
示例2: Analyzer
# 需要导入模块: from Analyzer import Analyzer [as 别名]
# 或者: from Analyzer.Analyzer import setPareto [as 别名]
import shutil
import time
parser = argparse.ArgumentParser(description="Analyze Multi-Objective Optimization algorithm results against true Pareto fronts")
parser.add_argument("--name", "-n", help="name of the selected results")
parser.add_argument("--results", "-r", metavar="RESULT", nargs="+", help="results directory of an algorithm")
parser.add_argument("--functions", "-f", metavar="FUNCTION", nargs="*", help="function to test")
parser.add_argument("--pareto", "-p", help="true Pareto front directory")
args = parser.parse_args()
analyzer = Analyzer()
analyzer.setResultDirectories(args.results)
pareto = args.pareto
if pareto is None:
pareto = os.path.dirname(__file__) + "/../resources/" + Analyzer.__PARETO__
analyzer.setPareto(pareto)
functions = []
for functionName in analyzer.getFunctionNames():
if len(args.functions) == 0 or True in [analyzer.functionMatches(fn, functionName) for fn in args.functions]:
functions.append(functionName.upper())
functions.sort()
resultDir = args.name
if resultDir[-1] == "/":
resultDir = resultDir[:-1];
if os.path.exists(resultDir):
newResultDir = "%s-%s" % (resultDir, time.strftime("%Y%m%d-%H%M%S"))
print "Backing up previous selection at '%s' to '%s'" % (resultDir, newResultDir)
shutil.move(resultDir, newResultDir)
os.mkdir(resultDir)
示例3: LatexReporter
# 需要导入模块: from Analyzer import Analyzer [as 别名]
# 或者: from Analyzer.Analyzer import setPareto [as 别名]
class LatexReporter(object):
__TEMPLATE_REPORT_FILE__ = "report.tex"
__TEMPLATE_REPORT_DIR__ = Utils.__RESOURCES_DIR__ + "report/"
__TEMPLATE_PRESENTATION_FILE__ = "presentation.tex"
__TEMPLATE_PRESENTATION_DIR__ = Utils.__RESOURCES_DIR__ + "presentation/"
__TEMPLATE_VAR__ = "%RESULTS%"
__DATA_FORMAT__ = "%.4f"
def __init__(self):
self.analyzer = Analyzer("latex")
def getFunctionNames(self, includeNotSolved=False):
return self.analyzer.getFunctionNames(includeNotSolved)
def setResultDirectories(self, results):
self.analyzer.setResultDirectories(results)
def setPareto(self, pareto):
self.analyzer.setPareto(pareto)
def _getBest(self, data):
n = len(data)
best = [False] * n
maxValue = max(data)
for i in xrange(n):
if abs(maxValue - data[i]) < Utils.__EPS__:
best[i] = True
return best
def _getBlockLatex(self, name, description, data1, data2, best):
n = len(data1)
if description is None or (len(description) == 1 and description[0] is None):
latex = [" \\multicolumn{2}{|c||}{%s}" % name]
else:
latex = [" \\multirow{%d}{*}{%s}" % (n, name)]
for block in xrange(n):
latexRow = []
if description is not None and description[block] is not None:
latexRow.append(description[block])
for i in xrange(len(data1[block])):
latexRow.append(self.analyzer.getFormattedValue(data1[block][i], None if data2 is None \
else data2[block][i], best[block][i] if best is not None else False))
latex.append(" & " + " & ".join(latexRow) + " \\\\")
latex.append(" \\hline")
return "\n".join(latex)
def _getTableStartLatex(self, nColumns, big, presentation):
latex = []
if presentation:
latex.append("\\begin{frame}")
latex.append("\\frametitle{\insertsubsection}")
latex.append("\\vspace*{-0.2cm}")
latex.append("\\begin{table}")
latex.append(" \\tiny \\centering")
sizeFactor = ""
if big:
if presentation:
sizeFactor = "1.1"
cmOff = "-0.5"
else:
sizeFactor = "1.5"
cmOff = "-3"
latex.append(" \\begin{adjustwidth}{%scm}{%scm}" % (cmOff, cmOff))
latex.append(" \\begin{tabularx}{%s\\textwidth}{| c | c || %s |}" % (sizeFactor, " | ".join(["K"] * nColumns)))
latex.append(" \\hline")
return "\n".join(latex)
def _getTableEndLatex(self, caption, label, big, presentation):
latex = [" \\end{tabularx}"]
if big:
latex.append(" \\end{adjustwidth}")
if caption is not None and label is not None:
latex.append(" \\caption{\\label{%s} %s}" % (label, caption))
latex.append("\\end{table}")
if presentation:
latex.append("\\end{frame}")
return "\n".join(latex)
def _getUnaryMetricLatex(self, data, functionNames):
nm = self.analyzer.metrics.nUnaryMetrics
nr = self.analyzer.nResults - 1
nf = len(functionNames)
nc = 2 + 4*nr
latex = ["\\begin{sidewaystable}"]
latex.append(" \\tiny \\centering")
latex.append(" \\begin{tabularx}{\\textwidth}{| l | l |%s} \\hline" % (" K |" * 4*nr))
header = " \\multirow{2}{*}{Problema} & \\multirow{2}{*}{Indicador}"
for resultName in self.analyzer.resultNames:
if resultName != Analyzer.__PARETO__:
header += " & \\multicolumn{4}{c|}{%s}" % Utils.getResultNameLatex(resultName)
latex.append(header + " \\\\ \\cline{3-%d}" % (nc))
latex.append((" & %s\\\\" % ("& \\mu & \\sigma & min & max " * nr)))
#.........这里部分代码省略.........