I have been trying to setup a nonlinear constraint for a genetic algorithm in SAS 9.2 for some time now.
The constraint is as follows;
(-0.3) <= mort(x,.,x/12,x) / mort(coeff,.,coeff/12,coeff) <= -0.1
Now, the nonlinear optimization calls like "nlpqn" let me specify nonlinear constraints with the "nlc" module. Do we have something similar for genetic algorithms?
Message was edited by: Rakesh
Message was edited by: Rakesh
In general, with GA there are several different strategies for satisfying non-linear constraints. Probably the simplest way within IML for this particular problem is to simply "fix up" any solution that does not satisfy the non-linear constraint so that it does match the constraint. In this case, by the nature of the mort() function, the constraint violation function is linear in the first component x ( the initial mortgage amount). That makes it easy to adjust your solution to reside on the nearest constraint boundary by modifying x and leaving the other components unchanged. You can do that in the objective function with something like:
start objective(x) global( coeff );
/* assumes desired soution vector is in x, coeff is constant matrix */
/* First, get the lower (lb) and upper (ub) bounds of the quantity
The problem I have is that I need to be able to vary all three parts of the mort() function to achieve this. So, whereas the function is linear in initial balance , it is not in the Interest Rate (x) and the Amortization Term (x). How do I change all three together, how do I distribute the bounds as weighting parameters amongst the three 'variables'?
Do let me know if you have a solution. Your earlier answer did open a few door for me!
Using this strategy you can still vary all three parameters. I assume you can assign reasonable upper and lower bounds for each variable, and then generate a uniform distribution of solutions across those bounds. This fixup strategy then maps in a certian way the solutions that fall outside the constraint to the constraint boundary.
What is your actual objective function for this problem? Depending on your objective, you might also be able to transform variables to produce easier constraints.
/*Fixup Variables - NOT BEING USED CURRENTLY*//*
do while (lb>NewPIPmt);
do while (NewPIPmt > ub);
I don't have complete knowledge of your model, but could you use the ratio:
as one of your input parameters, instead of what you now have as x? Since your x only appears in the computation of of NewUPB, which would be computed directly from the mort() function, it would then go away and you could use x for the new payment ratio parameter. Mathematically you could then just specify the correct bounds on that ratio directly and eliminate the non-linear constraint. Your objective might look something like this:
/* objective function, has minimum of 0 at x = xopt */
start redefault(x) global(coeff);
/* let x = NewPIPmt/OldPIPmt */
NewPIPmt = x * OldPIPmt;
/* solve for new principal */
NewUPB = mort( ., NewPIPmt, x/12,x-coeff);
CurrLTV = NewUPB/coeff;
LTVBasedOnOrigMV = NewUPB/coeff;