Beispiel #1
0
// StatMulti prints statistical analysis for multi-objective problems
//  emin, eave, emax, edev -- errors on f1(f0)
//  key -- "IGD" if IGD values are available. In this case e{...} are IGD values
func StatMulti(o *Optimiser, verbose bool) (key string, emin, eave, emax, edev float64, E []float64) {
	if len(o.Multi_err) < 2 && len(o.Multi_IGD) < 2 {
		io.Pfred("there are no samples for statistical analysis\n")
		return
	}
	o.fix_formatting_data()
	n := len(o.Multi_err)
	key = "E"
	if n < 2 {
		n = len(o.Multi_IGD)
		key = "IGD"
	}
	E = make([]float64, n)
	if key == "E" {
		copy(E, o.Multi_err)
	} else {
		copy(E, o.Multi_IGD)
	}
	emin, eave, emax, edev = rnd.StatBasic(E, true)
	if verbose {
		io.Pf("\nerror on Pareto front (multi)\n")
		io.Pf("%smin = %g\n", key, emin)
		io.Pf("%save = %g\n", key, eave)
		io.Pf("%smax = %g\n", key, emax)
		io.Pf("%sdev = %g\n", key, edev)
		io.Pf(rnd.BuildTextHist(nice(emin, o.HistNdig)-o.HistDelEmin, nice(emax, o.HistNdig)+o.HistDelEmax,
			o.HistNsta, E, o.HistFmt, o.HistLen))
	}
	return
}
Beispiel #2
0
// StatF computes statistical information corresponding to objective function idxF
func StatF(o *Optimiser, idxF int, verbose bool) (fmin, fave, fmax, fdev float64, F []float64) {
	nsamples := len(o.BestOvas[idxF])
	if nsamples == 0 {
		if verbose {
			io.Pfred("there are no samples for statistical analysis\n")
		}
		return
	}
	F = make([]float64, nsamples)
	if nsamples == 1 {
		F[0] = o.BestOvas[idxF][0]
		fmin, fave, fmax = F[0], F[0], F[0]
		return
	}
	for i, f := range o.BestOvas[idxF] {
		F[i] = f
	}
	fmin, fave, fmax, fdev = rnd.StatBasic(F, true)
	if verbose {
		str := "\n"
		if len(o.RptFref) == o.Nova {
			str = io.Sf(" (%g)\n", o.RptFref[idxF])
		}
		io.Pf("fmin = %g\n", fmin)
		io.Pf("fave = %g"+str, fave)
		io.Pf("fmax = %g\n", fmax)
		io.Pf("fdev = %g\n", fdev)
		o.fix_formatting_data()
		io.Pf(rnd.BuildTextHist(nice(fmin, o.HistNdig)-o.HistDelFmin, nice(fmax, o.HistNdig)+o.HistDelFmax,
			o.HistNsta, F, o.HistFmt, o.HistLen))
	}
	return
}
Beispiel #3
0
// StatF1F0 prints statistical analysis for two-objective problems
//  emin, eave, emax, edev -- errors on f1(f0)
//  lmin, lave, lmax, ldev -- arc-lengths along f1(f0) curve
func StatF1F0(o *Optimiser, verbose bool) (emin, eave, emax, edev float64, E []float64, lmin, lave, lmax, ldev float64, L []float64) {
	if len(o.F1F0_err) == 0 && len(o.F1F0_arcLen) == 0 {
		io.Pfred("there are no samples for statistical analysis\n")
		return
	}
	o.fix_formatting_data()
	if len(o.F1F0_err) > 2 {
		E = make([]float64, len(o.F1F0_err))
		copy(E, o.F1F0_err)
		emin, eave, emax, edev = rnd.StatBasic(E, true)
		if verbose {
			io.Pf("\nerror on Pareto front\n")
			io.Pf("emin = %g\n", emin)
			io.Pf("eave = %g\n", eave)
			io.Pf("emax = %g\n", emax)
			io.Pf("edev = %g\n", edev)
			io.Pf(rnd.BuildTextHist(nice(emin, o.HistNdig)-o.HistDelEmin, nice(emax, o.HistNdig)+o.HistDelEmax,
				o.HistNsta, E, o.HistFmt, o.HistLen))
		}
	}
	if len(o.F1F0_arcLen) > 2 {
		den := 1.0
		if o.F1F0_arcLenRef > 0 {
			den = o.F1F0_arcLenRef
		}
		L := make([]float64, len(o.F1F0_arcLen))
		for i, l := range o.F1F0_arcLen {
			L[i] = l / den
		}
		lmin, lave, lmax, ldev = rnd.StatBasic(L, true)
		if verbose {
			io.Pf("\nnormalised arc length along Pareto front (ref = %g)\n", o.F1F0_arcLenRef)
			io.Pf("lmin = %g\n", lmin)
			io.Pf("lave = %g\n", lave)
			io.Pf("lmax = %g\n", lmax)
			io.Pf("ldev = %g\n", ldev)
			io.Pf(rnd.BuildTextHist(nice(lmin, o.HistNdig)-o.HistDelEmin, nice(lmax, o.HistNdig)+o.HistDelEmax,
				o.HistNsta, L, o.HistFmt, o.HistLen))
		}
	}
	return
}
Beispiel #4
0
// Stat prints statistical analysis
func (o *SimpleFltProb) Stat(idxF, hlen int, Fref float64) {
	if o.C.Ntrials < 2 || o.Nfeasible < 2 {
		return
	}
	F := make([]float64, o.Nfeasible)
	for i := 0; i < o.Nfeasible; i++ {
		o.Fcn(o.ff[0], o.gg[0], o.hh[0], o.Xbest[i])
		F[i] = o.ff[0][idxF]
	}
	fmin, fave, fmax, fdev := rnd.StatBasic(F, true)
	io.Pf("fmin = %v\n", fmin)
	io.PfYel("fave = %v (%v)\n", fave, Fref)
	io.Pf("fmax = %v\n", fmax)
	io.Pf("fdev = %v\n\n", fdev)
	io.Pf(rnd.BuildTextHist(nice_num(fmin-0.05), nice_num(fmax+0.05), 11, F, "%.2f", hlen))
}
Beispiel #5
0
// oneNormalAddRow adds row to normal one-obj table
func (o *TexReport) oneNormalAddRow(opt *Optimiser) {
	opt.fix_formatting_data()
	FrefTxt := "N/A"
	if len(opt.RptFref) > 0 {
		FrefTxt = tx(opt.RptFmtF, opt.RptFref[0])
	}
	Fmin, Fave, Fmax, Fdev, F := StatF(opt, 0, false)
	FminTxt, FaveTxt, FmaxTxt, FdevTxt := tx(opt.RptFmtF, Fmin), tx(opt.RptFmtF, Fave), tx(opt.RptFmtF, Fmax), tx(opt.RptFmtFdev, Fdev)
	hist := rnd.BuildTextHist(nice(Fmin, opt.HistNdig)-opt.HistDelFmin, nice(Fmax, opt.HistNdig)+opt.HistDelFmax, opt.HistNsta, F, opt.HistFmt, opt.HistLen)
	io.Ff(o.buf, `
%s
&
{$\!\begin{aligned}
    N_{sol}        &= %d \\
	N_{cpu}        &= %d \\
	t_{max}        &= %d \\
	\Delta t_{exc} &= %d
\end{aligned}$}
&
{$\!\begin{aligned}
	%s_{ref} &= {\bf %s} \\
	C_{DE}   &= %g \\
	N_{eval} &= %d \\
	T_{sys}  &= %v
\end{aligned}$}
&
{$\!\begin{aligned}
    %s_{min} &= {\bf %s} \\
    %s_{ave} &= %s \\
    %s_{max} &= %s \\
    %s_{dev} &= {\bf %s}
\end{aligned}$}
&
\begin{minipage}{%s} %s
\begin{verbatim}
%s \end{verbatim}
\end{minipage} \\
`,
		opt.RptName,
		opt.Nsol, opt.Ncpu, opt.Tf, opt.DtExc,
		opt.RptWordF, FrefTxt, opt.DEC, opt.Nfeval, dround(opt.SysTimeAve, o.DroundCte),
		opt.RptWordF, FminTxt, opt.RptWordF, FaveTxt, opt.RptWordF, FmaxTxt, opt.RptWordF, FdevTxt,
		o.MiniPageSz, o.HistTextSize, hist)
	io.Ff(o.buf, "\n")
}
Beispiel #6
0
// multiAddRow adds row to multi-obj table
func (o *TexReport) multiAddRow(opt *Optimiser) {
	opt.fix_formatting_data()
	Ekey, Emin, Eave, Emax, Edev, E := StatMulti(opt, false)
	EminTxt, EaveTxt, EmaxTxt, EdevTxt := tx(opt.RptFmtE, Emin), tx(opt.RptFmtE, Eave), tx(opt.RptFmtE, Emax), tx(opt.RptFmtEdev, Edev)
	hist := rnd.BuildTextHist(nice(Emin, opt.HistNdig)-opt.HistDelEmin, nice(Emax, opt.HistNdig)+opt.HistDelEmax, opt.HistNsta, E, opt.HistFmt, opt.HistLen)
	io.Ff(o.buf, `
%s
&
{$\!\begin{aligned}
    N_{sol}        &= %d \\
	N_{cpu}        &= %d \\
	t_{max}        &= %d \\
	\Delta t_{exc} &= %d
\end{aligned}$}
&
{$\!\begin{aligned}
	N_{f}    &= %d \\
	C_{DE}   &= %g \\
	N_{eval} &= %d \\
	T_{sys}  &= %v
\end{aligned}$}
&
{$\!\begin{aligned}
    %s_{min} &= %s \\
    %s_{ave} &= %s \\
    %s_{max} &= %s \\
    %s_{dev} &= {\bf %s}
\end{aligned}$}
&
\begin{minipage}{%s} %s
\begin{verbatim}
%s \end{verbatim}
\end{minipage} \\
`,
		opt.RptName,
		opt.Nsol, opt.Ncpu, opt.Tf, opt.DtExc,
		opt.Nova, opt.DEC, opt.Nfeval, dround(opt.SysTimeAve, o.DroundCte),
		Ekey, EminTxt, Ekey, EaveTxt, Ekey, EmaxTxt, Ekey, EdevTxt,
		o.MiniPageSz, o.HistTextSize, hist)
}