| 1 |
import com.fuzzylite.*; |
| 2 |
import com.fuzzylite.activation.* |
| 3 |
import com.fuzzylite.defuzzifier.*; |
| 4 |
import com.fuzzylite.factory.*; |
| 5 |
import com.fuzzylite.hedge.*; |
| 6 |
import com.fuzzylite.imex.*; |
| 7 |
import com.fuzzylite.norm.*; |
| 8 |
import com.fuzzylite.norm.s.*; |
| 9 |
import com.fuzzylite.norm.t.*; |
| 10 |
import com.fuzzylite.rule.*; |
| 11 |
import com.fuzzylite.term.*; |
| 12 |
import com.fuzzylite.variable.*; |
| 13 |
|
| 14 |
public class cubic_approximator{ |
| 15 |
public static void main(String[] args){ |
| 16 |
|
| 17 |
|
| 18 |
Engine engine = new Engine(); |
| 19 |
engine.setName("cubic_approximator"); |
| 20 |
engine.setDescription(""); |
| 21 |
|
| 22 |
InputVariable X = new InputVariable(); |
| 23 |
X.setName("X"); |
| 24 |
X.setDescription(""); |
| 25 |
X.setEnabled(true); |
| 26 |
X.setRange(-5.000, 5.000); |
| 27 |
X.setLockValueInRange(false); |
| 28 |
X.addTerm(new Triangle("AboutNegFive", -6.000, -5.000, -4.000)); |
| 29 |
X.addTerm(new Triangle("AboutNegFour", -5.000, -4.000, -3.000)); |
| 30 |
X.addTerm(new Triangle("AboutNegThree", -4.000, -3.000, -2.000)); |
| 31 |
X.addTerm(new Triangle("AboutNegTwo", -3.000, -2.000, -1.000)); |
| 32 |
X.addTerm(new Triangle("AboutNegOne", -2.000, -1.000, 0.000)); |
| 33 |
X.addTerm(new Triangle("AboutZero", -1.000, 0.000, 1.000)); |
| 34 |
X.addTerm(new Triangle("AboutOne", 0.000, 1.000, 2.000)); |
| 35 |
X.addTerm(new Triangle("AboutTwo", 1.000, 2.000, 3.000)); |
| 36 |
X.addTerm(new Triangle("AboutThree", 2.000, 3.000, 4.000)); |
| 37 |
X.addTerm(new Triangle("AboutFour", 3.000, 4.000, 5.000)); |
| 38 |
X.addTerm(new Triangle("AboutFive", 4.000, 5.000, 6.000)); |
| 39 |
engine.addInputVariable(X); |
| 40 |
|
| 41 |
OutputVariable ApproxXCubed = new OutputVariable(); |
| 42 |
ApproxXCubed.setName("ApproxXCubed"); |
| 43 |
ApproxXCubed.setDescription(""); |
| 44 |
ApproxXCubed.setEnabled(true); |
| 45 |
ApproxXCubed.setRange(-5.000, 5.000); |
| 46 |
ApproxXCubed.setLockValueInRange(false); |
| 47 |
ApproxXCubed.setAggregation(null); |
| 48 |
ApproxXCubed.setDefuzzifier(new WeightedAverage("TakagiSugeno")); |
| 49 |
ApproxXCubed.setDefaultValue(Double.NaN); |
| 50 |
ApproxXCubed.setLockPreviousValue(false); |
| 51 |
ApproxXCubed.addTerm(Linear.create("TangentatNegFive", engine, 75.000, 250.000)); |
| 52 |
ApproxXCubed.addTerm(Linear.create("TangentatNegFour", engine, 48.000, 128.000)); |
| 53 |
ApproxXCubed.addTerm(Linear.create("TangentatNegThree", engine, 27.000, 54.000)); |
| 54 |
ApproxXCubed.addTerm(Linear.create("TangentatNegTwo", engine, 12.000, 16.000)); |
| 55 |
ApproxXCubed.addTerm(Linear.create("TangentatNegOne", engine, 3.000, 2.000)); |
| 56 |
ApproxXCubed.addTerm(Linear.create("TangentatZero", engine, 0.000, 0.000)); |
| 57 |
ApproxXCubed.addTerm(Linear.create("TangentatOne", engine, 3.000, -2.000)); |
| 58 |
ApproxXCubed.addTerm(Linear.create("TangentatTwo", engine, 12.000, -16.000)); |
| 59 |
ApproxXCubed.addTerm(Linear.create("TangentatThree", engine, 27.000, -54.000)); |
| 60 |
ApproxXCubed.addTerm(Linear.create("TangentatFour", engine, 48.000, -128.000)); |
| 61 |
ApproxXCubed.addTerm(Linear.create("TangentatFive", engine, 75.000, -250.000)); |
| 62 |
engine.addOutputVariable(ApproxXCubed); |
| 63 |
|
| 64 |
RuleBlock ruleBlock = new RuleBlock(); |
| 65 |
ruleBlock.setName(""); |
| 66 |
ruleBlock.setDescription(""); |
| 67 |
ruleBlock.setEnabled(true); |
| 68 |
ruleBlock.setConjunction(null); |
| 69 |
ruleBlock.setDisjunction(null); |
| 70 |
ruleBlock.setImplication(null); |
| 71 |
ruleBlock.setActivation(new General()); |
| 72 |
ruleBlock.addRule(Rule.parse("if X is AboutNegFive then ApproxXCubed is TangentatNegFive", engine)); |
| 73 |
ruleBlock.addRule(Rule.parse("if X is AboutNegFour then ApproxXCubed is TangentatNegFour", engine)); |
| 74 |
ruleBlock.addRule(Rule.parse("if X is AboutNegThree then ApproxXCubed is TangentatNegThree", engine)); |
| 75 |
ruleBlock.addRule(Rule.parse("if X is AboutNegTwo then ApproxXCubed is TangentatNegTwo", engine)); |
| 76 |
ruleBlock.addRule(Rule.parse("if X is AboutNegOne then ApproxXCubed is TangentatNegOne", engine)); |
| 77 |
ruleBlock.addRule(Rule.parse("if X is AboutZero then ApproxXCubed is TangentatZero", engine)); |
| 78 |
ruleBlock.addRule(Rule.parse("if X is AboutOne then ApproxXCubed is TangentatOne", engine)); |
| 79 |
ruleBlock.addRule(Rule.parse("if X is AboutTwo then ApproxXCubed is TangentatTwo", engine)); |
| 80 |
ruleBlock.addRule(Rule.parse("if X is AboutThree then ApproxXCubed is TangentatThree", engine)); |
| 81 |
ruleBlock.addRule(Rule.parse("if X is AboutFour then ApproxXCubed is TangentatFour", engine)); |
| 82 |
ruleBlock.addRule(Rule.parse("if X is AboutFive then ApproxXCubed is TangentatFive", engine)); |
| 83 |
engine.addRuleBlock(ruleBlock); |
| 84 |
|
| 85 |
|
| 86 |
} |
| 87 |
} |