Manual
Main interface
CommonSolve.solve
— Methodsolve(Algorithm::CDCPSolver, obj, args...; kwargs...) = cdcp::CDCProblem
Solve a combinatorial discrete choice problem with a given solution algorithm that can be SqueezingPolicy
, Squeezing
or Naive
. Results are returned as a CDCProblem
.
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 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, 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)
: whereobj1
andobj2
are the same objective function attached with different input vectorsobj1.ℒ
andobj2.ℒ
that correspond toℒ1
andℒ2
respectively
zbounds
determines the domain of the parameter z
, which defaults to (-Inf, Inf)
.
Keywords
zero_margin=nothing
: a function that returns the typez
that is indifferent to adding itemℓ
to decision setℒ
; it should have the methodzero_margin(obj::Objective, ℓ::Int, zleft, zright)
withℒ
attached toobj
and if not supplied, this function will be generated automatically fromequal_obj
policy0::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 aNamedTuple
used in the branching stage.maxfcall=1_000_000_000
: maximum calls to the objective function
solve(Naive, obj; 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::
CDCPSolver
obj::
[Objective
]: the objective functionx
: the solution, oncesolve
dvalue
: the maximum value found by the solverstate::
SolverState
CDCP.SolverState
— TypeSolverState::Int8
An Enum
type with values:
inprogress
success
maxfcall_reached
See also solve
, CDCProblem
.
Returned solutions types
CDCP.ItemState
— TypeItemState::Int8
An 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