solver binary variables

methody

Well-known Member
Joined
Jun 17, 2002
Messages
857
Hi there I am using solver to address a problem and basically it solves the problem i want it to solve.

Within the problem there are 6 columns and I am using sum at the bottom of each column. I want solver to indicate how many times those columns add up to 5. I was think of adding in binary values below each total so that a 1 would appear below the total which sum to 5. But I can't get it to work. I know it could be done simply with an if formula but that isn't possible.
Sorry could be clearer but any help appreciated.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
what kind of problem are you dealing with ?
I don't understand the picture.
 
Upvote 0
Hi sorry about that.
I'm using binary variables to create a schedule for teachers in school. There are 6 teacher names across the top and there are 8 periods down the left hand side. I have include constraints about the total for each teacher. That is all fine. So below each teacher there might be 1 1 1 0 1 1 0 1.
I am interested in the number of times a teacher teaches 3 periods in a row. I create a range of cells below which sums 3 cells. So in the example above there would be one case where the sum is 3.
I could use a countif to count the number of times teacher teaches 3 in a row but if a want to make that part of the model and try to the minimise that number solver wont let me as it doesn't like countifs

That's why i was trying to think of another way of effectively counting the number of cells which have 3 in them. I wondered if there would be a way of using an additional range of binary variables to effectively generate a 1 for every time that range had a 3 and a 0 everywhere else.

Probably still not very helpful

But it is effectively a question about any range of cells with a formula and is there a way of counting the number of cells with a particular value without using countif.
 
Upvote 0
what excel-version are you using ? 365, 2021 or older ?
how much is 11111010 ?
 
Upvote 0
Hi
I'm on Excel 365
Yes good question. That would yield 3 instances of 3 consecutive periods. I would hve envisaged that showing 3 '1's as binary variables
 
Upvote 0
methody.xlsx
something like this ?
methody.xlsx
ABCDEFGHIJ
1300040005000600070008000
2teacher1teacher2teacher3teacher4teacher5teacher6
330period11000012
440period20100012
550period30011114
660period40011114
770period50011114
880period60111115
990period71111105
10100period81111105
11100000110100011100111111001111110011111111111100
12014443
13min333333
14actual3466663131
15max666666
16
17goal2204.31020.45024.45028.45024.330102.210
Blad1
Cell Formulas
RangeFormula
C1:H1C1=COLUMN()*1000
A3:A10A3=ROW()*10
I3:I10,I17,I14I3=SUM(C3:H3)
C11:H11C11=TEXTJOIN(,,C3:C10)
C12:H12C12=SUM(--(MID(C11,ROW($B$2:$B$7),3)="111"))
C14:H14C14=SUM(C3:C10)
C17:H17C17=+SUMPRODUCT($A$3:$A$10,C3:C10)+C1*C12
Named Ranges
NameRefers ToCells
solver_adj=Blad1!$C$3:$H$10I3, C17, C14, C11
solver_lhs2=Blad1!$C$14:$H$14I14
solver_lhs3=Blad1!$C$3:$H$10I3, C17, C14, C11
solver_rhs1=Blad1!$C$14:$H$14I14
 
Upvote 0
Thanks BSALV
That's very clever and does what I asked but solver doesn't like TEXTJOIN when I ask it to solve a problem with it involved.
I'm not sure there's a way to do it as i think it has to use only pretty simple formulas. That's why I thought it might need to involve the use of creation of other binary variables.
thanks again
 
Upvote 0
i didn't use the simplex method, instead the evolutionary, but then you need to add more constraints.
 
Upvote 0

Forum statistics

Threads
1,214,659
Messages
6,120,781
Members
448,992
Latest member
prabhuk279

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