Skip to content

Commit 6e34d5b

Browse files
committed
version update
removed incorrect error handling for exceeding maximum number of constraints Solver can handle - SolverWrapper now defers to DLL for handling
1 parent c0ce5c5 commit 6e34d5b

26 files changed

+35
-44
lines changed
Binary file not shown.
Binary file not shown.

dist/SolverWrapperDLLSetup.exe

-108 KB
Binary file not shown.
-107 Bytes
Binary file not shown.

src/twinBASIC/source/ClassFactory.bas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Attribute VB_Description = "This class is used for object instantiation when ref
33
'%ModuleDescription "This class is used for object instantiation when referencing SolverWrapper externally from another VBA project"
44
'@folder("SolverWrapper.Source")
55
' ==========================================================================
6-
' SolverWrapper v0.8
6+
' SolverWrapper v0.9
77
'
88
' A wrapper for automating MS Excel's Solver Add-in
99
'

src/twinBASIC/source/SolvConstraints.cls

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Attribute VB_Description = "A class to set/manage Solver constraints."
1212
'@Exposed
1313
'@folder("SolverWrapper.Source")
1414
' ==========================================================================
15-
' SolverWrapper v0.8
15+
' SolverWrapper v0.9
1616
'
1717
' A wrapper for automating MS Excel's Solver Add-in
1818
'
@@ -60,10 +60,6 @@ Private oSolverSheet As Worksheet
6060
'%Description("Adds a constraint to the current problem.")
6161
Public Sub Add(ByVal cellRef As Variant, ByVal relation As SlvRelation, Optional ByVal formulaText As Variant)
6262
Attribute Add.VB_Description = "Adds a constraint to the current problem."
63-
If Me.Count + 1 > 100 Then
64-
Err.Raise vbObjectError + 4001, , "Number of Constraints must be less than or equal to 100"
65-
End If
66-
6763
Dim ws As Worksheet
6864
Dim solver_num As Long
6965

@@ -291,13 +287,13 @@ Private Sub ProcessConstraintParams(ByRef cellRef As Variant, ByVal relation As
291287
Err.Raise vbObjectError + 4001, , "Please specify a valid cell reference"
292288
End If
293289

294-
'could do this check in SolveIt right before calling dll - that way user can do things in any order
295-
'check that lhs refer(s) to the decision variables
296290
If relation > 3 Then
291+
'LHS MUST refer to the decision variables
292+
'and thus dose not count against the 100-cell constraint limit
297293
If Not NameExists("solver_adj", ws) Then
298294
Err.Raise vbObjectError + 4001, , "Cannot set constraint relations slvInt, slvBin, or slvAllDif, until after the decision variables are defined."
299295
End If
300-
If Not IsRangeInRange(ws.Range(cellRef), ws.Range(ws.Names("solver_adj").Name)) Then
296+
If Not IsRangeInRange(ws.Range(cellRef), ws.Names("solver_adj").RefersToRange) Then
301297
'the int, bin, and alldifferent constraints can only be applied to decision vars
302298
Err.Raise vbObjectError + 4001, , "The selected Relation only applies to contraints on decision variables."
303299
End If

src/twinBASIC/source/SolvDLL.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Attribute VB_Description = "This private class is used to communicate directly w
1111
'%ModuleDescription "This private class is used to communicate directly with DLL and is not exposed to User."
1212
'@folder("SolverWrapper.Source")
1313
' ==========================================================================
14-
' SolverWrapper v0.8
14+
' SolverWrapper v0.9
1515
'
1616
' A wrapper for automating MS Excel's Solver Add-in
1717
'

src/twinBASIC/source/SolvDecisionVars.cls

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Attribute VB_Description = "A class to define the Decision variable, i.e. the ce
1212
'@Exposed
1313
'@folder("SolverWrapper.Source")
1414
' ==========================================================================
15-
' SolverWrapper v0.8
15+
' SolverWrapper v0.9
1616
'
1717
' A wrapper for automating MS Excel's Solver Add-in
1818
'
@@ -53,9 +53,9 @@ Private oSolverSheet As Worksheet
5353
' ==========================================================================
5454

5555
'@DefaultMember
56-
'%Description("Adds a cell or range of cells that will be changed to achieve desired result in the target (objective) cell.")
56+
'%Description("Adds a cell(s) range that will be changed to achieve the desired result in the Objective cell - limited to 200 cells.")
5757
Public Sub Add(ParamArray cellRefs() As Variant)
58-
Attribute Add.VB_Description = "Adds a cell or range of cells that will be changed to achieve desired result in the target (objective) cell."
58+
Attribute Add.VB_Description = "Adds a cell(s) range that will be changed to achieve the desired result in the Objective cell - limited to 200 cells."
5959
Attribute Add.VB_UserMemId = 0
6060
Dim rCellRef As Range
6161
'initialize rCellRef - there can be more than one call to Add so check to see if its been called before...
@@ -67,8 +67,9 @@ Attribute Add.VB_UserMemId = 0
6767
End If
6868

6969
If Me.Count + rCellRef.Count > 200 Then
70-
Err.Raise vbObjectError + 4001, , "Number of Decision Variables must be less than or equal to 200"
70+
Err.Raise vbObjectError + 4001, , "Number of Decision Variable cells must be less than or equal to 200"
7171
End If
72+
7273
ProcessDecisionVars rCellRef
7374
End Sub
7475

src/twinBASIC/source/SolvObjective.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Attribute VB_Description = "A class to define the Solver Objective function."
1212
'@Exposed
1313
'@folder("SolverWrapper.Source")
1414
' ==========================================================================
15-
' SolverWrapper v0.8
15+
' SolverWrapper v0.9
1616
'
1717
' A wrapper for automating MS Excel's Solver Add-in
1818
'

src/twinBASIC/source/SolvOptions.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Attribute VB_Description = "A class to set Solver Options."
1212
'@Exposed
1313
'@folder("SolverWrapper.Source")
1414
' ==========================================================================
15-
' SolverWrapper v0.8
15+
' SolverWrapper v0.9
1616
'
1717
' A wrapper for automating MS Excel's Solver Add-in
1818
'

0 commit comments

Comments
 (0)