Manual
Main interface
CommonSolve.solve — Methodsolve(Algorithm::CDCPSolver, obj, S::Integer, args...; kwargs...) = cdcp::CDCProblemSolve a combinatorial discrete choice problem over S possible items, using a given solution algorithm that can be SqueezingPolicy, Squeezing or Naive. Results are returned as a CDCProblem. See the methods below.
The objective function obj should return the value evaluated at a choice vector ℒ with an optional parameter z that is typically a number (e.g. productivity).
obj must have a method of either obj(ℒ) (if no parameter is specified) or obj(ℒ, z) (if a parameter is specified). obj must not restrict the specific type of ℒ but only assume ℒ is a vector of length S with element type being Bool. Specifically, obj must not try to modify the elements in ℒ when it is called. It should only read from ℒ with getindex.
solve(Squeezing, obj, scdca::Bool; z=nothing)The problem should satisfy SCD-C from above if scdca is true and SCD-C from below if scdca is false.
Keywords
z=nothing
solve(SqueezingPolicy, obj, S::Integer, scdca::Bool, equal_obj, zbounds::Tuple{Z,Z}=(-Inf, Inf); kwargs...)The problem should satisfy SCD-C from above if scdca is true and SCD-C from below if scdca is false.
The function equal_obj should returns the cutoff type z with zleft <= z0 <= zright that is indifferent between two decision sets ℒ1 and ℒ2.
equal_obj can be defined with one of the two following methods:
equal_obj((ℒ1, ℒ2), zleft, zright): where the pair of input choices is accepted as a tupleequal_obj(obj1::Objective, obj2::Objective, zleft, zright): whereobj1andobj2are the same objective function attached with different input vectorsobj1.ℒandobj2.ℒthat correspond toℒ1andℒ2respectively
zbounds determines the domain of the parameter z, which defaults to (-Inf, Inf).
Keywords
zero_margin=nothing: a function that returns the typezthat is indifferent to adding itemℓto decision setℒ; it should have the methodzero_margin(obj::Objective, ℓ::Int, zleft, zright)withℒattached toobjand if not supplied, this function will be generated automatically fromequal_objpolicy0::Policy=Policy(obj, zbounds): initial policy which on top of which optimisation occursskiprefinement::Bool=false: skip the refinement step that searches resolves intervals for which squeezing doesn't pin down optimal policysinglekw=NamedTuple(): keyword arguments passed to the single-agent solver as aNamedTupleused in the branching stage.maxfcall=1_000_000_000: maximum calls to the objective function
solve(Naive, obj, S::Integer; kwargs...)Solve with exhaustion by checking all potential decision sets. This method should be used with extreme caution.
Keywords
z=nothing: the type parameterising the problem
CDCP.CDCProblem — TypeCDCProblem{M<:CDCPSolver, O<:Objective, T, F<:AbstractFloat}Results from solving a combinatorial discrete choice problem with solve. When a solution is attained, it can be retrieved from the field x.
Fields
solver::CDCPSolverobj::[Objective]: the objective functionx: the solution, oncesolvedvalue: the maximum value found by the solverstate::SolverState
CDCP.SolverState — TypeSolverState::Int8An Enum type with values:
inprogresssuccessmaxfcall_reached
See also solve, CDCProblem.
Returned solutions types
CDCP.ItemState — TypeItemState::Int8An Enum type describing the state of item ℓ with values:
excluded: from squeezing, definitely excludedincluded: from squeezing, definitely includedaux: checked, but cannot definitively include or exclude based on squeezingundetermined: not yet checked
See also solve, CDCProblem.
CDCP.Policy — TypePolicy{Z,V<:AbstractVector{ItemState}} <: AbstractVector{IntervalChoice{Z,V}}Policy function derived from SqueezingPolicy.
Given a policy function policy::Policy, the optimal decision set of a type z can be retrieved as expected, i.e. policy(z).
See also solve, CDCProblem.
Fields
cutoffs::Vector{Z}: cutoff types at which optimal decision set switchesitemstates_s::Vector{V}: a vector of decision sets, so thatitemstates_s[k]corresponds to the types abovecutoffs[k]and belowcutoffs[k+1]zright::Z: the maximum typez(can beInf).