Пример #1
0
func (tp *TreeParams) CheckExprTmp(e expr.Expr) bool {
	if e.Size() < tp.TmpMinSize || e.Size() > tp.TmpMaxSize ||
		e.Height() < tp.TmpMinDepth || e.Height() > tp.TmpMaxDepth {
		return false
	}
	return true
}
Пример #2
0
func (PS *PgeSearch) ExpandMethod1(O expr.Expr) (ret []expr.Expr) {
	O.Sort()
	ret = make([]expr.Expr, 0)
	// fmt.Printf("Expanding expression:  %v\n", O)

	for i := 0; i < O.Size(); i++ {
		I := i
		E := O.GetExpr(&I)
		switch E.ExprType() {
		case expr.ADD:
			tmp := PS.AddTermToExprMethod1(O, E, i)
			ret = append(ret, tmp[:]...)

		case expr.MUL:
			tmp := PS.WidenTermInExprMethod1(O, E, i)
			ret = append(ret, tmp[:]...)

		case expr.VAR:
			tmp := PS.DeepenTermInExprMethod1(O, E, i)
			ret = append(ret, tmp[:]...)

		default: // expr.DIV,expr.COS,expr.SIN,expr.EXP,expr.LOG,expr.ABS,expr.POW
			continue

		}
	}

	return ret
}
Пример #3
0
func (tp *TreeParams) CheckExpr(e expr.Expr) bool {
	if e.Size() < tp.MinSize {
		//    fmt.Printf( "Too SMALL:  e:%v  l:%v\n", e.Size(), tp.TmpMinSize )
		return false
	} else if e.Size() > tp.MaxSize {
		//    fmt.Printf( "Too LARGE:  e:%v  l:%v\n", e.Size(), tp.TmpMaxSize )
		return false
	} else if e.Height() < tp.MinDepth {
		//    fmt.Printf( "Too SHORT:  e:%v  l:%v\n", e.Height(), tp.TmpMinDepth )
		return false
	} else if e.Height() > tp.MaxDepth {
		//    fmt.Printf( "Too TALL:  e:%v  l:%v\n", e.Height(), tp.TmpMaxDepth )
		return false
	}
	return true
}
Пример #4
0
func (tp *TreeParams) CheckExprLog(e expr.Expr, log *bufio.Writer) bool {
	//   if e.Size() < tp.TmpMinSize || e.Size() > tp.TmpMaxSize ||
	//     e.Height() < tp.TmpMinDepth || e.Height() > tp.TmpMaxDepth {
	//       return false
	//     }
	if e.Size() < tp.MinSize {
		fmt.Fprintf(log, "Too SMALL:  e:%v  l:%v\n", e.Size(), tp.MinSize)
		return false
	} else if e.Size() > tp.MaxSize {
		fmt.Fprintf(log, "Too LARGE:  e:%v  l:%v\n", e.Size(), tp.MaxSize)
		return false
	} else if e.Height() < tp.MinDepth {
		fmt.Fprintf(log, "Too SHORT:  e:%v  l:%v\n", e.Height(), tp.MinDepth)
		return false
	} else if e.Height() > tp.MaxDepth {
		fmt.Fprintf(log, "Too TALL:  e:%v  l:%v\n", e.Height(), tp.MaxDepth)
		return false
	}
	return true
}