Skip to content

Commit

Permalink
Merge pull request #8 from jalving/jalving/update_version
Browse files Browse the repository at this point in the history
fix up for release
  • Loading branch information
jalving authored Dec 23, 2024
2 parents ac46f12 + 831ffa0 commit 587ae0c
Show file tree
Hide file tree
Showing 5 changed files with 245 additions and 239 deletions.
8 changes: 4 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PlasmoPlots"
uuid = "a21664a3-f668-4e98-8a13-7892286ec16a"
authors = ["Jordan Jalving <[email protected]> and contributors"]
version = "0.1.0"
version = "0.2.0"

[deps]
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
Expand All @@ -13,10 +13,10 @@ Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[compat]
Colors = "0.12"
GeometryBasics = "0.3, 0.4"
Colors = ">=0.12"
GeometryBasics = ">=0.4"
Graphs = "1"
NetworkLayout = "0.3, 0.4"
NetworkLayout = ">=0.4"
Plasmo = "0.6"
Plots = "1"
julia = "1"
Expand Down
39 changes: 18 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# PlasmoPlots

## Overview
PlasmoPlots.jl provides specialized functions to plot `OptiGraph` optimization models created with [Plasmo.jl](https://zavalab.github.io/Plasmo.jl).
PlasmoPlots.jl provides specialized functions to plot `OptiGraph` optimization models created with [Plasmo.jl](https://github.com/plasmo-dev/Plasmo.jl).
The package uses [Plots.jl](https://github.com/JuliaPlots/Plots.jl) and consequently supports its different plotting backends.

Currently, the package provides two functions to visualize optigraphs. These are:
Expand All @@ -14,12 +14,12 @@ Currently, the package provides two functions to visualize optigraphs. These ar
PlasmoPlots.jl can be installed with following command using the Julia package manager:

```julia
pkg> add https://github.com/jalving/PlasmoPlots.jl.git
pkg> add PlasmoPlots
```

## Simple Examples
## Examples

### Plotting a Simple OptiGraph
### Plotting an OptiGraph

The following example shows how to plot a very simple optigraph containing 3 nodes and one hyperedge between them.
```julia
Expand All @@ -30,38 +30,40 @@ gr()
#create an optigraph
graph = OptiGraph()

@optinode(graph1,n1)
@optinode(graph,n1)
@variable(n1, y >= 2)
@variable(n1,x >= 0)
@constraint(n1,x + y >= 3)
@objective(n1, Min, y)

@optinode(graph1,n2)
@optinode(graph,n2)
@variable(n2, y)
@variable(n2,x >= 0)
@constraint(n2,x + y >= 3)
@objective(n2, Min, y)

@optinode(graph1,n3)
@optinode(graph,n3)
@variable(n3, y )
@variable(n3,x >= 0)
@constraint(n3,x + y >= 3)
@objective(n3, Min, y)

@linkconstraint(graph1, n1[:x] + n2[:x] + n3[:x] == 3)
@linkconstraint(graph, n1[:x] + n2[:x] + n3[:x] == 3)

#plot the graph layout using `layout_plot`
plt_graph1 = layout_plot(graph1,
plt_graph1 = layout_plot(graph,
node_labels = true,
markersize = 60,
labelsize = 30,
linewidth = 4,
layout_options = Dict(:tol => 0.01,:iterations => 2));
layout_options = Dict(:tol=>0.01, :iterations=>2));

#plot the matrix layout using `matrix_plot`
plt_matrix1 = matrix_plot(graph1,
node_labels = true,
markersize = 30);
plt_matrix1 = matrix_plot(
graph,
node_labels = true,
markersize = 30
);
```

<img src="assets/simple_plot_layout.png" width="250" height="250"> <img src="assets/simple_matrix_layout.png" width="250" height="250">
Expand Down Expand Up @@ -147,20 +149,15 @@ graph0 = OptiGraph()
@variable(n0,x)
@constraint(n0,x >= 0)

add_subgraph!(graph0,graph1)
add_subgraph!(graph0,graph2)
add_subgraph!(graph0,graph3)
add_subgraph(graph0,graph1)
add_subgraph(graph0,graph2)
add_subgraph(graph0,graph3)
@linkconstraint(graph0,n3[:x] + n5[:x] + n7[:x] == 10)

@linkconstraint(graph0,n0[:x] + n3[:x] == 3)
@linkconstraint(graph0,n0[:x] + n5[:x] == 5)
@linkconstraint(graph0,n0[:x] + n7[:x] == 7)

#set the node labels which get plotted
for (i,node) in enumerate(all_nodes(graph0))
node.label = "n$i"
end

#plot the graph layout using `layout_plot` which will show subgraphs
plt_graph2 = layout_plot(graph0,
node_labels = true,
Expand Down
2 changes: 1 addition & 1 deletion src/PlasmoPlots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using Statistics
using Plasmo
using Plots
using NetworkLayout
using GeometryBasics:Point2f0,Point
using GeometryBasics: Point2f0, Point
using Colors
using Graphs

Expand Down
Loading

2 comments on commit 587ae0c

@jalving
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/121879

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.0 -m "<description of version>" 587ae0cbddc6135a55a95aee4377462dc69dcfa1
git push origin v0.2.0

Please sign in to comment.