TPCCLIB
Loading...
Searching...
No Matches
optcrit.c File Reference

Optimality Criteria for other libraries. More...

#include "tpcclibConfig.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <string.h>
#include "tpcextensions.h"
#include "tpcmodels.h"

Go to the source code of this file.

Functions

unsigned int optcritNr ()
 
char * optcritCode (optimality_criterion id)
 
char * optcritDesc (optimality_criterion id)
 
optimality_criterion optcritId (const char *s)
 

Detailed Description

Optimality Criteria for other libraries.

Definition in file optcrit.c.

Function Documentation

◆ optcritCode()

char * optcritCode ( optimality_criterion id)

Get string representation of an optimality criterion.

Returns
pointer to string representation of the code, or NULL if not identified.
See also
optcritDesc, optcritId, modelCode
Parameters
idOptimality criterion.

Definition at line 60 of file optcrit.c.

63 {
64 for(unsigned int i=0; i<optcritNr(); i++) if(id==tpc_optcrit[i].id) return(tpc_optcrit[i].code);
65 return((char*)NULL);
66}
unsigned int optcritNr()
Definition optcrit.c:47

◆ optcritDesc()

char * optcritDesc ( optimality_criterion id)

Get description of an optimality criterion.

Returns
pointer to string, or NULL if not identified.
See also
optcritCode, optcritId
Parameters
idOptimality criterion.

Definition at line 74 of file optcrit.c.

77 {
78 for(unsigned int i=0; i<optcritNr(); i++) if(id==tpc_optcrit[i].id) return(tpc_optcrit[i].desc);
79 return((char*)NULL);
80}

◆ optcritId()

optimality_criterion optcritId ( const char * s)

Get the Id for the string representation of optimality criterion code string.

Returns
Enumerated optimality criterion id, OPTCRIT_UNKNOWN, if unknown code.
See also
optcritCode, optcritDesc
Parameters
sOptimality criterion code string; code is case-insensitive, but otherwise exact match is required.

Definition at line 88 of file optcrit.c.

92 {
93 if(s==NULL || *s=='\0') return(OPTCRIT_UNKNOWN);
94 for(unsigned int i=0; i<optcritNr(); i++)
95 if(!strcasecmp(tpc_optcrit[i].code, s)) return(tpc_optcrit[i].id);
96 /* Try also some alternative names */
97 if(!strcasecmp("SS", s)) return(OPTCRIT_OLS);
98 if(!strcasecmp("WSS", s)) return(OPTCRIT_OLS);
99 if(!strcasecmp("SUMSQR", s)) return(OPTCRIT_OLS);
100 if(!strcasecmp("LAE", s)) return(OPTCRIT_LAD);
101 if(!strcasecmp("LAV", s)) return(OPTCRIT_LAD);
102 if(!strcasecmp("LAR", s)) return(OPTCRIT_LAD);
103 if(!strcasecmp("Deming", s)) return(OPTCRIT_ODR);
104 return(OPTCRIT_UNKNOWN);
105}
@ OPTCRIT_OLS
Ordinary Least Squares (sum-of-squares, SS).
Definition tpcmodels.h:68
@ OPTCRIT_LAD
Least Absolute Deviations (sum of absolute deviations, LAE, LAV, LAR).
Definition tpcmodels.h:70
@ OPTCRIT_ODR
Orthogonal Distance Regression (sum of perpendicular distances).
Definition tpcmodels.h:72
@ OPTCRIT_UNKNOWN
Unknown optimality criterion.
Definition tpcmodels.h:67

◆ optcritNr()

unsigned int optcritNr ( )

Number of optimality criteria.

Returns
Nr of criteria.

Definition at line 47 of file optcrit.c.

48{
49 unsigned int i=0;
50 while(tpc_optcrit[i].code[0]!='\0') i++;
51 return(i);
52}

Referenced by optcritCode(), optcritDesc(), and optcritId().