Automate a problem: Ideias and sugestions;

Dear Knime community,

I've been trying to automate my problem without much success, hope you can give me some light:

I have 2 tables:

A = [10,8,3,2] (Values / Always Fixed)
B = [1,1,0,1] (Means Enabled 1, Disabled 0 / Dynamic)

C = SUMPRODUCT(A * B) = 20 (Goal Result) 

The solution I'm looking for is the best combination possible in B to archive my goal result:

Ex.: If my Goal Result is 18, so I know vector B should be B = [1,1,0,0] and SUMP(A*B) will return 18;

To archive this here are the steps I see:

1) Input Goal Result Value; Ex.: 18 from user
2) Need a Way to randomize table B with 0's,1's; Ex.: all combinations possible: (0,0,0,0),(0,0,0,1),(0,0,1,1),(0,1,1,1),...); [Not sure how to do it]
3) Each combination, multiply B * A and get SUMP result [not sure best way to do it, loop?]
4) Store Results
5) Get best combination possible to display B table

I appreciate any feedback, if something is not clear I'm happy to provide more info.


For step 2) I would use the Table Creator node to generate a vector with one 0 and one 1. I would connect this node to both Input ports of the Cross Joiner. Then the result of the Cross Joiner has to be connected to both Input ports of another cross joiner. You can transpose this table if needed.