- Switched motor to hdb
- Changes to Hipadaba - Added project to histogram memory code - Started regression testing code - Added hill climbing as optimization method to optimise
This commit is contained in:
84
optimise.c
84
optimise.c
@ -519,38 +519,13 @@ static int ClimbDrive(SConnection *pCon,char *name, float value)
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static int ClimbVariable(pOptimise self, SConnection *pCon, int i)
|
||||
{
|
||||
pOVarEntry pOvar;
|
||||
void *pData;
|
||||
int status, direction = 1;
|
||||
long oneCount, twoCount, lastCount, currentCount;
|
||||
float varValue, startValue;
|
||||
char buffer[256];
|
||||
int (*CollectFunc)(pScanData self, int iPoint) = NULL;
|
||||
|
||||
assert(self);
|
||||
assert( (i >= 0) && (i < self->iVar));
|
||||
assert(pCon);
|
||||
|
||||
/* get variable data */
|
||||
DynarGet(self->pVariables,i,&pData);
|
||||
pOvar = (pOVarEntry)pData;
|
||||
startValue = pOvar->fCenter;
|
||||
|
||||
/*
|
||||
* prepare scan object
|
||||
*/
|
||||
self->pScanner->pCon = pCon;
|
||||
self->pScanner->pSics = pServ->pSics;
|
||||
self->pScanner->iNP = 1;
|
||||
self->pScanner->iMode = self->eCount;
|
||||
self->pScanner->fPreset = self->fPreset;
|
||||
|
||||
/*
|
||||
* test for upwards direction
|
||||
*/
|
||||
/*------------------------------------------------------------------------*/
|
||||
static int findDirection(pOptimise self, pOVarEntry pOvar, SConnection *pCon)
|
||||
{
|
||||
int status, direction;
|
||||
float varValue;
|
||||
long oneCount, twoCount;
|
||||
|
||||
varValue = pOvar->fCenter + pOvar->fStep;
|
||||
status = ClimbDrive(pCon,pOvar->pName,varValue);
|
||||
if(!status)
|
||||
@ -584,14 +559,46 @@ static int ClimbDrive(SConnection *pCon,char *name, float value)
|
||||
if(oneCount > twoCount)
|
||||
{
|
||||
direction = 1;
|
||||
lastCount = oneCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
direction = -1;
|
||||
lastCount = twoCount;
|
||||
}
|
||||
|
||||
return direction;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static int ClimbVariable(pOptimise self, SConnection *pCon, int i)
|
||||
{
|
||||
pOVarEntry pOvar;
|
||||
void *pData;
|
||||
int status, direction = 1;
|
||||
long oneCount, twoCount, lastCount, currentCount;
|
||||
float varValue, startValue;
|
||||
char buffer[256];
|
||||
int (*CollectFunc)(pScanData self, int iPoint) = NULL;
|
||||
|
||||
assert(self);
|
||||
assert( (i >= 0) && (i < self->iVar));
|
||||
assert(pCon);
|
||||
|
||||
/* get variable data */
|
||||
DynarGet(self->pVariables,i,&pData);
|
||||
pOvar = (pOVarEntry)pData;
|
||||
startValue = pOvar->fCenter;
|
||||
|
||||
/*
|
||||
* prepare scan object
|
||||
*/
|
||||
self->pScanner->pCon = pCon;
|
||||
self->pScanner->pSics = pServ->pSics;
|
||||
self->pScanner->iNP = 1;
|
||||
self->pScanner->iMode = self->eCount;
|
||||
self->pScanner->fPreset = self->fPreset;
|
||||
|
||||
direction = findDirection(self,pOvar, pCon);
|
||||
if(direction < 0){
|
||||
return direction;
|
||||
}
|
||||
/*
|
||||
* drive to the last best position
|
||||
*/
|
||||
@ -600,7 +607,12 @@ static int ClimbDrive(SConnection *pCon,char *name, float value)
|
||||
if(!status)
|
||||
{
|
||||
return DRIVEERROR;
|
||||
}
|
||||
}
|
||||
lastCount = ClimbCount(self,pCon);
|
||||
if(lastCount < 0)
|
||||
{
|
||||
return SCANERROR;
|
||||
}
|
||||
currentCount = lastCount;
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user