Esempio n. 1
0
File: stat.go Progetto: cpmech/goga
// 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
}
Esempio n. 2
0
File: stat.go Progetto: cpmech/goga
// 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
}
Esempio n. 3
0
File: stat.go Progetto: cpmech/goga
// 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
}
Esempio n. 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))
}