## Bug #110

### set_scalefactor should work with random effects

Status: | In Progress | Start date: | 12/13/2012 | ||
---|---|---|---|---|---|

Priority: | Normal | Due date: | |||

Assignee: | Hans Skaug | % Done: | 50% | ||

Category: | ADMB 11 | ||||

Target version: | ADMB-Trunk |

**Description**

You can use them, but you can't rescale them. set_scalefactor should be

added for df1b2variable types. In the meantime you can't even do it

yourself using

bounded parameters because boundp rescales the input x. Current source is

df1b2variable boundp(const df1b2variable& x, double fmin, double fmax,

const df1b2variable& _fpen)
{

ADUNCONST

df1b2variable t;

double diff=fmax-fmin;

const double l4=log(4.0);

df1b2variable ss=0.49999999999999999*sin(x*1.57079632679489661)+0.50;

t=fmin + diff*ss;

#ifdef USE_BARD_PEN

double pen=.000001/diff;

fpen-=pen*(log(ss+1.e-40)+log((1.0-ss)+1.e-40)+l4);

#else

if (x < -.9999)
{

fpen+=cube(-0.9999-x);

if (x < -1.) {

fpen+=1.e+6*cube(-1.0-x);

if (x < -1.02) {

fpen+=1.e+10*cube(-1.02-x);

}

}

}

if (x > 0.9999)
{

fpen+=cube(x-0.9999);

if (x > 1.) {

fpen+=1.e+6*cube(x-1.);

if (x > 1.02) {

fpen+=1.e+10*cube(x-1.02);

}

}

}

#endif

return(t);

}

at the line

`t=fmin + diff*ss;`

it gets rescaled by diff

To fixe this x should get divided by diff at the beginning as in

df1b2variable boundp(const df1b2variable& usx, double fmin, double fmax,

const df1b2variable& _fpen)
{

ADUNCONST

df1b2variable t;

double diff=fmax-fmin;

df1b2variable x=usx/diff;

const double l4=log(4.0);

df1b2variable ss=0.49999999999999999*sin(x*1.57079632679489661)+0.50;

Of course boundpin needs the same. And it should be done for dvariables

as well.

### History

#### #1 Updated by Hans Skaug almost 3 years ago

**Assignee**set to*Hans Skaug*

#### #3 Updated by Hans Skaug almost 3 years ago

Fixed for scalar objects, vectors and matrices remains.

#### #4 Updated by Hans Skaug almost 3 years ago

**% Done**changed from*0*to*50*

#### #5 Updated by Hans Skaug almost 3 years ago

**Status**changed from*New*to*In Progress*