关于规则引擎:CLIPS 和与 C 的集成 | 珊瑚贝

CLIPS and integration with C++


我正在开发一个相当复杂的规则引擎。所以我决定借助任何 GNU 规则引擎并将其与我的应用程序集成。我发现 CLIPS 是一个很好的规则引擎。

现在,我的应用程序是 C 语言,我想要一个示例方法(一种 Hello world 程序),我可以从中学习如何将 .clp 规则引擎集成到我的 C 应用程序中。

问题

  • 我的应用程序是在 Linux/AIX/HP 和 Mingw (for windows) 上开发的。我们能否在 CLIPS 中开发规则引擎并将其集成到所有这些平台上的 C 应用程序中?您能否分享有关如何集成的链接。
  • 进入规则引擎的根本原因是,我已经体验到在我的 C/C 应用程序中”构建”的规则会占用大量内存/CPU。我的印象是,通过使用规则引擎,我可以以更优化(更好的资源利用率)的方式实现相同的目标。 CLIPS 可以帮助我实现这一目标吗?
  • 更新 1:

    • 您正在开发什么样的应用程序?
      总而言之,我正在开发一个基于过滤器匹配的计数器。用户可以增加 (NetworkID=XYZ, Increment count = 7), (NetworkID = MNO, Increment count=934)… 等等。现在您得到 NetworkID=X* 的查询,然后我需要提供来自 XAA 的所有计数。 ..XZZ。它在跨不同节点(分布式环境)的多进程、多线程中更新。

    • 为什么里面有专家系统规则,是什么规则?
      现在,我的平台/应用程序在 C 中(用户在其中进行递增/递减/查询)。现在我想使用规则引擎来帮助我完成这些。用 C/C 代码编写逻辑似乎会消耗更多所需的资源。

    PS:增量/减量/查询相关的关键代码都在优化的c代码中。一些package器在 C 代码中。所以我正在检查规则引擎来为我做这件事,它可以从我的平台/应用程序(在 C/C 代码中)调用。

    • 你在开发什么样的应用,为什么里面有专家系统规则,什么样的规则?
    • @BasileStarynkevitch:更新了问题以回答您的观点。
    • 今天,CLIPS 似乎主要是 Java。您是否考虑在应用程序中嵌入高级脚本解释器?
    • CLIPS 确实存在于 C 语言中,但它可能不会被大量维护。在 Debian 或 Ubuntu 上使用 clisp 和 libclips-dev 软件包


    将 CLIPS 与 C 集成的最简单方法是使用编译器选项(如果可用)将 C 代码编译为 C 代码。来自高级编程指南 (http://clipsrules.sourceforge.net/documentation/v624/apg.htm) 的第 1.2 节,C 兼容性:

    The CLIPS source code can now be compiled using either an ANSI C or
    C++ compiler. Minimally, non-ANSI C compilers must support full ANSI
    style function prototypes and the void data type in order to compile
    CLIPS. If you want to make CLIPS API calls from a C++ program, it is
    usually easier to do the integration by compiling the CLIPS source
    files as C++ files. This removes the need to make an extern”C”
    declaration in your C++ program for the CLIPS APIs. Some programming
    environments allow you to specify the whether a file should be
    compiled as C or C++ code based on the file extension. Other
    environments allow you to explicitly specify which compiler to use
    regardless of the extension (e.g. in gcc the option”-x c++” will
    compile .c files as C++ files). In some environments, the same
    compiler is used to compile both C and C++ programs and the compiler
    uses the file extension to determine whether the file should be
    compiled as a C or C++ program. In this situation, changing the .c
    extension of the CLIPS source files to .cpp usually allows the source
    to be compiled as a C++ program.

    您可以选择尝试使用clipsmm (http://sourceforge.net/projects/clipsmm/) 之类的东西,它是CLIPS 库的C 接口。


    来源:https://www.codenong.com/11667628/

    微信公众号
    手机浏览(小程序)

    Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

    Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

    Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_8950.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
    0
    分享到:
    没有账号? 忘记密码?