Efficiency in bach.constraints

Discussions, advice, bug reports and much more about the "bach" environment.
Post Reply
Lauprellim
Posts: 22
Joined: Sun Jul 11, 2021 7:35 am

Efficiency in bach.constraints

Post by Lauprellim » Wed May 18, 2022 12:02 pm

Hello again!

I have a question about bach.constraints. I am trying to achieve more efficiency in the computation of solutions using the deterministic solver. Is there any advantage to ordering rules in a certain way when listing them in the [bach.keys] object that gets placed under the rightmost outlet of [bach.constraints]?

Here is a more specific instance of what I am asking. Let's say I want to check the entire proposed solution for some property (such as "has a unique high or low point") and reject it if it violates that constraint. But I also want to check every pairwise proposed solution for a property (such as "does not repeat a note twice"). Would it make any difference to the engine to order these constraints in a particular way in [bach.keys]?

E.g. [bach.keys hilopoint repeatnote] versus [bach.keys repeatnote hilopoint].

Many thanks & best wishes -- paul

andreaagostini
Posts: 209
Joined: Fri Dec 03, 2010 1:51 pm

Re: Efficiency in bach.constraints

Post by andreaagostini » Sat May 21, 2022 8:35 am

Hi,

There might be a minimal performance improvement if rules that are evaluated more times appear earlier in bach.keys, but I wouldn't expect anything significant.

On the other hand, the deterministic engine of bach.constraints internally rearranges both the constraints and the domains so as to improve the efficiency of the search.

Best,
andrea

Lauprellim
Posts: 22
Joined: Sun Jul 11, 2021 7:35 am

Re: Efficiency in bach.constraints

Post by Lauprellim » Tue May 24, 2022 3:03 am

Thank you, Andrea! Needless to say I am utterly fascinated with the harmony generator in the help file of [bach.constraints] -- it has provided much inspiration over the last few months. Slowly but surely I am learning more about how it all works. Best always -- paul

lucas_r_r
Posts: 10
Joined: Wed Oct 30, 2019 5:35 pm

Re: Efficiency in bach.constraints

Post by lucas_r_r » Sat May 28, 2022 10:55 am

I would like to join in my praise to bach.constraints. I'm using it a lot, but I still have a lot to learn!

Post Reply