New Var type

50 views
Skip to first unread message

Ilya Kudryavtsev

unread,
Dec 26, 2023, 8:05:39 AM12/26/23
to choco-solver
Hello the Choco team!

I have a question: is it possible to add new variables types to the Choco-solver? I'm interested in bit-fields. For sure 128-bit length, and, probably, even more. So, it's range is out of Java's ints, and could not be easily modeled using IntVars, also because I need some specific constraints, like taking middle part of the bit-vector. Now I'm looking for the solver start with, and contribute. 

Do you have some article on the Choco's high-level architecture? Like MiniCP? 

Thanks,
Ilya 

cpru...@gmail.com

unread,
Jan 22, 2024, 7:25:47 AM1/22/24
to choco-solver
Hello
Sorry, I missed your question.
Actually, you can extend Choco with new variables, but that requires a lot of work:
1. Declaring a new class which extends AbstractVariable and implements Variable (or possibly an intermediate interface).
You can have a look at SetVarImpl and SetVar if you want to start with something simper than IntVar. In particular, you will have to define:
a. ISetDelta getDelta() : might be needed if removed values are to be stored to react to fine event, 
b. ISetDeltaMonitor monitorDelta(ICause propagator) : complementary to the previous method
c. int getTypeAndKind() : to define the type (int, set, graph, ...) and the kind (var, view, constant) of the new variable
d. EvtScheduler<?> getEvtScheduler() : depending on the events to which the variable's propagators react, they can be finely scheduled
e. you possibly need to declare a backtrackable structure (like IStateInt or IStateBitset) to store the values.

2. Declaring the propagators for the new type of variable
3. Declaring the new type of decision (see IntDecision) and new search strategies.
4. If you want to deal with COP you'll probably have to change some things in the solver too.

if you want a more responsive experience, it's best to go to Discord: https://discord.gg/fty6Nrzg

Best 
Charles
Reply all
Reply to author
Forward
0 new messages