/[ascend]/trunk/base/generic/compiler/rel_blackbox.c
ViewVC logotype

Diff of /trunk/base/generic/compiler/rel_blackbox.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 909 by johnpye, Thu Oct 26 12:44:41 2006 UTC revision 910 by johnpye, Thu Oct 26 13:35:25 2006 UTC
# Line 94  int BlackBoxCalcResidual(struct Instance Line 94  int BlackBoxCalcResidual(struct Instance
94      double inputTolerance;      double inputTolerance;
95      int updateNeeded;      int updateNeeded;
96      int nok = 0;      int nok = 0;
97          static int warnexpt;
98  /* impl setup */  
99      ERROR_REPORTER_HERE(ASC_PROG_WARNING,"Blackbox evaluation is experimental (%s)",__FUNCTION__);      if(!warnexpt){
100            ERROR_REPORTER_HERE(ASC_PROG_WARNING,"Blackbox evaluation is experimental (%s)",__FUNCTION__);
101            warnexpt = 1;
102        }
103    
104      (void)i;      (void)i;
105      efunc = RelationBlackBoxExtFunc(r);      efunc = RelationBlackBoxExtFunc(r);
106      unique = RelationBlackBoxData(r);      unique = RelationBlackBoxData(r);
# Line 191  int BlackBoxCalcGradient(struct Instance Line 195  int BlackBoxCalcGradient(struct Instance
195      int updateNeeded, offset;      int updateNeeded, offset;
196      unsigned int k;      unsigned int k;
197      int nok = 0;      int nok = 0;
198          static int warnexpt;
199      /* prepare */  
200      ERROR_REPORTER_HERE(ASC_PROG_WARNING,"Blackbox gradient is experimental (%s)",__FUNCTION__);      if(!warnexpt){
201            ERROR_REPORTER_HERE(ASC_PROG_WARNING,"Blackbox gradient is experimental (%s)",__FUNCTION__);
202            warnexpt = 1;
203        }
204    
205        /* prepare */
206      (void)i;      (void)i;
207      efunc = RelationBlackBoxExtFunc(r);      efunc = RelationBlackBoxExtFunc(r);
208      unique = RelationBlackBoxData(r);      unique = RelationBlackBoxData(r);
# Line 325  int blackbox_fdiff(ExtBBoxFunc *resfn, s Line 334  int blackbox_fdiff(ExtBBoxFunc *resfn, s
334    double *ptr;    double *ptr;
335    double old_x,deltax,value;    double old_x,deltax,value;
336    
337    CONSOLE_DEBUG("NUMERICAL DERIVATIVE...");    /* CONSOLE_DEBUG("NUMERICAL DERIVATIVE..."); */
338    
339    tmp_outputs = ASC_NEW_ARRAY_CLEAR(double,noutputs);    tmp_outputs = ASC_NEW_ARRAY_CLEAR(double,noutputs);
340    
# Line 334  int blackbox_fdiff(ExtBBoxFunc *resfn, s Line 343  int blackbox_fdiff(ExtBBoxFunc *resfn, s
343      old_x = inputs[c];      old_x = inputs[c];
344      deltax = blackbox_peturbation(old_x);      deltax = blackbox_peturbation(old_x);
345      inputs[c] = old_x + deltax;      inputs[c] = old_x + deltax;
346      CONSOLE_DEBUG("PETURBATED VALUE of input[%ld] = %f",c,inputs[c]);      /* CONSOLE_DEBUG("PETURBATED VALUE of input[%ld] = %f",c,inputs[c]); */
347    
348      /* call routine. note that the 'jac' parameter is just along for the ride */      /* call routine. note that the 'jac' parameter is just along for the ride */
349      nok = (*resfn)(interp, ninputs, noutputs, inputs, tmp_outputs, jac);      nok = (*resfn)(interp, ninputs, noutputs, inputs, tmp_outputs, jac);
# Line 347  int blackbox_fdiff(ExtBBoxFunc *resfn, s Line 356  int blackbox_fdiff(ExtBBoxFunc *resfn, s
356      ptr = &jac[c];      ptr = &jac[c];
357      for(r=0;r<noutputs;r++){      for(r=0;r<noutputs;r++){
358        value = (tmp_outputs[r] - outputs[r]) / deltax;        value = (tmp_outputs[r] - outputs[r]) / deltax;
359        CONSOLE_DEBUG("output[%ld]: value = %f, gradient = %f",r,tmp_outputs[r],value);        /* CONSOLE_DEBUG("output[%ld]: value = %f, gradient = %f",r,tmp_outputs[r],value); */
360        *ptr = value;        *ptr = value;
361        ptr += ninputs;        ptr += ninputs;
362      }      }

Legend:
Removed from v.909  
changed lines
  Added in v.910

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22