Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup system for constraints #25

Merged
merged 3 commits into from
Oct 13, 2023
Merged

Setup system for constraints #25

merged 3 commits into from
Oct 13, 2023

Conversation

dahong67
Copy link
Owner

@dahong67 dahong67 commented Oct 13, 2023

Fixes #24

@codecov
Copy link

codecov bot commented Oct 13, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (ba84a57) 99.05% compared to head (ef7df98) 100.00%.

Additional details and impacted files
@@             Coverage Diff             @@
##           master       #25      +/-   ##
===========================================
+ Coverage   99.05%   100.00%   +0.94%     
===========================================
  Files           5         6       +1     
  Lines         106       113       +7     
===========================================
+ Hits          105       113       +8     
+ Misses          1         0       -1     
Files Coverage Δ
src/GCPDecompositions.jl 100.00% <ø> (ø)
src/gcp-opt.jl 100.00% <100.00%> (+2.22%) ⬆️
src/type-constraints.jl 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dahong67 dahong67 self-assigned this Oct 13, 2023
@dahong67
Copy link
Owner Author

dahong67 commented Oct 13, 2023

This PR adds a constraints argument:

gcp(X::Array, r, loss = LeastSquaresLoss(); constraints = default_constraints(loss)) =
_gcp(X, r, loss, constraints, (;))

with corresponding constraint types:
"""
AbstractConstraint
Abstract type for GCP constraints on the factor matrices `U = (U[1],...,U[N])`.
"""
abstract type AbstractConstraint end
# Concrete types
"""
LowerBound(value::Real)
Lower-bound constraint on the entries of the factor matrices
`U = (U[1],...,U[N])`, i.e., `U[i][j,k] >= value`.
"""
struct LowerBound{T} <: AbstractConstraint
value::T
end

and clarifies that the weights λ are constrained to all be one:
"""
gcp(X::Array, r, loss = LeastSquaresLoss();
constraints = default_constraints(loss)) -> CPD
Compute an approximate rank-`r` CP decomposition of the tensor `X`
with respect to the loss function `loss` and return a `CPD` object.
The weights `λ` are constrained to all be one and `constraints` is a
`Tuple` of constraints on the factor matrices `U = (U[1],...,U[N])`.
Conventional CP corresponds to the default `LeastSquaresLoss()` loss
with no constraints (i.e., `constraints = ()`).

@dahong67 dahong67 merged commit d8e9a75 into master Oct 13, 2023
@dahong67 dahong67 deleted the dahong67/issue24 branch October 13, 2023 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setup more systematic handling of constraints
1 participant