How to feed initial solution to solver?

I am keen to learn how to feed an initial solution to a solver. I use the following example and I got the above warning when I used CPLEX, Cbc, Gurobi, GLPK. Could any one point me in the right direction to solve this issue or is there any solver that accepts an initial solution?

Many thanks in advance.

using JuMP
using MathOptInterface
using Gurobi
using CPLEX
using GLPK
using Cbc
function solveModel(solver)
@variable(myModel, x, Int)
@variable(myModel, y, Int)
@variable(myModel, z>=0)
@variable(myModel, e[1:3], Bin)
@constraint(myModel,con1, 2x+3y<=10)
@constraint(myModel,con2, 3x+2y<=12)
@constraint(myModel,con3, z==2x+4y)
@constraint(myModel,con4, x>=y)
@constraint(myModel, con5, sum(e)==1)
@objective(myModel, Max,z)
@show termination_status(myModel) == MathOptInterface.OPTIMAL
@show primal_status(myModel) == MathOptInterface.FEASIBLE_POINT
return myModel, sol

I get the following output when I use GLPK. I have commented out “vals” and “set_start_value”. This looks fine.

(A JuMP Model
Maximization problem with:
Variables: 6
Objective function type: VariableRef
`VariableRef`-in-`MathOptInterface.ZeroOne`: 3 constraints
`VariableRef`-in-`MathOptInterface.Integer`: 2 constraints
`VariableRef`-in-`MathOptInterface.GreaterThan{Float64}`: 1 constraint
`GenericAffExpr{Float64,VariableRef}`-in-`MathOptInterface.EqualTo{Float64}`: 2 constraints
`GenericAffExpr{Float64,VariableRef}`-in-`MathOptInterface.GreaterThan{Float64}`: 1 constraint
`GenericAffExpr{Float64,VariableRef}`-in-`MathOptInterface.LessThan{Float64}`: 2 constraints
Model mode: AUTOMATIC
CachingOptimizer state: ATTACHED_OPTIMIZER
Solver name: GLPK
Names registered in the model: con1, con2, con3, con4, con5, e, x, y, z, [2.0, 2.0, 12.0, 1.0, 0.0, 0.0])

This is a duplicate of Warning, invalid warm-start basis discarded so I’m closing this thread.

1 Like