Skip to content

Commit

Permalink
Merge pull request #111 from hdavid16/update-logical-constraint-docs
Browse files Browse the repository at this point in the history
update proposition docs to include splatting
  • Loading branch information
hdavid16 authored Feb 8, 2024
2 parents fc4c5eb + 0523ae2 commit 3406645
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pkg.add("DisjunctiveProgramming")

## Model

A generalized disjunctive programming (GDP) model is created using `GDPModel()`, where the optimizer can be passed at model creation, along with other keyword arguments supported by JuMP Models.
A generalized disjunctive programming (GDP) model is created using `GDPModel()`, where the optimizer can be passed at model creation, along with other keyword arguments supported by JuMP Models.

```julia
using DisjunctiveProgramming
Expand Down Expand Up @@ -49,7 +49,7 @@ data = gdp_data(model)

## Logical Variables

Logical variables are JuMP `AbstractVariable`s with two fields: `fix_value` and `start_value`. These can be optionally specified at variable creation. Logical variables are created with the `@variable` JuMP macro by adding the tag `Logical` as the last keyword argument. As with the regular `@variable` macro, variables can be named and indexed:
Logical variables are JuMP `AbstractVariable`s with two fields: `fix_value` and `start_value`. These can be optionally specified at variable creation. Logical variables are created with the `@variable` JuMP macro by adding the tag `Logical` as the last keyword argument. As with the regular `@variable` macro, variables can be named and indexed:

```julia
@variable(model, Y[1:3], Logical)
Expand Down Expand Up @@ -79,9 +79,19 @@ Two types of logical constraints are supported:
@constraint(model, Y[1] ⟹ Y[2] := true)
```

_Note_: The parenthesis in the example above around the implication clause are only required when the parent logical operator is `` or `` to avoid parsing errors.
_DisjunctiveProgramming.jl_ will automatically reformulate Logical propositions to integer programming constraints by converting these expressions to [Conjunctive Normal Form](https://en.wikipedia.org/wiki/Conjunctive_normal_form), and then to algebraic constraints.

Logical propositions can be reformulated to IP constraints by automatic reformulation to [Conjunctive Normal Form](https://en.wikipedia.org/wiki/Conjunctive_normal_form).
Variable splatting is supported in the logical operator functions `logical_or`, `logical_and`, `logical_not`, `implies`, and `iff` such that

```julia
@constraint(model, logical_and(Y...) := true)
```

is equivalent to

```julia
@constraint(model, Y[1] ∧ Y[2] := true)
```

## Disjunctions

Expand Down
18 changes: 14 additions & 4 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pkg.add("DisjunctiveProgramming")

## Model

A generalized disjunctive programming (GDP) model is created using [`GDPModel`](@ref), where the optimizer can be passed at model creation, along with other keyword arguments supported by JuMP Models.
A generalized disjunctive programming (GDP) model is created using [`GDPModel`](@ref), where the optimizer can be passed at model creation, along with other keyword arguments supported by JuMP Models.

```julia
using DisjunctiveProgramming
Expand Down Expand Up @@ -49,7 +49,7 @@ data = gdp_data(model)

## Logical Variables

Logical variables are JuMP `AbstractVariable`s with two fields: `fix_value` and `start_value`. These can be optionally specified at variable creation. Logical variables are created with the `@variable` JuMP macro by adding the tag [`Logical`](@ref) as the last keyword argument. As with the regular `@variable` macro, variables can be named and indexed:
Logical variables are JuMP `AbstractVariable`s with two fields: `fix_value` and `start_value`. These can be optionally specified at variable creation. Logical variables are created with the `@variable` JuMP macro by adding the tag [`Logical`](@ref) as the last keyword argument. As with the regular `@variable` macro, variables can be named and indexed:

```julia
@variable(model, Y[1:3], Logical)
Expand Down Expand Up @@ -79,9 +79,19 @@ The `@constraint` JuMP macro is used to create these constraints with `:=`:
@constraint(model, Y[1] ⟹ Y[2] := true)
```

_Note_: The parenthesis in the example above around the implication clause are only required when the parent logical operator is `` or `` to avoid parsing errors.
_DisjunctiveProgramming.jl_ will automatically reformulate Logical propositions to integer programming constraints by converting these expressions to [Conjunctive Normal Form](https://en.wikipedia.org/wiki/Conjunctive_normal_form), and then to algebraic constraints.

Logical propositions can be reformulated to IP constraints by automatic reformulation to [Conjunctive Normal Form](https://en.wikipedia.org/wiki/Conjunctive_normal_form).
Variable splatting is supported in the logical operator functions `logical_or`, `logical_and`, `logical_not`, `implies`, and `iff` such that

```julia
@constraint(model, logical_and(Y...) := true)
```

is equivalent to

```julia
@constraint(model, Y[1] ∧ Y[2] := true)
```

## Disjunctions

Expand Down

0 comments on commit 3406645

Please sign in to comment.