Wiki Link: [discussion:2229]
Not using OML & Co 

Sep 3 2009 at 5:21 PM
Hi,

this might be a stupid question, but what the heck. Is it possible to use Solver Foundation with a model that is not formulated in the solver foundation way (i.e. either OML or created via the object model). In particular, lets assume I just have an arbitrary .Net function that takes a number of parameters and returns a value, could I pass that function to Solver Foundation and tell it to optimise it?

In that case Solver Foundation of course could not analyse the structure of the model at all, i.e. it would no any of the mathematical structure of the model, all it would have is a "black box".

I'm mainly interested in this in the realm of legacy code. If I have a fairly large model coded in some language, if I could wrap calls to that in a .Net function, could I then use Solver Foundation to opimise something in that model without recoding all equations?

Thanks,
David

Sep 3 2009 at 8:33 PM
There is a nonlinear unconstrained solver in MSF you may be able to use. You need to provide gradients however. If you don't have these you could try to approximate the derivatives by finite differences (but that may lead to problems). Otherwise you can look into using a derivative free optimization method (not included in the current version of MSF). These methods are usually only feasible if the number of "parameters" to optimize is small.

----------------------------------------------------------------
Erwin Kalvelagen
Amsterdam Optimization Modeling Group
erwin.kalvelagen@gmail.com
http://amsterdamoptimization.com
----------------------------------------------------------------

Coordinator
Sep 4 2009 at 3:57 AM
Erwin is spot on - if you use the unconstrained solver then you can provide "arbitrary" methods for the objective and gradient. In the Samples directory in the Solver Foundation install, under SolverExamples\Nonlinear there is a very simple example. In your case you'd make the _value and _gradient methods be wrappers to your legacy code.

I do plan on doing a blog post that kicks the tires a bit more - when it's up I will post the link here.

Nathan

Oct 3 2009 at 9:40 AM
Thanks guys, I'll have a look into these and will report back if I get it to work.

@Erwin: Any rough idea what small number of parameters means? 10, 100, 1000?

Cheers,
David

PS: It seems the email notification doesn't work for this forum, I had set it to let me know when ansers come in but it didn't alert me to either of your answers, otherwise I would have responded earlier.

Oct 4 2009 at 3:04 PM
The size of a problem that can be solved with a DFO (Derivative Free Optimization) method is largely problem dependent. But if you put a gun to my head, in general terms I would guess that n=100 variables is a reasonable threshold: for larger problems one would not consider DFO to be viable. On the other hand, if you have derivatives, then problems with with 1e6 variables can and have been been solved using standard general sparse NLP solvers.

----------------------------------------------------------------
Erwin Kalvelagen
Amsterdam Optimization Modeling Group
erwin@amsterdamoptimization.com
http://amsterdamoptimization.com
----------------------------------------------------------------

Oct 5 2009 at 2:39 PM
@erwin: Thanks!

Cheers,
David

Coordinator
Oct 15 2009 at 10:55 PM

You've probably long since worked through any issues, but I did post a slightly more involved example here:
http://blogs.msdn.com/natbr/archive/2009/10/15/using-solver-foundation-s-unconstrained-nonlinear-solver.aspx
Nathan


davidacoder wrote:
@erwin: Thanks!

Cheers,
David



Updating...
Page view tracker