@@ -77,12 +77,12 @@ function Base.copy(m::GLPKMathProgModelMIP)
7777
7878 m2. param = deepcopy (m. param)
7979 m2. smplxparam = deepcopy (m. smplxparam)
80-
80+
8181 m. lazycb == nothing || Base. warn_once (" Callbacks can't be copied, lazy callback ignored" )
8282 m. cutcb == nothing || Base. warn_once (" Callbacks can't be copied, cut callback ignored" )
8383 m. heuristiccb == nothing || Base. warn_once (" Callbacks can't be copied, heuristic callback ignored" )
8484 m. infocb == nothing || Base. warn_once (" Callbacks can't be copied, info callback ignored" )
85-
85+
8686 m2. objbound = m. objbound
8787
8888 m. cbdata == nothing || Base. warn_once (" Callbacks can't be copied, callbackdata ignored" )
@@ -539,7 +539,15 @@ function status(lpm::GLPKMathProgModelMIP)
539539 end
540540end
541541
542- getobjval (lpm:: GLPKMathProgModelMIP ) = GLPK. mip_obj_val (lpm. inner)
542+ function getobjval (lpm:: GLPKMathProgModelMIP )
543+ status = GLPK. mip_status (lpm. inner)
544+ if status == GLPK. UNDEF || status == GLPK. NOFEAS
545+ # no feasible solution so objective is NaN
546+ return NaN
547+ end
548+
549+ return GLPK. mip_obj_val (lpm. inner)
550+ end
543551
544552function getobjbound (lpm:: GLPKMathProgModelMIP )
545553 # This is a hack. We observed some cases where mip_status == OPT
556564function getsolution (lpm:: GLPKMathProgModelMIP )
557565 lp = lpm. inner
558566 n = GLPK. get_num_cols (lp)
567+ status = GLPK. mip_status (lpm. inner)
568+ if status == GLPK. UNDEF || status == GLPK. NOFEAS
569+ # no feasible solution to return
570+ return fill (NaN , n)
571+ end
559572
560573 x = Array {Float64} (n)
561574 for c = 1 : n
0 commit comments