Initializing help system before first use

Local solutions


Type: Programming
Rating: 2 (easy-medium)
Description: Nonlinear example demonstrating the presence of locally optimal solutions, and the role of initial points
File(s): xnlp_local_optima.mos


xnlp_local_optima.mos
! XNLP example demonstrating the presence of locally optimal solutions, and the 
! role of initial points
!
! This example performs a series of solves for the exact same problem having 
! several local optimas
!
! This example demonstrates a particular non-linear optimization concept as related 
! to Xpress NonLinear.
! The version of the example is for Xpress 7.5.
!
!  (c) 2013 Fair Isaac Corporation
!       author: Zsolt Csizmadia
model mmxnlp_nlp_duals
uses "mmxnlp"; 

declarations
 x,y: mpvar
end-declarations

!setparam("xnlp_verbose",1)

! A function with several local valleys
x^2*sin(x) >= y

! Observe the regions of attractions
writeln("Locally optimal solutions found:")	
writeln("------------------------------------------")
writeln("        x            y         objective  ")
writeln("------------------------------------------")
forall (i in -5..40) do
	setinitval(x,i)
	setinitval(y,i)
	minimize(x+y)
	if (getparam("xnlp_nlpstatus") = XNLP_STATUS_LOCALLY_OPTIMAL) then
		writeln(strfmt(getsol(x),13),",",strfmt(getsol(y),13),": ",
		        strfmt(getobjval,13))
    else
		writeln("Status is not locally optimal")	
	end-if
end-do

end-model