Skip to content

Conversation

@carlobaldassi
Copy link
Member

@IainNZ this is an alternative take on the new heuristic callback implementation, but I did not test it, can you do it?

The way this works is by keeping a solution vector, and signalling via NaNs which values are not initialized. This may an abuse of the meaning of NaN, but I thought it is safe. Another possibility is adding a bitmask (DataFrames style).

Note: the way it works now tries to mimic what you submitted in #8, in that after the solution is fed to the GLPK solver, it is "forgotten", i.e. one needs to call cbsetsolutionvalue! every time before using cbaddsolution!.

@IainNZ
Copy link
Member

IainNZ commented Feb 20, 2014

Much better @carlobaldassi , I like this design a lot. I think the use of NaN is totally safe in this context, theres no reason you'd want to set values to NaN.

I'm not sure if you saw my JuMP manual updates, but I wrote https://github.com/JuliaOpt/JuMP.jl/blob/heurcb/doc/callbacks.rst

Note that addSolution will not "wipe" the previous (partial) solution - you must override if a variable takes a value different from the previous partial solution. Notify JuMP that this function should be used as a heuristic using the setHeuristicCallback(m, myHeuristic) function before calling solve(m).

So basically, I say I don't wipe it... I'm not sure whether its better to wipe or not. @mlubin @joehuchette what do you think - wipe after every addSolution or be lazy?

@carlobaldassi
Copy link
Member Author

The downside of not wiping is that there is no way with the current state of affairs to unset a value in the provided solution (well, in GLPK that would be achieved by setting it to NaN, but that's an implementation detail and it shouldn't be exposed - might as well add a check against doing that and make it an error).
So in that case we should add a cbunsetsolutionvalue!(idx) function, I think. Or (I like this better, actually) we could add a signature cbsetsolutionvalue!(idx::Integer, val::Nothing).

On an unrelated note, what about adding back the cbaddsolution!(cbdata, sol::Vector) form, in case one wants to provide a full solution?

@IainNZ
Copy link
Member

IainNZ commented Feb 21, 2014

I'm starting to lean towards wiping, just to make things as simple as possible. If someone comes up with a use case where that is a serious problem, maybe we can re-think it.

We could keep that in mathprogbase, I wasn't sure what scenario would really use it though.

@carlobaldassi
Copy link
Member Author

In case you choose wiping (fine with me) this PR is ready (assuming you tested it, as I still didn't do it). So I'll let you pull the trigger whenever everything's ready.

IainNZ added a commit that referenced this pull request Feb 22, 2014
Update for new heuristic callback design
@IainNZ IainNZ merged commit e5fcb96 into master Feb 22, 2014
@IainNZ IainNZ deleted the heurcb2 branch February 22, 2014 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants