Forum Discussion
FICO
7 years agoCommunity Manager
How to load a MIP solution?
Dear all, Currently, I am trying to provide an initial solution to my IP that has three multidimensional (binary) decision variables (x(N), y(N,M) and z(M)). I know that there are the two functions ...
FICO
7 years agoCommunity Manager
I figured it out, here some pseudo code:
declarations
! sets
N: set of integer
M: set of integer
! decision variables
x: array(N) of mpvar
y: array(N,M) of mpvar
z: array(M) of mpvar
! objective function
obj: linctr
! arrays that contain your start solution
xStrt: array(N) of integer
yStrt: array(N,M) of integer
zStrt: array(M) of integer
! array that allows you to load the start solution into your variables
strtSol: array(mpvar) of real
end-declarations
! ------------ ------------- -----------
! Write your model here....
! ....
! ------------ ------------- -----------
! Load start solution into variables
forall(n in N) do
strtSol(x(n)) := xStrt(n)
end-do
forall(n in N, m in M) do
strtSol(y(n,m)) := yStrt(n,m)
end-do
forall(m in M) do
strtSol(z(m)) := zStrt(m)
end-do
! IMPORTANT! Load problem (compare example "d1wagon2.mos")
loadprob(obj)
! ------------ ------------- -----------
! Load solution into problem
! Version 1: the way the solution was loaded above suggests that you provide
! a complete start solution. Then you can use "loadmipsol"
! loadmipsol returns a status code about the solution, see
! https://www.maths.ed.ac.uk/hall/Xpress/FICO_Docs/mosel/mosel_lang/dhtml/loadmipsol.html
result := loadmipsol("strtSol",strtSol)
! Version 2: you can also provide a part of the solution (e.g. set only x). Then,
! "addmipsol" will try to build a feasible solution out of that.
! To re-inforce the search, one can require Xpress to spend more effort on the
! local search heuristics by " setparam("XPRS_USERSOLHEURISTIC",3)"
addmipsol("strtSol",strtSol)
! Re-inforce use of user solution in local search heuristics
setparam("XPRS_USERSOLHEURISTIC",3)
! Reporting use of user solution (since addmipsol is a procedure, not a function)
setcallback(XPRS_CB_SOLNOTIFY,"solnotify")
! The procedure; taken from example "d1wagon2.mos"
public procedure solnotify(id:string, status:integer)
writeln("Optimiser loaded solution '", id, "' status=", status)
end-procedureRelated Content
Related Content
MIP solution status
Hello, I've been using code like this to get the solution status of a MIP: case getprobstat of XPRS_OPT: status:="Optimum found" XPRS_UNF: status:="Unfinished" XPRS_INF: status:="Infeasib...5 months agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum3 unread comments3 unread6Views0likes3CommentsLoading an MIP solution
I'm having trouple loading an existing MIP solution into XPRESS using C++. The documentation for "load MIP solution" has the following example based on C: XPRBprob expl2;double vals[] = {1.5, 1, 0...14 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum1 unread comment1 unread0Views0likes1Comment