问题的更多详细信息:https://github.com/control-toolbox/OptimalControl.jl/issues/375
我正在使用 Julia 中的
OptimalControl
包解决最优控制问题。求解器 (solve
) 找到了最佳解,但随后出现错误,导致我无法处理或显示解。这是相关输出:
.
.
.
EXIT: Optimal Solution Found.
ERROR: MethodError: no method matching String(::Tuple{Symbol, MathOptInterface.TerminationStatusCode, MathOptInterface.ResultStatusCode})
The type `String` exists, but no method is defined for this combination of argument types when trying to construct it.
Closest candidates are:
String(::LazyString)
@ Base strings/lazy.jl:80
String(::Vector{UInt8})
@ Base strings/string.jl:72
String(::Base.CodeUnits{UInt8, String})
@ Base strings/string.jl:126
...
Stacktrace:
[1] OptimalControlSolution(docp::CTDirect.DOCP, docp_solution::SolverCore.GenericExecutionStats{…})
@ CTDirect ~/.julia/packages/CTDirect/5NADh/src/solution.jl:18
[2] direct_solve(::OptimalControlModel{…}; init::Nothing, grid_size::Int64, time_grid::Nothing, kwargs::@Kwargs{})
@ CTDirect ~/.julia/packages/CTDirect/5NADh/src/solve.jl:122
[3] direct_solve(::OptimalControlModel{Autonomous, Fixed})
@ CTDirect ~/.julia/packages/CTDirect/5NADh/src/solve.jl:90
[4] solve(::OptimalControlModel{Autonomous, Fixed}; kwargs::@Kwargs{})
@ OptimalControl ~/.julia/packages/OptimalControl/6SuFg/src/solve.jl:61
[5] solve(::OptimalControlModel{Autonomous, Fixed})
@ OptimalControl ~/.julia/packages/OptimalControl/6SuFg/src/solve.jl:55
[6] top-level scope
@ ~/Code/Tutorial.jl:15
Some type information was truncated. Use `show(err)` to see complete types.
我尝试过的:
Pkg.update("OptimalControl")
和 Pkg.update("CTDirect")
更新了所有相关软件包。Pkg.develop
检查并手动修改 CTDirect
包代码,但这导致了 OptimalControl
的兼容性问题。问题似乎源于
CTDirect
处理解决方案的方式。具体来说,它尝试将元组 (Symbol, MathOptInterface.TerminationStatusCode, MathOptInterface.ResultStatusCode)
转换为 String
,但失败了,因为没有为此组合定义方法。
我的设置:
-Julia Version: `1.11.1`
-OptimalControl Version: `0.12.3`
-CTDirect Version: `0.12.0`
问题:
CTDirect
或 OptimalControl
的已知问题吗?有更好的解决方法吗?Pkg.develop
期间导致冲突,我如何在本地修补此问题?CTDirect
存储库报告此问题是否会更好?如果是,我应该包含哪些详细信息?问题已解决,所有细节均在此处:https://github.com/control-toolbox/OptimalControl.jl/issues/375。