aGrUM/pyAgrum 3.3.0 released

  • pyAgrum

    • Configuration in C++: pyagrum.config is now the C++ gum::Configuration (PyAgrumConfiguration and
      pyagrum/config.py removed), with the same API and the same defaults.ini / pyagrum.ini files.
    • Renamed configuration keys: the default_ prefix is dropped and the keys of the look of the graphs
      (notebook, factorgraph, dynamicBN, influenceDiagram, credalnet, causal) are now lowerCamelCase keys
      defined in aGrUM. The old names are deprecated (still accepted, with a DeprecationWarning).
    • Graphs drawn by aGrUM: the raw toDot() of graphs and models now gives the look displayed in notebooks, and
      accepts a new pyagrum.DotOptions (size, layout, labels, colors of nodes and arcs). Font colors can be adaptive
      (black or white according to the background, the new default). Graphs given by the user are shown as they are.
      Code parsing the text of a toDot() may have to be adapted.
    • pyagrum.lib._colors renamed pyagrum.lib.dotstyle (deprecated relay kept); hex2rgb deprecated (use
      color2rgb); CausalModel.toDot() arguments SHOW_LATENT_NAMES, NODE_BG, NODE_FG, EDGE_COL deprecated.
    • skbn.BNClassifier: priorWeight now defaults to the configuration.
    • Fixed proba2hex (invalid colors) and CLGInference2dot (without evidence). pyAgrum requires pydot>=2.
    • Exceptions: all the aGrUM exceptions are now exported by pyagrum (FactoryError, NotImplementedYet,
      IncompatibleEvidence, LearningError, ...). TypeError and IOError are renamed GumTypeError and
      GumIOError so that from pyagrum import * no longer shadows the Python builtins. pyagrum.IOError is deprecated
      (use GumIOError), as pyagrum.SyntaxError: syntax errors are raised as the builtin SyntaxError (the aGrUM
      class is no longer wrapped). A few checks of Python arguments (e.g. setEvidence or setTargets with a wrong
      type) and del pyagrum.config[...] now raise the builtin TypeError or SyntaxError instead of the aGrUM ones.
  • aGrUM

    • New: gum::Configuration: thread-safe, typed and documented configuration singleton (defaults embedded in
      the library from several sources, agrum.ini read at start-up, domains of validity, hooks, push/pop,
      save/load).
    • Defaults from the configuration: approximation schemes, sampling/Gibbs/LBP inferences, KL distances, learners
      (new key learning.BNLearnerPreferredAlgo), jgum writers and the text display of tensors read their defaults from
      the configuration. The corresponding macros (DEFAULT_EPSILON, GIBBSKL_DEFAULT_*, GUM_CHI_EPSILON, ...) are
      removed.
    • Numerical tolerances: core.epsilonCoarse, epsilonStandard and epsilonFine replace hard-coded literals
      (some tolerances change slightly, e.g. in IBayesNet::check() and AlmostDifferent).
    • New gum::dot (DotStyle, DotWriter, DotOptions, colors): all the toDot() share the same writer, read
      the configuration and accept DotOptions; new CredalNet::toDot(); several malformed dot outputs fixed.
    • KTBNLearner and KTBNAdaptiveLearner gain usePC(), useFCI() and useGreedyThickThinning().
    • Fixed the copy/move of IBNLearner and BNLearner::copyState(), which lost some options.
    • GibbsBNdistance now draws the variables at random by default (gibbsKL.drawnAtRandom).
    • Much faster reading of models with clang and MSVC (BIF, DSL, NET, UAI, O3PRM...): e.g. a large BIF file from
      8 s to 0.1 s with clang.
    • Aggregators min, max, median, amplitude, sum on values: they worked on the indices of the
      parents, which was wrong for ranges not starting at 0 and for parents with different domains. They now work on
      the values of the parents and give the closest value of the aggregator (saturated at both bounds). sum and
      amplitude need numerical variables (use count to count the true parents), min, max and median accept
      labelized variables (order of the labels) or numerical ones, but not both: an incompatible variable is rejected
      with TypeError (GumTypeError in pyAgrum). The decomposition of aggregators now gives the right domains to the
      intermediate nodes (#198, #201). The aggregators derive from MultiDimFoldAggregator (count, exists,
      forall, and, or: neutralElt_() and fold_() on the indices of the parents) or from
      MultiDimValueAggregator (min, max, median, amplitude, sum: buildValue_() on their values).
    • O3PRM: the error of a system that cannot be instantiated gives the reason (e.g. an unassigned reference slot or a
      parent refused by an aggregator) instead of an unknown error.
  • Bug fixes (aGrUM and pyAgrum), thanks to @jschueller for issues #181 to #205

    • ImportanceSampling: the weight of a sample kept only the ratio of the last node (#181).
    • Hybrid samplers (LoopySamplingInference, Loopy*Sampling in pyAgrum): they stopped too early, while the LBP
      prior still outweighed the samples, and the prior was weighted in the wrong units with weighted samplers (#181).
    • LoopyBeliefPropagation: the error of a sweep was never reset, so LBP stopped after two sweeps (#182).
    • ShaferShenoyLIMIDInference: the optimal policy of a decision now keeps its decision parents (#183), and the
      variance of MEU() includes the covariances between utilities (#188, thanks to Mathias Alerini, Equinor).
    • StructuredPlaner: action-dependent rewards are taken into account (#184); FMDPSimulator and the planners no
      longer crash on a variable without transition for an action, which now keeps its value (#187).
    • ShaferShenoyMRFInference::jointPosterior(wanted, declared) returned the joint of the declared target, not of
      the wanted one (#185).
    • MultiDimFunctionGraphManager: setSon and eraseNode left inconsistent parent links (#186).
    • MultiDimNoisyORCompound: a causal weight lower than the leak (invalid model, giving probabilities outside
      [0,1]) is now rejected with OutOfBounds (#190).
    • evidenceProbability() (LazyPropagation, ShaferShenoyInference, ShaferShenoyMRFInference) ignored the
      connected components without target; the MRF one returned Z(e) instead of P(e) (#191, #193).
    • evidenceImpact, evidenceJointImpact and jointMutualInformation (BN and MRF) no longer replace the targets
      and the evidence of the user (#192).
    • GibbsSampling: the chain could freeze on a starting state of null probability; it now starts from a state of
      positive probability (or raises IncompatibleEvidence/OperationNotAllowed) (#189); exactly burnIn()
      transitions are done and burnIn(0) is allowed (#194).
    • MeekRules: rule R4 was not Meek's R4, so some compelled edges stayed undirected (#195, thanks to
      @ldesreumaux).
    • MultiDimNoisyORCompound, MultiDimNoisyORNet, MultiDimNoisyAND: weights outside [0,1] or NaN (and a null
      leak for NoisyAND, also through its setter) are rejected (#205). BayesNet::addArc and addWeightedArc no
      longer leave an arc in the graph when the CPT refuses it.
    • PRM: the CPT of a cast descendant (setAsCastDescendant) ignored the label map (#199).
    • qBNSampling: qBNRejection reused stale operators after setEvidence/useFragmentBN (#197); the quantum
      registers are created in the order of the qubit map (#200); the binarized parent states follow the CPT order
      (#204); a variable with a single state is rejected with OperationNotAllowed instead of crashing (#203).