在Julia v.1.1.1中使用CPLEX求解器构建模型时如何定义间隙?

时间:2019-07-10 11:25:48

标签: julia

请您帮助我如何在Julia v.1.1.1中使用Gap制作CPLEX模型? 在以前的版本中,我使用

Tsp=Model(solver=CplexSolver(CPX_PARAM_EPGAP=0.00009))

但是新版本在运行模型时会出错。

Model(with_optimizer(CPLEX.Optimizer),CPX_PARAM_EPGAP=0.00009)
ERROR: MethodError: no method matching Model(; CPX_PARAM_EPGAP=9.0e-5)
Closest candidates are:
  Model(; caching_mode, solver) at C:\Users\admin\.juliapro\JuliaPro_v1.1.1.1\packages\JuMP\ibcEh\src\JuMP.jl:190 got unsupported keyword argument "CPX_PARAM_EPGAP"
  Model(::Dict{MathOptInterface.VariableIndex,MathOptInterface.ConstraintIndex{MathOptInterface.SingleVariable,MathOptInterface.GreaterThan{Float64}}}, ::Dict{MathOptInterface.VariableIndex,MathOptInterface.ConstraintIndex{MathOptInterface.SingleVariable,MathOptInterface.LessThan{Float64}}}, ::Dict{MathOptInterface.VariableIndex,MathOptInterface.ConstraintIndex{MathOptInterface.SingleVariable,MathOptInterface.EqualTo{Float64}}}, ::Dict{MathOptInterface.VariableIndex,MathOptInterface.ConstraintIndex{MathOptInterface.SingleVariable,MathOptInterface.Integer}}, ::Dict{MathOptInterface.VariableIndex,MathOptInterface.ConstraintIndex{MathOptInterface.SingleVariable,MathOptInterface.ZeroOne}}, ::MathOptInterface.AbstractOptimizer, ::Dict{MathOptInterface.ConstraintIndex,AbstractShape}, ::Set{Any}, ::Any, ::Any, ::Dict{Symbol,Any}, ::Int64, ::Dict{Symbol,Any}) at C:\Users\admin\.juliapro\JuliaPro_v1.1.1.1\packages\JuMP\ibcEh\src\JuMP.jl:146 got unsupported keyword argument "CPX_PARAM_EPGAP"
  Model(::OptimizerFactory; bridge_constraints, kwargs...) at C:\Users\admin\.juliapro\JuliaPro_v1.1.1.1\packages\JuMP\ibcEh\src\JuMP.jl:220
  ...
Stacktrace:
 [1] kwerr(::NamedTuple{(:CPX_PARAM_EPGAP,),Tuple{Float64}}, ::Type) at .\error.jl:125
 [2] (::getfield(Core, Symbol("#kw#Type")))(::NamedTuple{(:CPX_PARAM_EPGAP,),Tuple{Float64}}, ::Type{Model}) at .\none:0
 [3] #Model#7(::Bool, ::Base.Iterators.Pairs{Symbol,Float64,Tuple{Symbol},NamedTuple{(:CPX_PARAM_EPGAP,),Tuple{Float64}}}, ::Type, ::OptimizerFactory) at C:\Users\admin\.juliapro\JuliaPro_v1.1.1.1\packages\JuMP\ibcEh\src\JuMP.jl:220
 [4] (::getfield(Core, Symbol("#kw#Type")))(::NamedTuple{(:CPX_PARAM_EPGAP,),Tuple{Float64}}, ::Type{Model}, ::OptimizerFactory) at .\none:0

但没有间隙


Model(with_optimizer(CPLEX.Optimizer))
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: EMPTY_OPTIMIZER
Solver name: CPLEX

非常感谢

它制作了Tsp模型。

Tsp=Model(with_optimizer(CPLEX.Optimizer,CPX_PARAM_EPGAP=0.00009))
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: EMPTY_OPTIMIZER
Solver name: CPLEX

1 个答案:

答案 0 :(得分:1)

您能尝试一下吗?

Option Explicit

Sub test()

    Dim LastRow As Long
    Dim strSearchingValue As String
    Dim rngSearchingArea As Range, rngFound As Range

    'Set the value you are looking for
    strSearchingValue = "Test"

    'Let us assume that our data appears in Sheet1 - change if needed
    With ThisWorkbook.Worksheets("Sheet1")
        'Let us assume that IDs appears in column A - Find the last row of column A
        LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
        'Let us assume that IDs start from row 2 and end at LastRow - Set the range we want to search
        Set rngSearchingArea = .Range("A2:A" & LastRow)
        'Use find method to check if there is any match
        Set rngFound = rngSearchingArea.Find(strSearchingValue, LookIn:=xlvalues, LookAt:=xlWhole)
        'Check the results
        If Not rngFound Is Nothing Then
            'If there is a match - you get back the row
            Debug.Print rngFound.Row
        Else
            'If there is not a match - you get back a message box
            MsgBox "This ID is not appear in the data."
        End If

    End With

End Sub