I am using the CLIPS V 6.31 through the .NET core wrapper provided.
So far , I have been able to
Assert a number of facts within the environment using the assert string function
Run the engine
Invoke (eval) a CLIPS native function (not a UDF) which returns a json representation of a CLIPS instance which is indeed the produced result of the run and deserialize it inside the C# application.
At this point, I do indeed to save into the database ( or .net app memory ) every fact or instance available within the environment before i dispose of the object. I will then load into a new environment the last persisted set of facts and instances where i left earlier.
the problem is , as I have learned ( and correct me if I'm wrong ) , functions (save) , (bsave) , (save-facts ) do not use a logical name and i therefore cannot capture their output ( as i would with wdisplay & (facts) function ) through custom routers .
I am aware that i can write the files into a hard disk and read from there or perhaps write other clips native functions to pass to c# string representations of every fact and instance within the env ( i believe there is no readily available function to do this )
The two of the approaches would negatively affect the performance of the application .
so what would be the correct approach for the problem at hand ? the performance is a matter of concern .
Many thanks in advance
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The ppfact function allows you to specify a logical name, so if you want to use a custom router you can iterate over the facts and use ppfact to direct the output to a logical name recognized by the router.
Thanks for the response. Also is there an equivalent to retrieve the instances ready to be loaded ? or do i need to write a function ? I understand (ppinstance) works in a different manner
In CLIPS 6.3, there are two C functions, EnvGetInstancePPForm and EnvGetFactPPForm, that will return the printed representation of an instance or a fact. You can iterate over the facts/instances and save that representation to later recreate the facts/instances. The drawback is that the buffer passed to the functions is fixed to whatever it's initially set. In CLIPS 6.4, the equivalent functions are InstancePPForm and FactPPForm and these use a data structure that will expand the string buffer needed to represent the entire fact/instance.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello there !
I am using the CLIPS V 6.31 through the .NET core wrapper provided.
So far , I have been able to
At this point, I do indeed to save into the database ( or .net app memory ) every fact or instance available within the environment before i dispose of the object. I will then load into a new environment the last persisted set of facts and instances where i left earlier.
the problem is , as I have learned ( and correct me if I'm wrong ) , functions (save) , (bsave) , (save-facts ) do not use a logical name and i therefore cannot capture their output ( as i would with wdisplay & (facts) function ) through custom routers .
I am aware that i can write the files into a hard disk and read from there or perhaps write other clips native functions to pass to c# string representations of every fact and instance within the env ( i believe there is no readily available function to do this )
The two of the approaches would negatively affect the performance of the application .
so what would be the correct approach for the problem at hand ? the performance is a matter of concern .
Many thanks in advance
The ppfact function allows you to specify a logical name, so if you want to use a custom router you can iterate over the facts and use ppfact to direct the output to a logical name recognized by the router.
Thanks for the response. Also is there an equivalent to retrieve the instances ready to be loaded ? or do i need to write a function ? I understand (ppinstance) works in a different manner
update : how about :
Is there a more efficient way or perhaps a native function for the purpose that i have missed ?
Last edit: Arya 2024-10-05
In CLIPS 6.3, there are two C functions, EnvGetInstancePPForm and EnvGetFactPPForm, that will return the printed representation of an instance or a fact. You can iterate over the facts/instances and save that representation to later recreate the facts/instances. The drawback is that the buffer passed to the functions is fixed to whatever it's initially set. In CLIPS 6.4, the equivalent functions are InstancePPForm and FactPPForm and these use a data structure that will expand the string buffer needed to represent the entire fact/instance.
Thanks for the prompt reply . I sure will check them out