{"id":16390914,"url":"https://github.com/sorend/fuzzy4j","last_synced_at":"2025-03-21T02:32:07.691Z","repository":{"id":28912861,"uuid":"32437799","full_name":"sorend/fuzzy4j","owner":"sorend","description":"Fuzzy logic library for Java","archived":false,"fork":false,"pushed_at":"2024-09-25T03:22:18.000Z","size":340,"stargazers_count":19,"open_issues_count":2,"forks_count":7,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-12T04:44:36.295Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sorend.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-03-18T04:28:52.000Z","updated_at":"2024-09-25T03:19:31.000Z","dependencies_parsed_at":"2024-08-15T13:17:00.303Z","dependency_job_id":null,"html_url":"https://github.com/sorend/fuzzy4j","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sorend%2Ffuzzy4j","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sorend%2Ffuzzy4j/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sorend%2Ffuzzy4j/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sorend%2Ffuzzy4j/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sorend","download_url":"https://codeload.github.com/sorend/fuzzy4j/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221811384,"owners_count":16884305,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T04:44:38.349Z","updated_at":"2024-10-28T09:10:25.155Z","avatar_url":"https://github.com/sorend.png","language":"Java","funding_links":[],"categories":["人工智能"],"sub_categories":["模糊逻辑"],"readme":"\nFuzzy logic library for Java (fuzzy4j) [![Build Status](https://travis-ci.org/sorend/fuzzy4j.svg?branch=master)](https://travis-ci.org/sorend/fuzzy4j) [![Release](https://jitpack.io/v/sorend/fuzzy4j.svg)](https://jitpack.io/#sorend/fuzzy4j) [![codecov](https://codecov.io/gh/sorend/fuzzy4j/branch/master/graph/badge.svg?token=4fc29BofFf)](https://codecov.io/gh/sorend/fuzzy4j)\n======================================\n\nFuzzy4j is a Java library implementing many commonly used fuzzy logic functions from the areas of fuzzy sets,\nfuzzy aggregation, and fuzzy controller. The library was initially developed as part of the fuzzy logic course under\nprof. Henrik Legind Larsen at Aalborg University, Esbjerg. Later it has been applied in different real-world\napplications under EU-FP7. If you are using fuzzy4j for something interesting, please drop us a line, thanks!\n\nThe goals of fuzzy4j is to implement a fuzzy toolbox for Java: 1) to give a set of meaningful and modern interfaces\nwhich can be used to implement your own fuzzy code; and 2) to provide default implementations of most common\nfuzzy sets, aggregations and controllers.\n\nWe are thankful for the collaborators, users who provide feedback, and researchers who have come up with fuzzy logic.\n\nUsage\n-----\n\nSource-code is available in GitHub, and can as such always be forked or cloned from https://github.com/sorend/fuzzy4j .\nThe pre-built artifacts are deployed in the https://jitpack.io repository. You can add this repository to your Maven\n(or Maven compatible, such as Ivy or SBT) for easy inclusion:\n\n    \u003crepository\u003e\n        \u003cid\u003ejitpack.io\u003c/id\u003e\n        \u003curl\u003ehttps://jitpack.io\u003c/url\u003e\n    \u003c/repository\u003e\n\nOnce the repository has been added, the artifact can be included in your project as shown below:\n\n    \u003cdependency\u003e\n        \u003cgroupId\u003efuzzy4j\u003c/groupId\u003e\n        \u003cartifactId\u003efuzzy4j\u003c/artifactId\u003e\n        \u003cversion\u003e${fuzzy4j.version}\u003c/version\u003e\n    \u003c/dependency\u003e\n\nFuzzy sets\n----------\n\nFuzzy sets are implemented as FuzzyFunctions. The current implementations are found in the fuzzy.sets package.\nCreating a fuzzy set based on a specific triangular function and it's negation.\n\n    FuzzyFunction f = new TriangularFunction(0.0, 1.5, 6.0);\n    FuzzyFunction not_f = new ZadehNegation(f);\n\n    double mu_x = f.apply(1.0);\n    double not_mu_x = not_f.apply(1.0);\n\nFuzzy aggregation operators\n---------------------------\n\nFuzzy aggregation of values, see fuzzy4j.aggregation for implemented aggregation operators. A small example below:\n\n    Aggregation owa = new OWA(0.5, 0.2, 0.2, 0.1);\n    double aggr = owa.apply(0.8, 0.2, 0.7, 0.1);\n\nThere is also a class of weighted aggregation operators, see fuzzy4j.aggregation.weighted. A small example below:\n(\"_\" is static imported WeightedValue._)\n\n    WeightedAggregation wowa = new WeightedOWA(0.1, 0.5, 0.5, 0.2, 0.2, 0.1);\n    double waggr = wowa.apply(_(1.0, 0.8), _(1.0, 0.2), _(1.0, 0.7), _(1.0, 0.1));\n\nMany of the aggregation operators require parameters for instantiation. The unified method\nfor instantiazing them is to use ParametricFactory\u003cT\u003e. Most of the implemented aggregation\noperators with parameters already contain such a factory. Look for a static FACTORY attribute.\nAs an example below is shown the OWA operator, which contains two factories:\n\n    // create OWA operator with specific OWA weights.\n    OWA owa1 = OWA.FACTORY.create(0.5, 0.25, 0.1, 0.1, 0.05);\n    // create OWA operator with MEOWA weights from andness.\n    OWA owa2 = OWA.MEOWA_FACTORY.create(5, 0.8);\n\nFuzzy controller (flc)\n----------------------\n\nA part of the fuzzy4j library is the fuzzy logic controller (flc). This allows you\nto programatically construct fuzzy logic controllers.\n\nThe following example is taken from the test class.\n\n    Term cold = term(\"cold\", 10, 40, 70);\n    Term ok   = term(\"ok\", 40, 70, 100);\n    Term hot  = term(\"hot\", 70, 100, 130);\n\n    Variable room = input(\"room\", cold, ok, hot).start(40).end(100);\n\n    Term low  = term(\"low\", -50, 0, 50);\n    Term medi = term(\"medium\", 0, 50, 100);\n    Term high = term(\"high\", 50, 100, 150);\n\n    Variable effort = output(\"effort\", low, medi, high).start(-50).end(150);\n\n    FLC impl = ControllerBuilder.newBuilder()\n            .when().var(room).is(cold).then().var(effort).is(high)\n            .when().var(room).is(ok).then().var(effort).is(medi)\n            .when().var(room).is(hot).then().var(effort).is(low)\n            .create();\n\n    InputInstance instance = new InputInstance().is(room, 60);\n\n    System.out.println(\"fuzzy = \" + impl.applyFuzzy(instance));\n\n    Map\u003cVariable, Double\u003e crisp = impl.apply(instance);\n\n    System.out.println(\"crisp = \" + crisp);\n\nYou can create terms by discretizing using one of the methods from Discretizations.\nFor example to create a number of uniformly distributed triangular functions, see below:\n\n    Term[] terms = Discretizations.uniformTriangular(0.0, 10.0, \"low\", \"medium\", \"high\");\n\n    assert \"low\".equals(terms[0].name);\n    assert \"medium\".equals(terms[1].name);\n    assert \"high\".equals(terms[2].name);\n\nVariables have a default domain of [0, 1] (the unit interval). You can set a different\ndomain by using start(..) and end(..) on the variable. The defuzzifiers use a number of\nsamples to determine the defuzzified value, the default number of samples is 100. If you\nchange the domain of a variable, you accordingly set the number of samples to an appropriate\nnumber. See the example of domain and samples below:\n\n    Term low    = term(\"low\", 0, 0, 36.0, 37.25);\n    Term normal = term(\"normal\", 36.0, 37.25, 38.5);\n    Term high   = term(\"high\", 37.26, 38.5, 100, 100);\n\n    // set domain to [0, 100]\n    Variable temp = output(\"temp\", low, normal, high).start(0).end(100);\n\n    // create a centroid defuzzifier, and set number of samples to 1000\n    Centroid defuzzifier = new Centroid();\n    defuzzifier.setSamples(1000);\n\nYou can use hedges to modify matching of a term in rules. For example the \"not\" hedge\nwill match not. You can build hedges using the static methods in HedgeBuilder, or, you\ncan implement your own Hedge. In the example below the \"not\" and \"very\" hedges are\nused.\n\n    FLC impl = ControllerBuilder.newBuilder()\n            .when().var(temp).is(not(high)).then().var(paracetamol).is(none)\n            .when().var(temp).is(very(high)).then().var(paracetamol).is(moderate)\n            .defuzzifier(new Centroid())\n            .create();\n\n\nLicense\n-------\n\nFuzzy4j is licensed under MIT license.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsorend%2Ffuzzy4j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsorend%2Ffuzzy4j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsorend%2Ffuzzy4j/lists"}