-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
257 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
Using solver 'cvxopt' | ||
for 3 free variables | ||
in 4 posynomial inequalities. | ||
Solving took 0.00804 seconds. | ||
|
||
Optimal Cost | ||
------------ | ||
1 | ||
|
||
Model Sensitivities (sorts models in sections below) | ||
------------------- | ||
+3.0 : System.Fleet2 | ||
+1.0 : System.Fleet2.Vehicle | ||
|
||
Free Variables | ||
-------------- | ||
| System.Fleet2 | ||
z : [ 1 ] | ||
|
||
| System.Fleet2.Vehicle | ||
a : [ 1 1 ] | ||
|
||
Fixed Variables | ||
--------------- | ||
| System.Fleet2 | ||
x : [ 4 ] | ||
y : [ 3 1 ] | ||
|
||
Variable Sensitivities | ||
---------------------- | ||
| System.Fleet2 | ||
y : [ - +0.25 ] | ||
|
||
Most Sensitive Constraints | ||
-------------------------- | ||
| System.Fleet2 | ||
+1 : z[0] ≥ a[0,0]·x[0]^-1·y[0,0] + y[1,0]/x[0]·a[1,0] | ||
|
||
| System.Fleet2.Vehicle | ||
+0.75 : a[0,0] ≥ 1 | ||
+0.25 : a[1,0] ≥ 1 | ||
|
||
Using solver 'cvxopt' | ||
for 9 free variables | ||
in 10 posynomial inequalities. | ||
Solving took 0.0195 seconds. | ||
|
||
Optimal Cost | ||
------------ | ||
3 | ||
|
||
Model Sensitivities (sorts models in sections below) | ||
------------------- | ||
+3.0 : System2.Fleet2 | ||
+1.0 : System2.Fleet2.Vehicle | ||
|
||
Free Variables | ||
-------------- | ||
| System2.Fleet2 | ||
z : [ 1 1 1 ] | ||
|
||
| System2.Fleet2.Vehicle | ||
a : [ 1 1 1 | ||
1 1 1 ] | ||
|
||
Fixed Variables | ||
--------------- | ||
| System2.Fleet2 | ||
x : [ 4 4 4 ] | ||
y : [ 3 3 3 | ||
1 1 1 ] | ||
|
||
Variable Sensitivities | ||
---------------------- | ||
| System2.Fleet2 | ||
y : [ - - - | ||
+0.083 +0.083 +0.083 ] | ||
|
||
Most Sensitive Constraints | ||
-------------------------- | ||
| System2.Fleet2 | ||
+0.33 : z[0] ≥ a[0,0]·x[0]^-1·y[0,0] + y[1,0]/x[0]·a[1,0] | ||
+0.33 : z[1] ≥ a[0,1]·x[1]^-1·y[0,1] + y[1,1]/x[1]·a[1,1] | ||
+0.33 : z[2] ≥ a[0,2]·x[2]^-1·y[0,2] + y[1,2]/x[2]·a[1,2] | ||
|
||
| System2.Fleet2.Vehicle | ||
+0.25 : a[0,0] ≥ 1 | ||
+0.25 : a[0,1] ≥ 1 | ||
|
||
Sweeping with 1 solves: | ||
Sweeping took 0.0224 seconds. | ||
|
||
Optimal Cost | ||
------------ | ||
20 | ||
|
||
Swept Variables | ||
--------------- | ||
y : [ 1 2 3 ] | ||
|
||
Free Variables | ||
-------------- | ||
x : [ 2 6 12 ] | ||
|
||
Fixed Variables | ||
--------------- | ||
z : [ 1 4 9 ] | ||
|
||
Variable Sensitivities | ||
---------------------- | ||
y : [ +0.15 +0.5 +1 ] | ||
|
||
Most Sensitive Constraints | ||
-------------------------- | ||
+0.6 : x[2] ≥ y[2] + z[2] | ||
+0.3 : x[1] ≥ y[1] + z[1] | ||
+0.1 : x[0] ≥ y[0] + z[0] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
"Tests broadcast_sub function for returned-dictionary substitutions" | ||
import numpy as np | ||
from gpkit import Variable, Model, ConstraintSet, Vectorize | ||
from gpkit.small_scripts import broadcast_substitution | ||
|
||
class Pie(Model): | ||
"Pie model" | ||
def setup(self): | ||
self.x = x = Variable("x") | ||
z = Variable("z") | ||
constraints = [ | ||
x >= z, | ||
] | ||
substitutions = {'z': 1} | ||
return constraints, substitutions | ||
|
||
class Cake(Model): | ||
"Cake model, containing a vector of Pies" | ||
def setup(self): | ||
self.y = y = Variable("y") | ||
with Vectorize(2): | ||
s = Pie() | ||
constraints = [y >= s.x] | ||
constraints += [s] | ||
subs = {'x': broadcast_substitution(s.x, [2, 3])} | ||
return constraints, subs | ||
|
||
class Yum1(Model): | ||
"Total dessert system model containing 5 Cakes" | ||
def setup(self): | ||
with Vectorize(5): | ||
cake = Cake() | ||
y = cake.y | ||
self.cost = sum(y) | ||
constraints = ConstraintSet([cake]) | ||
return constraints | ||
|
||
m = Yum1() | ||
sol = m.solve() | ||
print(sol.table()) | ||
|
||
class Yum2(Model): | ||
"Total dessert system model containing 1 Cake" | ||
def setup(self): | ||
with Vectorize(1): | ||
cake = Cake() | ||
y = cake.y | ||
self.cost = sum(y) | ||
constraints = ConstraintSet([cake]) | ||
return constraints | ||
|
||
m = Yum2() | ||
sol = m.solve() | ||
print(sol.table()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
Using solver 'cvxopt' | ||
for 5 free variables | ||
in 11 posynomial inequalities. | ||
Solving took 0.0145 seconds. | ||
|
||
Optimal Cost | ||
------------ | ||
15 | ||
|
||
Model Sensitivities (sorts models in sections below) | ||
------------------- | ||
+1.0 : Yum1.Cake.Pie | ||
: Yum1.Cake | ||
|
||
Free Variables | ||
-------------- | ||
| Yum1.Cake | ||
y : [ 3 3 3 3 3 ] | ||
|
||
Fixed Variables | ||
--------------- | ||
| Yum1.Cake.Pie | ||
x : [ 2 2 2 2 2 | ||
3 3 3 3 3 ] | ||
z : [ 1 1 1 1 1 | ||
1 1 1 1 1 ] | ||
|
||
Variable Sensitivities | ||
---------------------- | ||
| Yum1.Cake.Pie | ||
x : [ +7.1e-07 +7.1e-07 +7.1e-07 +7.1e-07 +7.1e-07 | ||
+0.2 +0.2 +0.2 +0.2 +0.2 ] | ||
|
||
Most Sensitive Constraints | ||
-------------------------- | ||
| Yum1.Cake | ||
+0.2 : y[0] ≥ x[1,0] | ||
+0.2 : y[1] ≥ x[1,1] | ||
+0.2 : y[2] ≥ x[1,2] | ||
+0.2 : y[3] ≥ x[1,3] | ||
+0.2 : y[4] ≥ x[1,4] | ||
|
||
Using solver 'cvxopt' | ||
for 1 free variables | ||
in 3 posynomial inequalities. | ||
Solving took 0.0132 seconds. | ||
|
||
Optimal Cost | ||
------------ | ||
3 | ||
|
||
Model Sensitivities (sorts models in sections below) | ||
------------------- | ||
+1.0 : Yum2.Cake | ||
: Yum2.Cake.Pie | ||
|
||
Free Variables | ||
-------------- | ||
| Yum2.Cake | ||
y : [ 3 ] | ||
|
||
Fixed Variables | ||
--------------- | ||
| Yum2.Cake.Pie | ||
x : [ 2 3 ] | ||
z : [ 1 1 ] | ||
|
||
Variable Sensitivities | ||
---------------------- | ||
| Yum2.Cake.Pie | ||
x : [ +8.4e-08 +1 ] | ||
|
||
Most Sensitive Constraints | ||
-------------------------- | ||
| Yum2.Cake | ||
+1 : y[0] ≥ x[1,0] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters