Menu

How to set parameters outside of d3web?

Help
Yang
2017-05-30
2017-05-30
  • Yang

    Yang - 2017-05-30

    Hey,

    In my case, there are some parameters in rules which would be changed outside of d3web. I think it is possible to do so by answering questions. But, it might not be feasible. So, is there any efficient way to set the parameters? For instance, loading a xml file?

    Thank you!

    Regards,
    Yang

     
  • Albrecht Striffler

    Hey Yang,

    yes, you can do this using the TimeDB-Plugin and abstract questions.
    Example: You have a pressure sensor and a variable threshold (maybe depending on temperature), at which you want to classify the pressure as ok or to high.

    It would look something like this:

    %%Question
    pressure [num]
    pressure_threshold [num] <abstract>
    %</abstract>

    %%Solution
    Pressure to high
    %

    %%Rule
    IF eval(pressure > pressure_threshold)
    THEN Pressure to high = P7
    %

    You can set the threshold the same way you set the value for other question, the flag <abstract> is optional (used to mark the question as an internal so it can be displayed accordingly in a GUI). The syntax with eval(...) is an extension from the TimeDB plugin and allows to compare questions not only to constant values/choices, but also to other questions. Inside eval() you can basically do the same as everything described here: https://www.d3web.de/Wiki.jsp?page=Doc%20Expressions</abstract>

    Regards
    Albrecht

     
  • Yang

    Yang - 2017-06-02

    Hey Albrecht,

    Thank you so much!

    In my case, there are some complex equations, such as f = a x + bx^2 + cX^3 + d....
    The parameters are determined in the java application. *

    I think it is a little boring to set so many questions in,
    %%Question
    The value of a [num]
    the value of b [num]
    ...
    %

    Therefore, I am wondering whether there is an alternative way.

    Thank you so much!

    With best regards,
    Yang

     
  • Albrecht Striffler

    If you want to use a variable in one of your formulas or any other knowledge snipplet in KnowWE, e.g. rule or flow chart, you have to define that variable in the %%Question markup, there is currently not really a way around it. I'm not sure if you understood correctly how to set values though. You don't set the values in the question markup, but afterwards either in any of the interviews like %%QuickInterview, or via tha API as described here https://www.d3web.de/Wiki.jsp?page=How-To%20Create%20a%20Session#section-How-To+Create+a+Session-EnteringFactsToTheSession
    So the %%Question markup looks like this:

    %%Question
    a [num]
    b [num]
    c [num]
    d [num]
    x [num]
    f [num]
    %

    Then, when you have your formula, e.g.

    %%Variable
    f = a x + bx^2 + cX^3 + d
    %

    and you have set all the values needed in the formula (a, b, c, d, x), the value of f will be calculated directly.

     

Log in to post a comment.

MongoDB Logo MongoDB