本文整理汇总了C#中minasastate类的典型用法代码示例。如果您正苦于以下问题:C# minasastate类的具体用法?C# minasastate怎么用?C# minasastate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
minasastate类属于命名空间,在下文中一共展示了minasastate类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: norm
/*************************************************************************
Returns norm of bounded anti-gradient.
Bounded antigradient is a vector obtained from anti-gradient by zeroing
components which point outwards:
result = norm(v)
v[i]=0 if ((-g[i]<0)and(x[i]=bndl[i])) or
((-g[i]>0)and(x[i]=bndu[i]))
v[i]=-g[i] otherwise
This function may be used to check a stopping criterion.
-- ALGLIB --
Copyright 20.03.2009 by Bochkanov Sergey
*************************************************************************/
private static double asaboundedantigradnorm(minasastate state)
{
double result = 0;
int i = 0;
double v = 0;
result = 0;
for(i=0; i<=state.n-1; i++)
{
v = -state.g[i];
if( (double)(state.x[i])==(double)(state.bndl[i]) && (double)(-state.g[i])<(double)(0) )
{
v = 0;
}
if( (double)(state.x[i])==(double)(state.bndu[i]) && (double)(-state.g[i])>(double)(0) )
{
v = 0;
}
result = result+math.sqr(v);
}
result = Math.Sqrt(result);
return result;
}
开发者ID:orlovk,项目名称:PtProject,代码行数:38,代码来源:optimization.cs
示例2: minasaresultsbuf
/*************************************************************************
Obsolete optimization algorithm.
Was replaced by MinBLEIC subpackage.
-- ALGLIB --
Copyright 20.03.2009 by Bochkanov Sergey
*************************************************************************/
public static void minasaresultsbuf(minasastate state,
ref double[] x,
minasareport rep)
{
int i = 0;
int i_ = 0;
if( alglib.ap.len(x)<state.n )
{
x = new double[state.n];
}
for(i_=0; i_<=state.n-1;i_++)
{
x[i_] = state.x[i_];
}
rep.iterationscount = state.repiterationscount;
rep.nfev = state.repnfev;
rep.terminationtype = state.repterminationtype;
rep.activeconstraints = 0;
for(i=0; i<=state.n-1; i++)
{
if( (double)(state.ak[i])==(double)(0) )
{
rep.activeconstraints = rep.activeconstraints+1;
}
}
}
开发者ID:orlovk,项目名称:PtProject,代码行数:34,代码来源:optimization.cs
示例3: minasarestartfrom
/*************************************************************************
Obsolete optimization algorithm.
Was replaced by MinBLEIC subpackage.
-- ALGLIB --
Copyright 30.07.2010 by Bochkanov Sergey
*************************************************************************/
public static void minasarestartfrom(minasastate state,
double[] x,
double[] bndl,
double[] bndu)
{
int i_ = 0;
alglib.ap.assert(alglib.ap.len(x)>=state.n, "MinASARestartFrom: Length(X)<N!");
alglib.ap.assert(apserv.isfinitevector(x, state.n), "MinASARestartFrom: X contains infinite or NaN values!");
alglib.ap.assert(alglib.ap.len(bndl)>=state.n, "MinASARestartFrom: Length(BndL)<N!");
alglib.ap.assert(apserv.isfinitevector(bndl, state.n), "MinASARestartFrom: BndL contains infinite or NaN values!");
alglib.ap.assert(alglib.ap.len(bndu)>=state.n, "MinASARestartFrom: Length(BndU)<N!");
alglib.ap.assert(apserv.isfinitevector(bndu, state.n), "MinASARestartFrom: BndU contains infinite or NaN values!");
for(i_=0; i_<=state.n-1;i_++)
{
state.x[i_] = x[i_];
}
for(i_=0; i_<=state.n-1;i_++)
{
state.bndl[i_] = bndl[i_];
}
for(i_=0; i_<=state.n-1;i_++)
{
state.bndu[i_] = bndu[i_];
}
state.laststep = 0;
state.rstate.ia = new int[3+1];
state.rstate.ba = new bool[1+1];
state.rstate.ra = new double[2+1];
state.rstate.stage = -1;
clearrequestfields(state);
}
开发者ID:orlovk,项目名称:PtProject,代码行数:39,代码来源:optimization.cs
示例4: minasaiteration
/*************************************************************************
-- ALGLIB --
Copyright 20.03.2009 by Bochkanov Sergey
*************************************************************************/
public static bool minasaiteration(minasastate state)
{
bool result = new bool();
int n = 0;
int i = 0;
double betak = 0;
double v = 0;
double vv = 0;
int mcinfo = 0;
bool b = new bool();
bool stepfound = new bool();
int diffcnt = 0;
int i_ = 0;
//
// Reverse communication preparations
// I know it looks ugly, but it works the same way
// anywhere from C++ to Python.
//
// This code initializes locals by:
// * random values determined during code
// generation - on first subroutine call
// * values from previous call - on subsequent calls
//
if( state.rstate.stage>=0 )
{
n = state.rstate.ia[0];
i = state.rstate.ia[1];
mcinfo = state.rstate.ia[2];
diffcnt = state.rstate.ia[3];
b = state.rstate.ba[0];
stepfound = state.rstate.ba[1];
betak = state.rstate.ra[0];
v = state.rstate.ra[1];
vv = state.rstate.ra[2];
}
else
{
n = -983;
i = -989;
mcinfo = -834;
diffcnt = 900;
b = true;
stepfound = false;
betak = 214;
v = -338;
vv = -686;
}
if( state.rstate.stage==0 )
{
goto lbl_0;
}
if( state.rstate.stage==1 )
{
goto lbl_1;
}
if( state.rstate.stage==2 )
{
goto lbl_2;
}
if( state.rstate.stage==3 )
{
goto lbl_3;
}
if( state.rstate.stage==4 )
{
goto lbl_4;
}
if( state.rstate.stage==5 )
{
goto lbl_5;
}
if( state.rstate.stage==6 )
{
goto lbl_6;
}
if( state.rstate.stage==7 )
{
goto lbl_7;
}
if( state.rstate.stage==8 )
{
goto lbl_8;
}
if( state.rstate.stage==9 )
{
goto lbl_9;
}
if( state.rstate.stage==10 )
{
goto lbl_10;
}
if( state.rstate.stage==11 )
{
//.........这里部分代码省略.........
开发者ID:orlovk,项目名称:PtProject,代码行数:101,代码来源:optimization.cs
示例5: minasaresults
/*************************************************************************
Obsolete optimization algorithm.
Was replaced by MinBLEIC subpackage.
-- ALGLIB --
Copyright 20.03.2009 by Bochkanov Sergey
*************************************************************************/
public static void minasaresults(minasastate state,
ref double[] x,
minasareport rep)
{
x = new double[0];
minasaresultsbuf(state, ref x, rep);
}
开发者ID:orlovk,项目名称:PtProject,代码行数:15,代码来源:optimization.cs
示例6: asauisempty
/*************************************************************************
Returns True, if U set is empty.
* State.X is used as point,
* State.G - as gradient,
* D is calculated within function (because State.D may have different
meaning depending on current optimization algorithm)
For a meaning of U see 'NEW ACTIVE SET ALGORITHM FOR BOX CONSTRAINED
OPTIMIZATION' by WILLIAM W. HAGER AND HONGCHAO ZHANG.
-- ALGLIB --
Copyright 20.03.2009 by Bochkanov Sergey
*************************************************************************/
private static bool asauisempty(minasastate state)
{
bool result = new bool();
int i = 0;
double d = 0;
double d2 = 0;
double d32 = 0;
d = asad1norm(state);
d2 = Math.Sqrt(d);
d32 = d*d2;
result = true;
for(i=0; i<=state.n-1; i++)
{
if( (double)(Math.Abs(state.g[i]))>=(double)(d2) && (double)(Math.Min(state.x[i]-state.bndl[i], state.bndu[i]-state.x[i]))>=(double)(d32) )
{
result = false;
return result;
}
}
return result;
}
开发者ID:orlovk,项目名称:PtProject,代码行数:36,代码来源:optimization.cs
示例7: F
/*************************************************************************
NONLINEAR BOUND CONSTRAINED OPTIMIZATION USING
MODIFIED
WILLIAM W. HAGER AND HONGCHAO ZHANG
ACTIVE SET ALGORITHM
The subroutine minimizes function F(x) of N arguments with bound
constraints: BndL[i] <= x[i] <= BndU[i]
This method is globally convergent as long as grad(f) is Lipschitz
continuous on a level set: L = { x : f(x)<=f(x0) }.
INPUT PARAMETERS:
N - problem dimension. N>0
X - initial solution approximation, array[0..N-1].
BndL - lower bounds, array[0..N-1].
all elements MUST be specified, i.e. all variables are
bounded. However, if some (all) variables are unbounded,
you may specify very small number as bound: -1000, -1.0E6
or -1.0E300, or something like that.
BndU - upper bounds, array[0..N-1].
all elements MUST be specified, i.e. all variables are
bounded. However, if some (all) variables are unbounded,
you may specify very large number as bound: +1000, +1.0E6
or +1.0E300, or something like that.
EpsG - positive number which defines a precision of search. The
subroutine finishes its work if the condition ||G|| < EpsG is
satisfied, where ||.|| means Euclidian norm, G - gradient, X -
current approximation.
EpsF - positive number which defines a precision of search. The
subroutine finishes its work if on iteration number k+1 the
condition |F(k+1)-F(k)| <= EpsF*max{|F(k)|, |F(k+1)|, 1} is
satisfied.
EpsX - positive number which defines a precision of search. The
subroutine finishes its work if on iteration number k+1 the
condition |X(k+1)-X(k)| <= EpsX is fulfilled.
MaxIts - maximum number of iterations. If MaxIts=0, the number of
iterations is unlimited.
OUTPUT PARAMETERS:
State - structure used for reverse communication.
This function initializes State structure with default optimization
parameters (stopping conditions, step size, etc.). Use MinASASet??????()
functions to tune optimization parameters.
After all optimization parameters are tuned, you should use
MinASAIteration() function to advance algorithm iterations.
NOTES:
1. you may tune stopping conditions with MinASASetCond() function
2. if target function contains exp() or other fast growing functions, and
optimization algorithm makes too large steps which leads to overflow,
use MinASASetStpMax() function to bound algorithm's steps.
-- ALGLIB --
Copyright 25.03.2010 by Bochkanov Sergey
*************************************************************************/
public static void minasacreate(int n,
ref double[] x,
ref double[] bndl,
ref double[] bndu,
ref minasastate state)
{
int i = 0;
int i_ = 0;
System.Diagnostics.Debug.Assert(n>=1, "MinASA: N too small!");
for(i=0; i<=n-1; i++)
{
System.Diagnostics.Debug.Assert((double)(bndl[i])<=(double)(bndu[i]), "MinASA: inconsistent bounds!");
System.Diagnostics.Debug.Assert((double)(bndl[i])<=(double)(x[i]), "MinASA: infeasible X!");
System.Diagnostics.Debug.Assert((double)(x[i])<=(double)(bndu[i]), "MinASA: infeasible X!");
}
//
// Initialize
//
state.n = n;
minasasetcond(ref state, 0, 0, 0, 0);
minasasetxrep(ref state, false);
minasasetstpmax(ref state, 0);
minasasetalgorithm(ref state, -1);
state.bndl = new double[n];
state.bndu = new double[n];
state.ak = new double[n];
state.xk = new double[n];
state.dk = new double[n];
state.an = new double[n];
state.xn = new double[n];
state.dn = new double[n];
state.x = new double[n];
state.d = new double[n];
state.g = new double[n];
state.gc = new double[n];
state.work = new double[n];
state.yk = new double[n];
for(i_=0; i_<=n-1;i_++)
{
//.........这里部分代码省略.........
开发者ID:palefacer,项目名称:TelescopeOrientation,代码行数:101,代码来源:minasa.cs
示例8: minasasetcond
/*************************************************************************
Obsolete optimization algorithm.
Was replaced by MinBLEIC subpackage.
-- ALGLIB --
Copyright 02.04.2010 by Bochkanov Sergey
*************************************************************************/
public static void minasasetcond(minasastate state,
double epsg,
double epsf,
double epsx,
int maxits)
{
alglib.ap.assert(math.isfinite(epsg), "MinASASetCond: EpsG is not finite number!");
alglib.ap.assert((double)(epsg)>=(double)(0), "MinASASetCond: negative EpsG!");
alglib.ap.assert(math.isfinite(epsf), "MinASASetCond: EpsF is not finite number!");
alglib.ap.assert((double)(epsf)>=(double)(0), "MinASASetCond: negative EpsF!");
alglib.ap.assert(math.isfinite(epsx), "MinASASetCond: EpsX is not finite number!");
alglib.ap.assert((double)(epsx)>=(double)(0), "MinASASetCond: negative EpsX!");
alglib.ap.assert(maxits>=0, "MinASASetCond: negative MaxIts!");
if( (((double)(epsg)==(double)(0) && (double)(epsf)==(double)(0)) && (double)(epsx)==(double)(0)) && maxits==0 )
{
epsx = 1.0E-6;
}
state.epsg = epsg;
state.epsf = epsf;
state.epsx = epsx;
state.maxits = maxits;
}
开发者ID:orlovk,项目名称:PtProject,代码行数:29,代码来源:optimization.cs
示例9: minasasetxrep
/*************************************************************************
Obsolete optimization algorithm.
Was replaced by MinBLEIC subpackage.
-- ALGLIB --
Copyright 02.04.2010 by Bochkanov Sergey
*************************************************************************/
public static void minasasetxrep(minasastate state,
bool needxrep)
{
state.xrep = needxrep;
}
开发者ID:orlovk,项目名称:PtProject,代码行数:12,代码来源:optimization.cs
示例10: make_copy
public override alglib.apobject make_copy()
{
minasastate _result = new minasastate();
_result.n = n;
_result.epsg = epsg;
_result.epsf = epsf;
_result.epsx = epsx;
_result.maxits = maxits;
_result.xrep = xrep;
_result.stpmax = stpmax;
_result.cgtype = cgtype;
_result.k = k;
_result.nfev = nfev;
_result.mcstage = mcstage;
_result.bndl = (double[])bndl.Clone();
_result.bndu = (double[])bndu.Clone();
_result.curalgo = curalgo;
_result.acount = acount;
_result.mu = mu;
_result.finit = finit;
_result.dginit = dginit;
_result.ak = (double[])ak.Clone();
_result.xk = (double[])xk.Clone();
_result.dk = (double[])dk.Clone();
_result.an = (double[])an.Clone();
_result.xn = (double[])xn.Clone();
_result.dn = (double[])dn.Clone();
_result.d = (double[])d.Clone();
_result.fold = fold;
_result.stp = stp;
_result.work = (double[])work.Clone();
_result.yk = (double[])yk.Clone();
_result.gc = (double[])gc.Clone();
_result.laststep = laststep;
_result.x = (double[])x.Clone();
_result.f = f;
_result.g = (double[])g.Clone();
_result.needfg = needfg;
_result.xupdated = xupdated;
_result.rstate = (rcommstate)rstate.make_copy();
_result.repiterationscount = repiterationscount;
_result.repnfev = repnfev;
_result.repterminationtype = repterminationtype;
_result.debugrestartscount = debugrestartscount;
_result.lstate = (linmin.linminstate)lstate.make_copy();
_result.betahs = betahs;
_result.betady = betady;
return _result;
}
开发者ID:orlovk,项目名称:PtProject,代码行数:49,代码来源:optimization.cs
示例11: minasacreate
/*************************************************************************
Obsolete optimization algorithm.
Was replaced by MinBLEIC subpackage.
-- ALGLIB --
Copyright 25.03.2010 by Bochkanov Sergey
*************************************************************************/
public static void minasacreate(int n,
double[] x,
double[] bndl,
double[] bndu,
minasastate state)
{
int i = 0;
alglib.ap.assert(n>=1, "MinASA: N too small!");
alglib.ap.assert(alglib.ap.len(x)>=n, "MinCGCreate: Length(X)<N!");
alglib.ap.assert(apserv.isfinitevector(x, n), "MinCGCreate: X contains infinite or NaN values!");
alglib.ap.assert(alglib.ap.len(bndl)>=n, "MinCGCreate: Length(BndL)<N!");
alglib.ap.assert(apserv.isfinitevector(bndl, n), "MinCGCreate: BndL contains infinite or NaN values!");
alglib.ap.assert(alglib.ap.len(bndu)>=n, "MinCGCreate: Length(BndU)<N!");
alglib.ap.assert(apserv.isfinitevector(bndu, n), "MinCGCreate: BndU contains infinite or NaN values!");
for(i=0; i<=n-1; i++)
{
alglib.ap.assert((double)(bndl[i])<=(double)(bndu[i]), "MinASA: inconsistent bounds!");
alglib.ap.assert((double)(bndl[i])<=(double)(x[i]), "MinASA: infeasible X!");
alglib.ap.assert((double)(x[i])<=(double)(bndu[i]), "MinASA: infeasible X!");
}
//
// Initialize
//
state.n = n;
minasasetcond(state, 0, 0, 0, 0);
minasasetxrep(state, false);
minasasetstpmax(state, 0);
minasasetalgorithm(state, -1);
state.bndl = new double[n];
state.bndu = new double[n];
state.ak = new double[n];
state.xk = new double[n];
state.dk = new double[n];
state.an = new double[n];
state.xn = new double[n];
state.dn = new double[n];
state.x = new double[n];
state.d = new double[n];
state.g = new double[n];
state.gc = new double[n];
state.work = new double[n];
state.yk = new double[n];
minasarestartfrom(state, x, bndl, bndu);
}
开发者ID:orlovk,项目名称:PtProject,代码行数:53,代码来源:optimization.cs
示例12: MinCGCreate
/*************************************************************************
This function sets maximum step length
INPUT PARAMETERS:
State - structure which stores algorithm state between calls and
which is used for reverse communication. Must be
initialized with MinCGCreate()
StpMax - maximum step length, >=0. Set StpMax to 0.0, if you don't
want to limit step length.
Use this subroutine when you optimize target function which contains exp()
or other fast growing functions, and optimization algorithm makes too
large steps which leads to overflow. This function allows us to reject
steps that are too large (and therefore expose us to the possible
overflow) without actually calculating function value at the x+stp*d.
-- ALGLIB --
Copyright 02.04.2010 by Bochkanov Sergey
*************************************************************************/
public static void minasasetstpmax(ref minasastate state,
double stpmax)
{
System.Diagnostics.Debug.Assert((double)(stpmax)>=(double)(0), "MinASASetStpMax: StpMax<0!");
state.stpmax = stpmax;
}
开发者ID:palefacer,项目名称:TelescopeOrientation,代码行数:25,代码来源:minasa.cs
示例13: MinASACreate
/*************************************************************************
This function sets optimization algorithm.
INPUT PARAMETERS:
State - structure which stores algorithm state between calls and
which is used for reverse communication. Must be
initialized with MinASACreate()
UAType - algorithm type:
* -1 automatic selection of the best algorithm
* 0 DY (Dai and Yuan) algorithm
* 1 Hybrid DY-HS algorithm
-- ALGLIB --
Copyright 02.04.2010 by Bochkanov Sergey
*************************************************************************/
public static void minasasetalgorithm(ref minasastate state,
int algotype)
{
System.Diagnostics.Debug.Assert(algotype>=-1 & algotype<=1, "MinASASetAlgorithm: incorrect AlgoType!");
if( algotype==-1 )
{
algotype = 1;
}
state.cgtype = algotype;
}
开发者ID:palefacer,项目名称:TelescopeOrientation,代码行数:25,代码来源:minasa.cs
示例14: GI
/*************************************************************************
Returns norm of GI(x).
GI(x) is a gradient vector whose components associated with active
constraints are zeroed. It differs from bounded anti-gradient because
components of GI(x) are zeroed independently of sign(g[i]), and
anti-gradient's components are zeroed with respect to both constraint and
sign.
-- ALGLIB --
Copyright 20.03.2009 by Bochkanov Sergey
*************************************************************************/
private static double asaginorm(minasastate state)
{
double result = 0;
int i = 0;
result = 0;
for(i=0; i<=state.n-1; i++)
{
if( (double)(state.x[i])!=(double)(state.bndl[i]) && (double)(state.x[i])!=(double)(state.bndu[i]) )
{
result = result+math.sqr(state.g[i]);
}
}
result = Math.Sqrt(result);
return result;
}
开发者ID:orlovk,项目名称:PtProject,代码行数:28,代码来源:optimization.cs
示例15: minasasetalgorithm
/*************************************************************************
Obsolete optimization algorithm.
Was replaced by MinBLEIC subpackage.
-- ALGLIB --
Copyright 02.04.2010 by Bochkanov Sergey
*************************************************************************/
public static void minasasetalgorithm(minasastate state,
int algotype)
{
alglib.ap.assert(algotype>=-1 && algotype<=1, "MinASASetAlgorithm: incorrect AlgoType!");
if( algotype==-1 )
{
algotype = 1;
}
state.cgtype = algotype;
}
开发者ID:orlovk,项目名称:PtProject,代码行数:17,代码来源:optimization.cs
示例16: minasasetstpmax
/*************************************************************************
Obsolete optimization algorithm.
Was replaced by MinBLEIC subpackage.
-- ALGLIB --
Copyright 02.04.2010 by Bochkanov Sergey
*************************************************************************/
public static void minasasetstpmax(minasastate state,
double stpmax)
{
alglib.ap.assert(math.isfinite(stpmax), "MinASASetStpMax: StpMax is not finite!");
alglib.ap.assert((double)(stpmax)>=(double)(0), "MinASASetStpMax: StpMax<0!");
state.stpmax = stpmax;
}
开发者ID:orlovk,项目名称:PtProject,代码行数:14,代码来源:optimization.cs
示例17: fileds
/*************************************************************************
Clears request fileds (to be sure that we don't forgot to clear something)
*************************************************************************/
private static void clearrequestfields(minasastate state)
{
state.needfg = false;
state.xupdated = false;
}
开发者ID:orlovk,项目名称:PtProject,代码行数:8,代码来源:optimization.cs
示例18: asawanttounstick
/*************************************************************************
Returns True, if optimizer "want to unstick" from one of the active
constraints, i.e. there is such active constraint with index I that either
lower bound is active and g[i]<0, or upper bound is active and g[i]>0.
State.X is used as current point, State.X - as gradient.
-- ALGLIB --
Copyright 20.03.2009 by Bochkanov Sergey
*************************************************************************/
private static bool asawanttounstick(ref minasastate state)
{
bool result = new bool();
int i = 0;
result = false;
for(i=0; i<=state.n-1; i++)
{
if( (double)(state.x[i])==(double)(state.bndl[i]) & (double)(state.g[i])<(double)(0) )
{
result = true;
}
if( (double)(state.x[i])==(double)(state.bndu[i]) & (double)(state.g[i])>(double)(0) )
{
result = true;
}
if( result )
{
return result;
}
}
return result;
}
开发者ID:palefacer,项目名称:TelescopeOrientation,代码行数:32,代码来源:minasa.cs
注:本文中的minasastate类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论