Running binary permutations

Tkeller

Board Regular
Joined
Jul 23, 2003
Messages
143
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Hello,

I have a model where I need to decide which of 30 fixed variables are going to be used in a final calculation. I set a swith to either turn each one on or off, then the model gives me the answer. I need to find the combination of these 30 variables that maximizes my final answer. The answer is not intuitive as if I use all the vairables I have blown my "budget". If I do this manually, it will require me to test 900 (30^2) possible combinations.

I have setup my model with a range of 30 contiguous cells that are contained in column B and I can set each of these cells to either 1 or 0 (true or false) to switch the variables in each of the adjacent cells in column C either on or off. If the cell is "off" it will not be used in the calculation.

What I am trying to do is to write a small VBA program that will cycle through all 900 combinations then provide the "range" of varible settings that gives the best answer. e.g. (0,0,0,1,1,1,0,0,0,0....1,1,1,0)

I am somewhat familiar with VBA but am stumped at how I would do this. In an ideal world I am somehow using a range of values for each of the 300 iterations, then capturing the best range.

Thanks!
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Hi Tkeller

The total number of permutations is not 30^2=900, it's 2^30=1,073,741,824.
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top