Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Looping solver for recursive optimization

I have an optimization problem that is broken down into a number of
smaller optimization problems given the number of observations on a
variable. On each observation, I would like to have solver change a
range of two cells to minimize the a third cell. This would be looped
over the entire range of data given a starting reference. The problem
I am having though is that at every observation I get a break "Code
Execution Has Been Interrupted". Here is the code I have so far:

Private Sub CommandButton1_Click()
Dim cell1 As Range
Dim cell2 As Range
Dim cell3 As Range
Dim rindex As Integer
Dim colindex As Integer
Dim i As Integer
Dim nobs As Integer
Set cell1 = Range("O13")
rindex = cell1.Row
colindex = cell1.Column
nobs = Cells(Rows.Count, "O").End(xlUp).Row
Application.DisplayAlerts = False
For i = 1 To (nobs - 13)
Set cell1 = Cells(rindex + (i - 1), colindex)
Set cell2 = Cells(rindex + (i - 1), colindex + 1)
Set cell3 = Cells(rindex + (i - 1), colindex + 3)
SOLVER.SolverReset
SOLVER.SolverOptions MaxTime:=100, Iterations:=1000,_
Precision:=0.000001,Convergence:=0.000001
SOLVER.SolverOk setcell:=cell3.Address, maxminval:=2,_
bychange:=Range(cell1, cell2).Address
SOLVER.SolverSolve userfinish:=True
Next i
End Sub


The break occurs at SOLVER.SolverSolve userfinish:=True. Thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Looping solver for recursive optimization

Hmm, dont know why you put the extra SOLVER at the beggining - but here is
some code i used for much the same thing and it works fine for me.

'Solve but dont display results
SolverSolve userfinish:=True
'get result
SolverFinish KeepFinal:=1

wrote in message
oups.com...
I have an optimization problem that is broken down into a number of
smaller optimization problems given the number of observations on a
variable. On each observation, I would like to have solver change a
range of two cells to minimize the a third cell. This would be looped
over the entire range of data given a starting reference. The problem
I am having though is that at every observation I get a break "Code
Execution Has Been Interrupted". Here is the code I have so far:

Private Sub CommandButton1_Click()
Dim cell1 As Range
Dim cell2 As Range
Dim cell3 As Range
Dim rindex As Integer
Dim colindex As Integer
Dim i As Integer
Dim nobs As Integer
Set cell1 = Range("O13")
rindex = cell1.Row
colindex = cell1.Column
nobs = Cells(Rows.Count, "O").End(xlUp).Row
Application.DisplayAlerts = False
For i = 1 To (nobs - 13)
Set cell1 = Cells(rindex + (i - 1), colindex)
Set cell2 = Cells(rindex + (i - 1), colindex + 1)
Set cell3 = Cells(rindex + (i - 1), colindex + 3)
SOLVER.SolverReset
SOLVER.SolverOptions MaxTime:=100, Iterations:=1000,_
Precision:=0.000001,Convergence:=0.000001
SOLVER.SolverOk setcell:=cell3.Address, maxminval:=2,_
bychange:=Range(cell1, cell2).Address
SOLVER.SolverSolve userfinish:=True
Next i
End Sub


The break occurs at SOLVER.SolverSolve userfinish:=True. Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Looping solver for recursive optimization

Thanks for the quick reply. I added SolverFinish KeepFinal:=1 and
removed the additional Solver but I still get the same break.

Graham Whitehead wrote:
Hmm, dont know why you put the extra SOLVER at the beggining - but here is
some code i used for much the same thing and it works fine for me.

'Solve but dont display results
SolverSolve userfinish:=True
'get result
SolverFinish KeepFinal:=1

wrote in message
oups.com...
I have an optimization problem that is broken down into a number of
smaller optimization problems given the number of observations on a
variable. On each observation, I would like to have solver change a
range of two cells to minimize the a third cell. This would be looped
over the entire range of data given a starting reference. The problem
I am having though is that at every observation I get a break "Code
Execution Has Been Interrupted". Here is the code I have so far:

Private Sub CommandButton1_Click()
Dim cell1 As Range
Dim cell2 As Range
Dim cell3 As Range
Dim rindex As Integer
Dim colindex As Integer
Dim i As Integer
Dim nobs As Integer
Set cell1 = Range("O13")
rindex = cell1.Row
colindex = cell1.Column
nobs = Cells(Rows.Count, "O").End(xlUp).Row
Application.DisplayAlerts = False
For i = 1 To (nobs - 13)
Set cell1 = Cells(rindex + (i - 1), colindex)
Set cell2 = Cells(rindex + (i - 1), colindex + 1)
Set cell3 = Cells(rindex + (i - 1), colindex + 3)
SOLVER.SolverReset
SOLVER.SolverOptions MaxTime:=100, Iterations:=1000,_
Precision:=0.000001,Convergence:=0.000001
SOLVER.SolverOk setcell:=cell3.Address, maxminval:=2,_
bychange:=Range(cell1, cell2).Address
SOLVER.SolverSolve userfinish:=True
Next i
End Sub


The break occurs at SOLVER.SolverSolve userfinish:=True. Thanks.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Looping solver for recursive optimization

