Skip to content

Commit

Permalink
Hard code docs and test params
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerhanks committed Jul 1, 2024
1 parent 42415e2 commit 60ac06c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 20 deletions.
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,22 @@ using AlgebraicOptimization
using Catlab

# Problem parameters.
P = rand(-1:0.01:1,5,5)
P = P'*P
Q = rand(-1:0.01:1,3,3)
Q = Q'*Q
R = rand(-1:0.01:1,4,4)
R = R'*R
P = [2.1154 -0.3038 0.368 -1.5728 -1.203
-0.3038 1.5697 1.0226 0.159 -0.946
0.368 1.0226 1.847 -0.4916 -1.2668
-1.5728 0.159 -0.4916 2.2192 1.5315
-1.203 -0.946 -1.2668 1.5315 1.9281]
Q = [0.2456 0.3564 -0.0088
0.3564 0.5912 -0.0914
-0.0088 -0.0914 0.8774]
R = [2.0546 -1.333 -0.5263 0.3189
-1.333 1.0481 -0.0211 0.2462
-0.5263 -0.0211 0.951 -0.7813
0.3189 0.2462 -0.7813 1.5813]

a = rand(-1:0.01:1,5)
b = rand(-1:0.01:1,3)
c = rand(-1:0.01:1,4)
a = [-0.26, 0.22, 0.09, 0.19, -0.96]
b = [-0.72, 0.12, 0.41]
c = [0.55, 0.51, 0.6, -0.61]

# Subproblem objectives.
# A PrimalObjective wraps an objective function with its input dimension.
Expand Down
2 changes: 1 addition & 1 deletion src/FinSetAlgebras.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function Open{T}(o::T) where T
Open{T}(domain(o), o, id(domain(o)))
end

function Open{T}(o::T, m::FinFunction)
function Open{T}(o::T, m::FinFunction) where T
Open{T}(domain(o), o, m)
end

Expand Down
27 changes: 17 additions & 10 deletions test/Objectives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,23 @@ d = @relation (x,y,z) begin
h(u,w,z)
end

P = rand(-1:0.01:1,5,5)
P = P'*P
Q = rand(-1:0.01:1,3,3)
Q = Q'*Q
R = rand(-1:0.01:1,4,4)
R = R'*R

a = rand(-1:0.01:1,5)
b = rand(-1:0.01:1,3)
c = rand(-1:0.01:1,4)

P = [2.1154 -0.3038 0.368 -1.5728 -1.203
-0.3038 1.5697 1.0226 0.159 -0.946
0.368 1.0226 1.847 -0.4916 -1.2668
-1.5728 0.159 -0.4916 2.2192 1.5315
-1.203 -0.946 -1.2668 1.5315 1.9281]
Q = [0.2456 0.3564 -0.0088
0.3564 0.5912 -0.0914
-0.0088 -0.0914 0.8774]
R = [2.0546 -1.333 -0.5263 0.3189
-1.333 1.0481 -0.0211 0.2462
-0.5263 -0.0211 0.951 -0.7813
0.3189 0.2462 -0.7813 1.5813]

a = [-0.26, 0.22, 0.09, 0.19, -0.96]
b = [-0.72, 0.12, 0.41]
c = [0.55, 0.51, 0.6, -0.61]

p1 = Open{PrimalObjective}(FinSet(5), PrimalObjective(FinSet(5),x->x'*P*x + a'*x), FinFunction([2,4], 5))
p2 = Open{PrimalObjective}(FinSet(3), PrimalObjective(FinSet(3),x->x'*Q*x + b'*x), id(FinSet(3)))
Expand Down

0 comments on commit 60ac06c

Please sign in to comment.