How to obtain a Boolean Factor

(Samuel Thiriot) #1

I’m working on a method which should accept discrete search spaces. My first use case contains for instance enumerated types (which might stand for install technology of “type A” or “type B”) and Boolean types (like “install photovoltaic panels on this building or not”).

I would like to implement a method able to deal with that. It is obviously better to rely on the usual OpenMole framework, that is Factors, which enable writing nice things like:
param1 in (0.0, 99.0),
param2 in (5, 500),
param3 in (“1”,“2”,“3”)

However, I cannot write the equivalent for a Boolean factor, as a Boolean factor has nothing which will be implicitely decoded as Bounds (if my understanding is good)
val paramB = Val[Boolean]
param1 in (0.0, 99.0),
param2 in (5, 500),
param3 in (“1”,“2”,“3”),

Do you have an idea on how to implemnt that ?

(Samuel Thiriot) #2


(Juste Raimbault) #3

Sorry for my rough answer in the issue then, I did not get that your question was about attributing the values (what may be not well documented and a potential issue then).
Does not “paramB in Seq(true,false)” do the job ?


Can you give a full example. In which kind of exploration do you intend to use it?

(Samuel Thiriot) #5

No pb !

It does ! Perfect ! Thanks

(Samuel Thiriot) #6

Hey Romain!

If you have no time, my question was solved, so you can stop there ^^

Well basically it’s about the implementation of a “new” (to OpenMole) method based on classifier systems. It works a lot like genetic algorithms, so I also ask the user the search space and encode it as kind of genes (as done in the “Genome” part of the “evolution” plugin. As you did there, I’m using implicit functions to decode factors into genes. Boolean factors were never matched until the trick from justin with Seq(true, false).

tks for support !



FYI: Val[Boolean] are factors already, no need for the in Seq(true, false).

(Samuel Thiriot) #8

Well strangely enough it’s not working with just the Val[Boolean], but it’s probably in my code.

I want the user to write something like:

    microActions = Seq(
                        actionInstallReno in (0.0, 0.152),
                        actionInstallBattery in (50, 10000), 
                        actionInstallPV in Seq(true, false) ), 

I’ve stuff like that:

 implicit def factorIsDoubleGene[D](f: Factor[D, Double])(implicit bounded: Bounds[D, Double]) =
    DoubleGene(f.prototype, bounded.min(f.domain), bounded.max(f.domain))

  implicit def factorIsIntegerGene[D](f: Factor[D, Int])(implicit bounded: Bounds[D, Int]) =
    IntegerGene(f.prototype, bounded.min(f.domain), bounded.max(f.domain))

  implicit def factorIsBooleanGene[D](f: Factor[D, Boolean]) =

The Boolean version is called with the Seq(true, false), but not without it. If I try the Val alone, this implicit conversion is not called. So I had the feeling it was not a factor. But maybe I did something wrong ?

(sorry, it’s difficult talking about excerpts of code…)


It is actually implement here:

(Samuel Thiriot) #10

Ok, I see; it should work. I’ll dig in my code to see why it’s not activated in my tests. In the meantime the workaround from justin will help. Tks a lot !

(Juste Raimbault) #11

You’re integrating classifiers into OpenMOLE ? :heart_eyes:
Can we imagine going towards neural nets ? :slight_smile:

(Samuel Thiriot) #12

Well, I’m rather integrating LCS, as my goal is to discover rules which are meaningful to a human being. I don’t have a use case with neural nets used for classification… do you ?

(Juste Raimbault) #13

Nice !
I don’t, but I would like to dig a bit into it (when I will have time in another life) :slight_smile:


If it is shaped like a genetic algorithm, it might be worth implementing it in MGO. Then OpenMOLE proposes steady state and island based distribution scheme.

If you implement a generation based algorithm it will be very inefficient.

(Samuel Thiriot) #15

Yes, that’s what I’m afraid of.
Yet when we discussed MGO, I remember you said it is complex and undocumented. So I start in OpenMole, which is already not that easy as I’ve to discover a lot of things. It the prototype works, it will be time to consider investing much more time in undestanding MGO… that’s my perspective until now, but I’m open to suggestions !