示例#1
0
func Test_data3d(tst *testing.T) {

	// data
	prob := "CF9"
	dat := PFdata(prob)
	X := utl.DblsGetColumn(0, dat)
	Y := utl.DblsGetColumn(1, dat)
	Z := utl.DblsGetColumn(2, dat)

	// figure
	plt.SetForEps(1.0, 400)
	plt.Plot3dPoints(X, Y, Z, "s=0.05, color='r', facecolor='r', edgecolor='r', xlbl='$f_1$', ylbl='$f_2$', zlbl='$f_3$'")
	plt.AxisRange3d(0, 1, 0, 1, 0, 1)
	plt.Camera(10, -135, "")
	//plt.Camera(10, 45, "")
	plt.SaveD("/tmp/goga", io.Sf("cec09-%s.eps", prob))

	// interactive
	if false {
		r := 0.005
		scn := vtk.NewScene()
		P := vtk.Spheres{X: X, Y: Y, Z: Z, R: utl.DblVals(len(X), r), Color: []float64{1, 0, 0, 1}}
		P.AddTo(scn)
		scn.Run()
	}
}
示例#2
0
文件: auxplot.go 项目: cpmech/goga
func plot3(opt *goga.Optimiser, onlyFront0, twice bool, ptRad float64) {

	// results
	var X, Y, Z []float64
	if onlyFront0 {
		for _, sol := range opt.Solutions {
			if sol.Feasible() && sol.FrontId == 0 {
				X = append(X, sol.Ova[0])
				Y = append(Y, sol.Ova[1])
				Z = append(Z, sol.Ova[2])
			}
		}
	} else {
		X, Y, Z = make([]float64, opt.Nsol), make([]float64, opt.Nsol), make([]float64, opt.Nsol)
		for i, sol := range opt.Solutions {
			X[i], Y[i], Z[i] = sol.Ova[0], sol.Ova[1], sol.Ova[2]
		}
	}

	// create a new VTK Scene
	scn := vtk.NewScene()
	scn.HydroLine = false
	scn.FullAxes = false
	scn.AxesLen = 1.1
	scn.WithPlanes = false
	scn.LblX = io.Sf("f%d", 0)
	scn.LblY = io.Sf("f%d", 1)
	scn.LblZ = io.Sf("f%d", 2)
	scn.LblSz = 20

	// particles
	var P vtk.Spheres
	P.X, P.Y, P.Z = X, Y, Z
	P.R = utl.DblVals(len(X), ptRad)
	P.Color = []float64{1, 0, 0, 1}
	P.AddTo(scn)

	// start interactive mode
	scn.SaveEps = false
	scn.SavePng = true
	scn.PngMag = 2
	scn.Fnk = io.Sf("/tmp/goga/m3_%s_A", opt.RptName)
	scn.Run()
	if twice {
		scn.Fnk = io.Sf("/tmp/goga/m3_%s_B", opt.RptName)
		scn.Run()
	}
}
示例#3
0
文件: auxplot.go 项目: cpmech/goga
func plot3x(opt *goga.Optimiser, onlyFront0 bool, i, j, k int, ptRad float64) {

	// points
	var X, Y, Z []float64
	if onlyFront0 {
		for _, sol := range opt.Solutions {
			if sol.Feasible() && sol.FrontId == 0 {
				X = append(X, sol.Flt[i])
				Y = append(Y, sol.Flt[j])
				Z = append(Z, sol.Flt[k])
			}
		}
	} else {
		X, Y, Z = make([]float64, opt.Nsol), make([]float64, opt.Nsol), make([]float64, opt.Nsol)
		for m, sol := range opt.Solutions {
			X[m], Y[m], Z[m] = sol.Flt[i], sol.Flt[j], sol.Flt[k]
		}
	}

	// create a new VTK Scene
	scn := vtk.NewScene()
	scn.HydroLine = false
	scn.FullAxes = true
	scn.AxesLen = 1.1
	scn.WithPlanes = false
	scn.LblX = io.Sf("x%d", i)
	scn.LblY = io.Sf("x%d", j)
	scn.LblZ = io.Sf("x%d", k)
	scn.LblSz = 20

	// reference particles
	var Ps vtk.Spheres
	switch opt.RptName {
	case "UF3":
		np := 101
		nx := opt.Nsol
		c1 := 0.5 * (1.0 + 3.0*(float64(1)-2.0)/(float64(nx)-2.0))
		c2 := 0.5 * (1.0 + 3.0*(float64(2)-2.0)/(float64(nx)-2.0))
		Ps.X = utl.LinSpace(0, 1, np)
		Ps.Y = make([]float64, np)
		Ps.Z = make([]float64, np)
		for i := 0; i < np; i++ {
			Ps.Y[i] = math.Pow(Ps.X[i], c1)
			Ps.Z[i] = math.Pow(Ps.X[i], c2)
		}
		Ps.R = utl.DblVals(np, 0.7*ptRad)
		Ps.Color = []float64{0, 0, 1, 1}
		Ps.AddTo(scn)
		scn.FullAxes = false
	}

	// particles
	var P vtk.Spheres
	P.X, P.Y, P.Z = X, Y, Z
	P.R = utl.DblVals(len(X), ptRad)
	P.Color = []float64{1, 0, 0, 1}
	P.AddTo(scn)

	// start interactive mode
	scn.SaveEps = false
	scn.SavePng = false
	scn.PngMag = 2
	scn.Fnk = io.Sf("/tmp/goga/m3_pts_%s", opt.RptName)
	scn.Run()
}
示例#4
0
文件: auxplot.go 项目: cpmech/goga
func vtk_plot3(opt *goga.Optimiser, αcone, ptRad float64, onlyFront0, twice bool) {

	// results
	var X, Y, Z []float64
	if onlyFront0 {
		for _, sol := range opt.Solutions {
			if sol.Feasible() && sol.FrontId == 0 {
				X = append(X, sol.Ova[0])
				Y = append(Y, sol.Ova[1])
				Z = append(Z, sol.Ova[2])
			}
		}
	} else {
		X, Y, Z = make([]float64, opt.Nsol), make([]float64, opt.Nsol), make([]float64, opt.Nsol)
		for i, sol := range opt.Solutions {
			X[i], Y[i], Z[i] = sol.Ova[0], sol.Ova[1], sol.Ova[2]
		}
	}

	// create a new VTK Scene
	scn := vtk.NewScene()
	scn.HydroLine = false
	scn.FullAxes = false
	scn.AxesLen = 1.1
	scn.WithPlanes = false
	scn.LblX = io.Sf("f%d", 0)
	scn.LblY = io.Sf("f%d", 1)
	scn.LblZ = io.Sf("f%d", 2)
	scn.LblSz = 20
	if opt.RptName == "DTLZ1" {
		scn.AxesLen = 0.6
	}

	// optimal Pareto front
	front := vtk.NewIsoSurf(func(x []float64) (f, vx, vy, vz float64) {
		f = opt.Multi_fcnErr(x)
		return
	})
	front.Limits = []float64{opt.RptFmin[0], opt.RptFmax[0], opt.RptFmin[1], opt.RptFmax[1], opt.RptFmin[2], opt.RptFmax[2]}
	front.Color = []float64{0.45098039, 0.70588235, 1., 0.8}
	front.CmapNclrs = 0 // use this to use specified color
	front.Ndiv = []int{61, 61, 61}
	front.AddTo(scn)

	// cone
	if opt.RptName == "DTLZ2c" {
		cone := vtk.NewIsoSurf(func(x []float64) (f, vx, vy, vz float64) {
			f = cone_angle(x) - math.Tan(αcone)
			return
		})
		cone.Limits = []float64{0, -1, 0, 1, 0, 360}
		cone.Ndiv = []int{61, 61, 81}
		cone.OctRotate = true
		cone.GridShowPts = false
		cone.Color = []float64{0.96862745, 0.75294118, 0.40784314, 0.5}
		cone.CmapNclrs = 0 // use this to use specified color
		cone.AddTo(scn)    // remember to add to Scene
	}

	// particles
	var P vtk.Spheres
	P.X, P.Y, P.Z = X, Y, Z
	P.R = utl.DblVals(len(X), ptRad)
	P.Color = []float64{1, 0, 0, 1}
	P.AddTo(scn)

	// start interactive mode
	scn.SaveEps = false
	scn.SavePng = true
	scn.PngMag = 2
	scn.Fnk = io.Sf("/tmp/goga/vtk_%s_A", opt.RptName)
	scn.Run()
	if twice {
		scn.Fnk = io.Sf("/tmp/goga/vtk_%s_B", opt.RptName)
		scn.Run()
	}
}