## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
Alessandro Savino
@xavier7179
@phwuill_gitlab no problem! You can also clone the formula and add to any other Homebrew repo you like :)
leeningzzu
@leeningzzu
@phwuill_gitlab Hi Pierre-Henri, pyAgrum is a brilliant library, I'm trying to discover it! I have some problems when I try to build the DBN model. if structure and parameter learning could be performed from data, without computing the CPTs for the DBN manually? I noticed that can be done for BN, but for transitions CPTs, how to perform it? Sorry for all these questions. pyAgrum is very useful to me, Thanks in advance.
Pierre-Henri Wuillemin
@phwuill_gitlab

Hi @leeningzzu,
Learning a dBNs is not difficult if you know how to learn BNs :-) It is mainly a database transformation problem. This code is not in pyAgrum since there is no canonical format for stochastic data that we know of.

Suppose you follow the variables A,B,C,... dynamically. Let us call X(t)=(A(t),B(t),C(t),...) the set of variables at time t. So your data for the learning process is a set of {X_k(0),...,X_k(T_k), for k in 1...N} (so there are N different trajectories with possibly different lengths T_1,...,T_N).

• Then you have to construct the database learn0=(X_1(0),X_2(0),...,X_N(0)) to learn the structure and parameters of the dBN at T=0,

• and you have to build learnTrans=([X_k(t),X_k(t+1)] for all k, for all t) to learn the structure and parameters of the dBN transition model.

Once the databases have been created, the 2 points are just the applications of pyAgrum's learning algorithms to produce BN_0 and BN_transition. This being done, you just have to copy structures and parameters of this 2 learned BNs into a dBN and it is done. :-)

Pierre-Henri Wuillemin
@phwuill_gitlab
PS- When learning the transition model, do not forget to add constraints in order to forbid backward arcs (from t+1 to t)
leeningzzu
@leeningzzu
Pierre-Henri Wuillemin
@phwuill_gitlab
Hello, aGrUM/pyAgrum 0.19.0 is out ! see https://agrum.gitlab.io/articles/agrumpyagrum-0190-released.html
Alessandro Savino
@xavier7179
@phwuill_gitlab I updated my homebrew repo too
Ketemwabi Yves Shamavu

Hi @leeningzzu,
Learning a dBNs is not difficult if you know how to learn BNs :-) It is mainly a database transformation problem. This code is not in pyAgrum since there is no canonical format for stochastic data that we know of.

Suppose you follow the variables A,B,C,... dynamically. Let us call X(t)=(A(t),B(t),C(t),...) the set of variables at time t. So your data for the learning process is a set of {X_k(0),...,X_k(T_k), for k in 1...N} (so there are N different trajectories with possibly different lengths T_1,...,T_N).

• Then you have to construct the database learn0=(X_1(0),X_2(0),...,X_N(0)) to learn the structure and parameters of the dBN at T=0,

• and you have to build learnTrans=([X_k(t),X_k(t+1)] for all k, for all t) to learn the structure and parameters of the dBN transition model.

Once the databases have been created, the 2 points are just the applications of pyAgrum's learning algorithms to produce BN_0 and BN_transition. This being done, you just have to copy structures and parameters of this 2 learned BNs into a dBN and it is done. :-)
Thanks, Pierre!

Makes so much sense. Thanks, Pierre!
Pierre-Henri Wuillemin
@phwuill_gitlab

You are very welcome. Do not forget the PS !

PS- When learning the transition model, do not forget to add constraints in order to forbid backward arcs (from t+1 to t)