Thanks for the quick reply. I added SolverFinish KeepFinal:=1 and
removed the additional Solver but I still get the same break.

Graham Whitehead wrote:
Hmm, dont know why you put the extra SOLVER at the beggining - but here is
some code i used for much the same thing and it works fine for me.

'Solve but dont display results
SolverSolve userfinish:=True
'get result
SolverFinish KeepFinal:=1


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Looping solver for recursive optimization

if you can attach an example sheet with some code i can take a look

wrote in message
oups.com...
Thanks for the quick reply. I added SolverFinish KeepFinal:=1 and
removed the additional Solver but I still get the same break.

Graham Whitehead wrote:
Hmm, dont know why you put the extra SOLVER at the beggining - but here
is
some code i used for much the same thing and it works fine for me.

'Solve but dont display results
SolverSolve userfinish:=True
'get result
SolverFinish KeepFinal:=1






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 167
Default Looping solver for recursive optimization

Try restarting your computer when you get that error. It happens to me all
the time after I intentionally break the code.

Your code seems okay to me, and I've done a few routines like this one.

Pflugs

" wrote:

I have an optimization problem that is broken down into a number of
smaller optimization problems given the number of observations on a
variable. On each observation, I would like to have solver change a
range of two cells to minimize the a third cell. This would be looped
over the entire range of data given a starting reference. The problem
I am having though is that at every observation I get a break "Code
Execution Has Been Interrupted". Here is the code I have so far:

Private Sub CommandButton1_Click()
Dim cell1 As Range
Dim cell2 As Range
Dim cell3 As Range
Dim rindex As Integer
Dim colindex As Integer
Dim i As Integer
Dim nobs As Integer
Set cell1 = Range("O13")
rindex = cell1.Row
colindex = cell1.Column
nobs = Cells(Rows.Count, "O").End(xlUp).Row
Application.DisplayAlerts = False
For i = 1 To (nobs - 13)
Set cell1 = Cells(rindex + (i - 1), colindex)
Set cell2 = Cells(rindex + (i - 1), colindex + 1)
Set cell3 = Cells(rindex + (i - 1), colindex + 3)
SOLVER.SolverReset
SOLVER.SolverOptions MaxTime:=100, Iterations:=1000,_
Precision:=0.000001,Convergence:=0.000001
SOLVER.SolverOk setcell:=cell3.Address, maxminval:=2,_
bychange:=Range(cell1, cell2).Address
SOLVER.SolverSolve userfinish:=True
Next i
End Sub


The break occurs at SOLVER.SolverSolve userfinish:=True. Thanks.


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Looping solver for recursive optimization

Thanks guys. I reinstalled Excel and it the code works now. Go
figure...

Pflugs wrote:
Try restarting your computer when you get that error. It happens to me all
the time after I intentionally break the code.

Your code seems okay to me, and I've done a few routines like this one.

Pflugs

" wrote:

I have an optimization problem that is broken down into a number of
smaller optimization problems given the number of observations on a
variable. On each observation, I would like to have solver change a
range of two cells to minimize the a third cell. This would be looped
over the entire range of data given a starting reference. The problem
I am having though is that at every observation I get a break "Code
Execution Has Been Interrupted". Here is the code I have so far:

Private Sub CommandButton1_Click()
Dim cell1 As Range
Dim cell2 As Range
Dim cell3 As Range
Dim rindex As Integer
Dim colindex As Integer
Dim i As Integer
Dim nobs As Integer
Set cell1 = Range("O13")
rindex = cell1.Row
colindex = cell1.Column
nobs = Cells(Rows.Count, "O").End(xlUp).Row
Application.DisplayAlerts = False
For i = 1 To (nobs - 13)
Set cell1 = Cells(rindex + (i - 1), colindex)
Set cell2 = Cells(rindex + (i - 1), colindex + 1)
Set cell3 = Cells(rindex + (i - 1), colindex + 3)
SOLVER.SolverReset
SOLVER.SolverOptions MaxTime:=100, Iterations:=1000,_
Precision:=0.000001,Convergence:=0.000001
SOLVER.SolverOk setcell:=cell3.Address, maxminval:=2,_
bychange:=Range(cell1, cell2).Address
SOLVER.SolverSolve userfinish:=True
Next i
End Sub


The break occurs at SOLVER.SolverSolve userfinish:=True. Thanks.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Seo , Search Engine Optimizer , Seo Search engine Optimization , search engine optimization services, SEO Consulting Se0 Guy Excel Worksheet Functions 0 March 8th 07 04:08 AM
Seo , Search Engine Optimizer , Seo Search engine Optimization , search engine optimization services, SEO Consulting Se0 Guy Excel Discussion (Misc queries) 0 March 8th 07 04:08 AM
Seo , Search Engine Optimizer , Seo Search engine Optimization , search engine optimization services, SEO Consulting Se0 Guy Links and Linking in Excel 0 March 8th 07 04:08 AM
Seo , Search Engine Optimizer , Seo Search engine Optimization , search engine optimization services, SEO Consulting Se0 Guy Charts and Charting in Excel 0 March 8th 07 04:08 AM
Looping a solver Aaron Frick Excel Programming 1 November 10th 03 12:06 AM


All times are GMT +1. The time now is 08:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"