我尝试运行以下代码块:
template <typename T>
Dog::Dog(const T &name) : _name(name) {}
// if T is only copyable, then it will be copied once
// if T is only movable, it results in compilation error (conclusion: define separate move constructor)
// if T is both copyable and movable, it results in one copy
template <typename T>
Dog::Dog(T name) : _name(std::move(name)) {}
// if T is only copyable, then it results in 2 copies
// if T is only movable, and you called Dog(std::move(name)), it results in 2 moves
// if T is both copyable and movable, it results in one copy, then one move.
我收到以下错误:
using JuMP
using CPLEX
function solveRMP(cust::Int64,
routes::Array{Float64,2},
routeCost::Array{Float64,1},
m::Int64)
cust_dep = cust+2;
rmp = Model(solver = CplexSolver())
# Add decistion variables
@variable(rmp, 0<=x[1:size(routes,2)])
#
# Add objective
@objective(rmp, Min, sum(routeCost[r]*x[r] for r=1:size(routes,2)))
# #####################
# ### Constraints
@constraint(rmp, cVisitCust[i=2:cust_dep-1], sum(routes[i,r]*x[r] for r=1:size(routes,2)) == 1)
@constraint(rmp, cMaxNrRoutes, sum(x[r] for r=1:size(routes,2)) <= m )
allConstraints = vcat(cVisitCust,cMaxNrRoutes)
writeLP(rmp, "myRMP.lp", genericnames=false);
solve(rmp)
duals = zeros(1,1)
append!(duals,getdual(allConstraints))
return getvalue(x), duals
end
答案 0 :(得分:1)
在变量x
的声明中,
@variable(rmp, 0<=x[1:size(routes,2)])
约束需要位于变量名称的右侧
@variable(rmp, x[1:size(routes,2)] >= 0)
否则0
被解释为变量名称,导致错误。