Roger Hak
@CheeringRoger_gitlab
Hi Pierre-Henri, I have a question regarding influence diagram inference. I would like to know the expected utility of all the possible choices, not just the one that gives the maximum expected utility (ie.displayResult()). Do you know a way to obtain that information? Kind regards, Roger
Pierre-Henri Wuillemin
@phwuill_gitlab
Hi @CheeringRoger_gitlab, which version of pyAgrum are you using ? AFAIK, displayResult() is obsolete. We have now a new and much better (IMO) graphical display result : https://pyagrum.readthedocs.io/en/latest/influenceDiagram.html#inference
Roger Hak
@CheeringRoger_gitlab
Hi @phwuill_gitlab , that is awesome stuff! I updated to pyAgrum 0.19 and what an improvement that is. Thanks a lot! Exactly what I needed. Now I can easily get the posterior utilities of all my decision options.
Pierre-Henri Wuillemin
@phwuill_gitlab
nice :-)
yiruiZhao
@yiruiZhao
Hi Pierre-Henri, I receive an error when I trying to use the function loadBN() with Pyagrum. what is wrong?
Pierre-Henri Wuillemin
@phwuill_gitlab
Hi @yiruiZhao , do you have the file alarm.dsl in the directoryres ?
yiruiZhao
@yiruiZhao
Thank you, Prof. Pierre-Henri, I have found the related files in github. but I have two more questions, the first, does the gum. CNLoopyPropagation() refer to the GL2U algorithm or the L2U ? I noticed that only GL2U and MC Sampling are incorporated in the aGrUM , so, I guess the loopy propagation algorithm in pyAgrum referring to the GL2U. whatâ€™s more, can you give me more details about how to define the .evi file as an evidence for a credal net? Thanks a lot.
yiruiZhao
@yiruiZhao
Prof. Pierre-HenrI, I can load the WaterSprinkler. bif file with loadBN(), even the .bif file that I generated can be successfully loaded, but I can't load the "2Umin.bif" and the "2Umax.bif" files located in the directory cn, I guess that there are something wrong with these two files
Pierre-Henri Wuillemin
@phwuill_gitlab

Hi @yiruiZhao ,

Sorry for the slightly late answer, this algo (CNLoopyPropagation) is a specific L2U-based algo (binarization is a non-trivial process that deserves to be treated in a non-generic way). We have slightly optimized L2U (as well as our version of MonteCarlo).

The .evi files has a very simple structure and can contain 2 sections :

• [EVIDENCE] where one can specify (soft-like) evidence for each variable

[EVIDENCE]
L 0 1
G 1 0 1

(here L has the value 1, and G can not have the value 1)

• [QUERY] where one can specify for which variable-value one is interested to compute the probability interval

[QUERY]
A 1
H 0 1

I am interested in the probability interval for A=0 and for H=1

