The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 individual check for parameter updates (NLF) [yes]

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
kfauth Posted - 06/20/2016 : 06:36:25 AM
Origin Ver. and Service Release (Select Help-->About Origin): Pro 2015G (64bit) Sr2
Operating System:Win7Pro

As recommended in the context of fitting with integrations (convolutions), one can use

BOOL bIsNewParamValues = pCtxt->IsNewParamValues();

for checking, whether some parameter has been updated.

I am currently implementing a fit function in OriginC (for the first time, halas) where what is to do after parameter update is a bit demanding.

However, computation load could be reduced, since what exactly is to do does depend on what parameters have been updated.

Previously, when coding fit functions as external DLLs, I was able to do so by introducing global variables to the DLL, which then were "remembered" throughout the many calls to the fitting function. I then had instances of variables which were given the actual parameter values just prior to returning and a comparison with these values was made upon the next call to decide which computations were necessary.

I wonder whether a similar thing can be implemented when coding in OriginC (which I need to do since access to internal objects is required.)

One obvious way of doing so could be to require the presence of a worksheet (or column) which stores the current parameter values and then to do a comparison with those entries. I would, however, prefer some way of doing this within the OriginC code for the fit function. I am not sure whether using static variables could do the trick, though, and am seeking advice, therefore, in this respect.

Many thanks in advance for any help.
1   L A T E S T    R E P L I E S    (Newest First)
kfauth Posted - 06/24/2016 : 01:49:57 AM
In case you're interested, the answer is "yes, in principle".

If your fit function file has code like


void _myFitFunction(
//Fit Parameter(s)
double MyPar_1,/*...*/MyPar_N;
..
..)
   // Beginning of editable part
   NLFitContext *pCtxt = Project.GetNLFitContext();
   if ( pCtxt )
   /*static double initializes to 0.0*/
   static double MyOldPar_1,/*...*/MyOldPar_N; 


   // If parameters were updated, we will recalculate what is required to
   BOOL bIsNewParamValues = pCtxt->IsNewParamValues();
   if ( bIsNewParamValues )
   {
      //check which parameters changed
      BOOL bP_1_ch = MyPar_1 && MyOldPar_1;
      /*[etc]*/
      BOOL bP_N_ch = MyPar_N && MyOldPar_N;

      //calculate only what's required according to bP_n_ch


then I can speed up calculation quite a bit if only the changes induced by the actual parameter change(s) are taken into account.

Of course this requires that at the end of the fit function code we have a sequence of parameter updates:


   } //endif bIsNewParamValues

   y=ReturnValue;
   //update parameter values into static variables
   MyOldPar_1=MyPar_1;
   /* etc. */
   MyOldPar_N=MyPar_N;
}


However, I see a possible issue with this:

Suppose more than one dataset is being fitted with myFitFunction. I would think that then there are several active instances of myFitFunction running. Due to the static statement, all would (have) to work on the same copies of MyOldPar_n (Q: isn't that true?)

No problem with shared parameters. But how about the non-shared ones? Is there a way to remember parameter values for successive calls of myFitFunction for successive calls concerning the same dataset while having them distinct for different datasets?

Any thoughts or help would be appreciated.

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000