MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: FindMaximum - f is a MathLink function

  • To: mathgroup at
  • Subject: [mg114195] Re: FindMaximum - f is a MathLink function
  • From: Albert Retey <awnl at>
  • Date: Fri, 26 Nov 2010 05:31:33 -0500 (EST)
  • References: <iclffl$lco$>

Am 25.11.2010 11:57, schrieb Klemen Dovrtel:
> Hello everybody,
> I wrote a custom function that writes the arguments of function into a .txt file, and  than runs some external simulation program, using MathLink, that takes this argument as input. The results of that simulation program are written into a .txt file which is than read back by Mathematica. (print screen: In[387])
> If i run this custom function for arbitrary arguments, everything works fine. (print screen: In[388])
> What i would like to do is to find the maximum of my custom function. So i used the Mathematica FindMaximum algorithm on my custom function (print screen: In[391]). But this doesn't work as i thought it will. It stops right away (after one simulation). And the result is not correct - it seems like it read the results in .txt file before the simulation was finished (the result of simulation is the same as one calculated "manually" in one line above). The FindMaximum also did not start at values set as starting point.
> Any idea what could be wrong?

I think this is a variation of a very frequent question to this group:
you must define the function TRNSYSIzacun in such a way that it only
evaluates with numeric input:

TRNSYSIzacun[m01_?NumericQ,...]:= ...

otherwise it will only be evaluated once by FindMaximum with symbolic
arguments. I wonder why the call with symbolic arguments did work at all
in your case...



  • Prev by Date: Re: Rendering transparent objects changed in M8
  • Next by Date: Re: TextRecognize tabular data
  • Previous by thread: Re: FindMaximum - f is a MathLink function
  • Next by thread: Why ParallelTable does not use CUDA