2Umin.bif and 2Umax.bif are bif files but for credal networks (proba max and proba min). They are used with CredalNets (as in http://webia.lip6.fr/~phw/aGrUM/docs/last/notebooks/14-Models_credalNetworks.ipynb.html):

cn=gum.CredalNet("cn/2Umin.bif","cn/2Umax.bif")
Pierre-Henri Wuillemin
@phwuill_gitlab

Hi again @yiruiZhao ,

I just remembered this discussion and that I forgot to mention something. So just to be clear: for Credal Networks, there are 2 inference algorithms implemented in aGrUM:

• MonteCarlo : works with all (discrete) credal networks
• LoopyBelief : an implementation of L2U, working only with binary credal networks.

But on the other hand, we propose a binarization (the one proposed by LG2U) that we do not do automatically because it implies a possible important modification of the underlying distribution (approximateBinarization)

With this binarization, you can use LoopyBelief on any discrete CN...

Pierre-Henri Wuillemin
@phwuill_gitlab
(the results for $F$ with the different inference)
Alessandro Savino
@xavier7179

@phwuill_gitlab Hi there. I updated the personal homebrew repo for v0.20.1. While the test in the Formula seems to work just fine (at least the new version is installed so I guess it compiled and run properly), when I try it in another (previous) project, I get stucked at some linker missing reference such as (on OSX):

Undefined symbols for architecture x86_64:
"__ZN3gum30BinaryJoinTreeConverterDefault7convertERKNS_11CliqueGraphERKNS_9HashTableImmSaISt4pairImmEEEERKNS_3SetImSaImEEE", referenced from:
__ZN3gum15LazyPropagationIfE13createNewJT__Ev in main.cpp.o

Did you ever experience such situation?

Another small issue I do not know if you are aware of: since I have different toolchains and I was trying to figure out the issue, I switched from my g++ homebrewed compiler to the standard OSX one: clang. I noticed that now it ships with openmp (previously you just had an error on CMake find _package) but on compilation the #include <omp.h> is not working.

Pierre-Henri Wuillemin
@phwuill_gitlab
Hi @xavier7179 , this error is quite weird since BinaryJoinTreeConverterDefaut(...) has not been changed for a while ...
Did you recompile your old project ? Do you have several versions of aGrUM installed in different places ?
For clang ans omp, I do not think any of us did know that ... Googling a bit, I found that https://stackoverflow.com/questions/66663120/fatal-error-omp-h-file-not-found-using-clang-on-apple-m1 ... But I have no clue for now ... Did you try to find omp.h in the clang's folder ?
Alessandro Savino
@xavier7179

Hi @xavier7179 , this error is quite weird since BinaryJoinTreeConverterDefaut(...) has not been changed for a while ...
Did you recompile your old project ? Do you have several versions of aGrUM installed in different places ?

actually yes, I recompiled everything and since I installed it using homebrew, only one version remains in the system... I also print the full verbose version of the command and everything seems right in terms of libraries... that one is only one of the many part that it does not link properly... it looks the static compilation of the library did not included everything

Pierre-Henri Wuillemin
@phwuill_gitlab

If the tests are OK, I think that the library is quite complete. The test coverage is not so bad and particularly for the BN's inference and especially for the LazyPropagation which is one of the most used algorithms in aGrUM ...

Can you find a minimal code that causes such linking errors so that we can test it ourselves ?

Alessandro Savino
@xavier7179
I debugged the installation further, during the linking of CXX static library all .o come out "has no symbols"... is it as expected?
Pierre-Henri Wuillemin
@phwuill_gitlab
do you see the same when compiling the tests ?
Pierre-Henri Wuillemin
@phwuill_gitlab
Hi again @xavier7179, I just succeeded in compiling and running the tests and the sample project in apps/aGrUM/HowToBuildSimpleBN on my mac book pro. I do not how to help you with your problem... Maybe you can share a minimized version of your project ?
Alessandro Savino
@xavier7179
actually, I noticed something strange. The installation ask for a static library, while the python act test release aGrUM -t all recompiles everything but the library is a dynamic one (and then the test are all just fine)
Pierre-Henri Wuillemin
@phwuill_gitlab
did you use the option "--static" ?
I can create such a static library and I can compile my HowToBuildSimpleBN against it ...
Pierre-Henri Wuillemin
@phwuill_gitlab
Just to be sure, I compiled aGrUM's tests against dynamic or static agrum's lib :
The first one (27422256 octets) is against .dynlib and the second one (39524344 octests) is against .a... Both are working correctly
By the way, the message about .o having no symbols is normal : a major part of aGrUM is template (or inlined) and then are compiled with the application and does not create any symbol in the library ...
Alessandro Savino
@xavier7179
As you can check in the Homebrew formula, I used the https://agrum.gitlab.io/pages/install-agrum-mac-os.html instructions to generate the formula. So the commando to generate the library is python act install release aGrUM --static -d INSTALL_PATH. The formula runs the hash table test to very the installation. In order to check it even further, I downloaded it and check everything by hand, thus I also run the act test part
what XCode version are you using as compile reference?
Pierre-Henri Wuillemin
@phwuill_gitlab
I do not have any xcode version (as far as I know :-) ), but homebrew ask me to xcode-select --install from time to time (command line tools). I am using MacOS Big Sur 11.3 (xcode-select version 2384.)
Pierre-Henri Wuillemin
@phwuill_gitlab
This is the correct command line for static library. Removing --static generates a .dynlib...
You can try and look at build/release/src/gumTest. You will see the difference in the size when compiling with or without --static
Alessandro Savino
@xavier7179

I found the 'bug'. If keep the suggested openmp include:

find_package(OpenMP)
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS}${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}${OpenMP_CXX_FLAGS}")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}${OpenMP_EXE_LINKER_FLAGS}")
else (OPENMP_FOUND)
endif(OPENMP_FOUND)

Pierre-Henri Wuillemin
@phwuill_gitlab
OK and yes, we need openMP ... and you saw this FATAL "OpenMP not found" ?
Alessandro Savino
@xavier7179
Actually not at all. The problem is that it enters in OPENMP_FOUND corretly but:
1. during the compilation of the library it prints:
-- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES)
-- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)
-- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND)
2. on a program:
-- Found OpenMP_C: -Xclang -fopenmp (found version "5.0")
-- Found OpenMP_CXX: -Xclang -fopenmp (found version "5.0")
-- Found OpenMP: TRUE (found version "5.0")
and I get Undefined sysmbols kind of errors
Pierre-Henri Wuillemin
@phwuill_gitlab
So the library found OpenMP_FOUND TRUE but OpenMP_C_FOUND and OpenMP_CPP_FOUND missing. And the program found everything TRUE ? What does the program's CMakeLists.txt ?
(I cannot reproduce this here, sorry)