~ubuntu-branches/ubuntu/maverick/yagiuda/maverick

« back to all changes in this revision

Viewing changes to src/dobetter.c

  • Committer: Bazaar Package Importer
  • Author(s): Joop Stakenborg
  • Date: 2005-08-22 20:20:13 UTC
  • Revision ID: james.westby@ubuntu.com-20050822202013-mhhxp4xirdxrdfx1
Tags: upstream-1.19
ImportĀ upstreamĀ versionĀ 1.19

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifdef HAVE_STDLIB_H
 
2
#include <stdlib.h>
 
3
#endif
 
4
#include <stdio.h>
 
5
#include <errno.h>
 
6
#include "yagi.h"
 
7
 
 
8
/* This routine prints the data to disk and to stdout, since the new result
 
9
is better than all previous */
 
10
 
 
11
void do_since_better(int i, char *output_filename, char *update_filename, struct FCOMPLEX input_impedance, struct performance_data n,struct flags flag,char * notes,double frequency,double min_frequency,double max_frequency,double  step_frequency,int elements, int driven,int parasitic,double angular_step,double **driven_data,double **parasitic_data,double scale_factor,double new_perf)
 
12
{
 
13
                        static int run_first_time=TRUE;
 
14
 
 
15
                        FILE *fp_out, *update_fp;
 
16
                        int print_fitnessQ;
 
17
                        n.r=input_impedance.r; n.x=input_impedance.i;
 
18
                        if(flag.Wflg || flag.gflg)
 
19
                                print_fitnessQ=TRUE;
 
20
                        else
 
21
                                print_fitnessQ=FALSE;
 
22
                        print_relavent_performance_data(stdout,"",i,flag,n,new_perf,TRUE,print_fitnessQ); 
 
23
                        update_fp=fopen(update_filename,"a");
 
24
                        if(run_first_time==TRUE && flag.wflg)
 
25
                                fprintf(update_fp, "Optimised for wide-band use\n");
 
26
                        if(run_first_time==TRUE && flag.gflg)
 
27
                                fprintf(update_fp, "Optimised With the genetic algoritm\n");
 
28
                        run_first_time=FALSE;
 
29
 
 
30
                        print_relavent_performance_data(update_fp,"",i,flag,n,new_perf,TRUE,print_fitnessQ); 
 
31
                        fclose(update_fp);
 
32
                        /* write our best design to date to disk */
 
33
                        
 
34
                        fp_out=fopen(output_filename,"wt");
 
35
                        write_input_data_to_disk(fp_out, notes, frequency/1e6,                          min_frequency/1e6,max_frequency/1e6, step_frequency/1e6, elements,              driven, parasitic, angular_step,driven_data, parasitic_data,                    scale_factor); 
 
36
                        fclose(fp_out);
 
37
 
 
38
#ifdef DEBUG
 
39
        if(errno)
 
40
        {
 
41
                fprintf(stderr,"Errno =%d in dobetter.c\n", errno);
 
42
                exit(1);
 
43
        }
 
44
#endif
 
45
}