com.github.chen0040.gp.treegp.program.operators.Not Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-genetic-programming Show documentation
Show all versions of java-genetic-programming Show documentation
Genetic Programming in Java, including packages on Linear Genetic Programming
package com.github.chen0040.gp.treegp.program.operators;
import com.github.chen0040.gp.commons.Observation;
import com.github.chen0040.gp.treegp.program.Operator;
import com.github.chen0040.gp.treegp.program.Primitive;
/**
* Created by xschen on 11/5/2017.
*/
public class Not extends Operator {
private static final double tolerance = 0.0000001;
private static final long serialVersionUID = 346204193784368825L;
public Not(){
super(1, "NOT");
}
@Override public void execute(Observation observation){
setValue(isTrue(getInput(0)) ? 1.0 : 0.0);
}
public boolean isTrue(double x)
{
if (x > -tolerance && x < tolerance)
{
return false;
}
return true;
}
@Override public Primitive makeCopy() {
return new Not().copy(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy