# shrinkage::GapSafePenalty

Shrinkage for Rust · 0.3.0

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/screening.rs>)

```rust
pub trait GapSafePenalty: ProximalPenalty
```

Complete-penalty dual feasibility and exact fixed-zero restrictions. 

A fixed-zero constraint differs from excluding a coordinate from a penalty. Implementations must retain every interaction with removed zeros. 

<a id="methods"></a>

## Methods

<a id="method-dual_feasible"></a>

### `dual_feasible`

```rust
fn dual_feasible(
    &self,
    correlations: &[f64],
    errors: &[f64]
) -> Result<bool, FitError>
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/screening.rs>)

Check complete feasibility for all correlations within the error bounds. 

<a id="method-dual_feasible-documentation-errors"></a>

#### Errors

Reject incompatible dimensions or invalid penalty settings. 

<a id="method-dual_scaling"></a>

### `dual_scaling`

```rust
fn dual_scaling(
    &self,
    _correlations: &[f64],
    _errors: &[f64]
) -> Result<Option<f64>, FitError>
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/screening.rs>)

Return an analytic feasible divisor, or request the generic search. 

<a id="method-dual_scaling-documentation-errors"></a>

#### Errors

Reject incompatible dimensions or invalid penalty settings. 

<a id="method-has_sparsity"></a>

### `has_sparsity`

```rust
fn has_sparsity(&self) -> bool
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/screening.rs>)

Whether this penalty has a positive sparsity component. 

<a id="method-prox_zeroed"></a>

### `prox_zeroed`

```rust
fn prox_zeroed(
    &self,
    input: &[f64],
    zeroed: &[bool],
    step: f64,
    output: &mut [f64]
) -> Result<(), FitError>
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/screening.rs>)

Evaluate the exact prox with `true` coordinates constrained to zero. 

<a id="method-prox_zeroed-documentation-errors"></a>

#### Errors

Reject invalid parameters, dimensions, steps, or arithmetic. 

<a id="method-screen_zeros"></a>

### `screen_zeros`

```rust
fn screen_zeros(
    &self,
    correlations: &[f64],
    errors: &[f64],
    zeroed: &mut [bool]
) -> Result<(), FitError>
```

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/screening.rs>)

Add proven zeros using bounds on the optimal correlations. 

`errors[j]` includes the safe radius times the column norm and rounding. Existing `true` entries must remain fixed. 

<a id="method-screen_zeros-documentation-errors"></a>

#### Errors

Reject incompatible dimensions or invalid penalty settings. 

<a id="impl-4aba12756cba46501c1f131992292ac408f15b936047206d8f4fb8ef96d27ee6"></a>

## [Implementation of GapSafePenalty](<70ffed513f4897153138a3d474faab53b31c338c10fd2b0945fd39cc01a58a42>)

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/screening/penalty.rs>)

```rust
impl GapSafePenalty for shrinkage::ChainFusedLasso
```

<a id="impl-fd650d538e5ed97951f25f48d795dd53b3ae461da347319c529574d24863f788"></a>

## [Implementation of GapSafePenalty](<70ffed513f4897153138a3d474faab53b31c338c10fd2b0945fd39cc01a58a42>)

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/screening/penalty.rs>)

```rust
impl GapSafePenalty for shrinkage::ClusteredLasso
```

<a id="impl-c0e9e90d7de5c93536e790e4dee5a0ed4e7121cc5b1fe066dc139a4c91f3b9c6"></a>

## [Implementation of GapSafePenalty](<70ffed513f4897153138a3d474faab53b31c338c10fd2b0945fd39cc01a58a42>)

[Source](<https://github.com/jolars/shrinkage/blob/eeafe449edce19d3c552a03060f681ae3891af74/src/screening/penalty.rs>)

```rust
impl GapSafePenalty for shrinkage::Slope
```
