Question on Solver

KevinZ

New Member
Joined
Apr 14, 2019
Messages
33
I am trying to run the code below. When I run this, I am getting the following error message:

OpenSolver Could not find an optimal solution, and reported: Infeasible

The Model contains a restraint 'I2:I160 >=1' for which instance 4does not depend on the decision variable and is not satisfied.
Constraint specifies: LHS=I5>=RHS=1=1

No Solution was available to load into the spreadsheet.

This is the code from the VBA. I am trying to add the code below in green. It should be that if the value in column I is >=0, then it is available to use the data for the row.

For example: If row 6 has a value of 4 in I6, then it can be included in the solution, If row 7 has a value of 0 in I7, then it should not be included in the solution.
I am trying to avoid putting each row in the constraints, as the number of rows varies over time.

' SolverOkSetCell:="$L$3", MaxMinVal:=1, ValueOf:=0, ByChange:="$A$2:$A$160",_
' Engine:=1,EngineDesc:="GRG Nonlinear"
' SolverAdd CellRef:="$A$2:$A$160", Relation:=5,FormulaText:="binary"
' SolverAdd CellRef:="$L$10",Relation:=1, FormulaText:="$L$5"
' SolverAdd CellRef:="$L$10", Relation:=3,FormulaText:="$L$6"
' SolverAdd CellRef:="$L$9",Relation:=2, FormulaText:="$L$8"
'SolverAddCellRef:="$L$3", Relation:=1, FormulaText:="$L$12"
' 'if Remaining (Column I) >=1,use, if <=1 skip
' SolverAdd CellRef:=" I$2:$I$160",Relation:=3, FormulaText:="1"

Please let me know if you have any ideas or if this doesn't make sense or is not possible.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Sorry, the green color was removed. The line I am having issues with is:
' SolverAdd CellRef:=" I$2:$I$160",Relation:=3, FormulaText:="1"
 
Upvote 0

Forum statistics

Threads
1,214,611
Messages
6,120,509
Members
448,967
Latest member
screechyboy79

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