Esempio n. 1
0
/*
 *  s w a p I n d e x
 */
returnValue SubjectTo::swapIndex(   Indexlist* const indexlist,
                                    int_t number1, int_t number2
                                    )
{
    /* consistency checks */
    if ( status != 0 )
    {
        if ( status[number1] != status[number2] )
            return THROWERROR( RET_SWAPINDEX_FAILED );
    }
    else
        return THROWERROR( RET_SWAPINDEX_FAILED );

    if ( number1 == number2 )
    {
        THROWWARNING( RET_NOTHING_TO_DO );
        return SUCCESSFUL_RETURN;
    }

    if ( indexlist != 0 )
    {
        if ( indexlist->swapNumbers( number1,number2 ) != SUCCESSFUL_RETURN )
            return THROWERROR( RET_SWAPINDEX_FAILED );
    }
    else
        return THROWERROR( RET_INVALID_ARGUMENTS );

    return SUCCESSFUL_RETURN;
}
Esempio n. 2
0
/*
 *	a d d N u m b e r
 */
returnValue Indexlist::addNumber( int addnumber )
{
	int i;

	if ( lastusedindex+1 < physicallength )
	{
		/* If there is enough storage, add number to indexlist. */
		++lastusedindex;
		number[lastusedindex] = addnumber;
		next[lastusedindex] = 0;

		if ( length == 0 )
		{
			first = lastusedindex;
			previous[lastusedindex] = 0;
		}
		else
		{
			next[last] = lastusedindex;
			previous[lastusedindex] = last;
		}

		last = lastusedindex;
		++length;

		return SUCCESSFUL_RETURN;
	}
	else
	{
		/* Rearrangement of index list necessary! */
		if ( length >= physicallength )
			return THROWERROR( RET_INDEXLIST_EXCEEDS_MAX_LENGTH );
		else
		{
			int* numberArray = new int[length];
			getNumberArray( numberArray );

			/* copy existing elements */
			for ( i=0; i<length; ++i )
			{
				number[i] = numberArray[i];
				next[i] = i+1;
				previous[i] = i-1;
			}

			/* add new number at end of list */
			number[length] = addnumber;
			next[length] = -1;
			previous[length] = length-1;

			/* and set remaining entries to empty */
			for ( i=length+1; i<physicallength; ++i )
			{
				number[i] = -1;
				next[i] = -1;
				previous[i] = -1;
			}

			first = 0;
			last = length;
			lastusedindex = length;
			++length;

			delete[] numberArray;

			return THROWWARNING( RET_INDEXLIST_MUST_BE_REORDERD );
		}
	}
}
Esempio n. 3
0
/*
 *	e n s u r e C o n s i s t e n c y
 */
returnValue Options::ensureConsistency( )
{
	BooleanType needToAdjust = BT_FALSE;

	/* flipping bounds require far bounds */
    /* (ckirches) Removed this as per filter's trust region
	if( enableFlippingBounds == BT_TRUE )
		enableFarBounds = BT_TRUE;
    */
	
	if( enableDriftCorrection < 0 )
	{
		enableDriftCorrection = 0;
		needToAdjust = BT_TRUE;
	}
	
	if( enableCholeskyRefactorisation < 0 )
	{
		enableCholeskyRefactorisation = 0;
		needToAdjust = BT_TRUE;
	}

	if ( terminationTolerance <= 0.0 )
	{
		terminationTolerance = EPS;
		needToAdjust = BT_TRUE;
	}

	if ( epsIterRef <= 0.0 )
	{
		epsIterRef = EPS;
		needToAdjust = BT_TRUE;
	}

	if ( epsRegularisation <= 0.0 )
	{
		epsRegularisation = EPS;
		needToAdjust = BT_TRUE;
	}

	if ( boundTolerance <= 0.0 )
	{
		boundTolerance = EPS;
		needToAdjust = BT_TRUE;
	}

	if ( boundRelaxation <= 0.0 )
	{
		boundRelaxation = EPS;
		needToAdjust = BT_TRUE;
	}
	
	if ( maxPrimalJump <= 0.0 )
	{
		maxPrimalJump = EPS;
		needToAdjust = BT_TRUE;
	}

	if ( maxDualJump <= 0.0 )
	{
		maxDualJump = EPS;
		needToAdjust = BT_TRUE;
	}


	if ( initialRamping < 0.0 )
	{
		initialRamping = 0.0;
		needToAdjust = BT_TRUE;
	}

	if ( finalRamping < 0.0 )
	{
		finalRamping = 0.0;
		needToAdjust = BT_TRUE;
	}

	if ( initialFarBounds <= boundRelaxation )
	{
		initialFarBounds = boundRelaxation+EPS;
		needToAdjust = BT_TRUE;
	}
	
	if ( growFarBounds < 1.1 )
	{
		growFarBounds = 1.1;
		needToAdjust = BT_TRUE;
	}

	if ( epsFlipping <= 0.0 )
	{
		epsFlipping = EPS;
		needToAdjust = BT_TRUE;
	}

	if ( numRegularisationSteps < 0 )
	{
		numRegularisationSteps = 0;
		needToAdjust = BT_TRUE;
	}

	if ( epsRegularisation < 0.0 )
	{
		epsRegularisation = EPS;
		needToAdjust = BT_TRUE;
	}

	if ( numRefinementSteps < 0 )
	{
		numRefinementSteps = 0;
		needToAdjust = BT_TRUE;
	}

	if ( epsIterRef < 0.0 )
	{
		epsIterRef = EPS;
		needToAdjust = BT_TRUE;
	}

	if ( epsLITests < 0.0 )
	{
		epsLITests = EPS;
		needToAdjust = BT_TRUE;
	}

	if ( epsNZCTests < 0.0 )
	{
		epsNZCTests = EPS;
		needToAdjust = BT_TRUE;
	}

	if ( needToAdjust == BT_TRUE)
		return THROWWARNING( RET_OPTIONS_ADJUSTED );

	return SUCCESSFUL_RETURN;
}