forked from arras-energy/gridlabd-models
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstrained_simple.glm
More file actions
52 lines (47 loc) · 888 Bytes
/
constrained_simple.glm
File metadata and controls
52 lines (47 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// simple optimization test
// problem is a quadratic minimization problem
// it should solve in a single iteration
#set tmp=.
#set verbose=1
#set profiler=1
#define include=../../core
module optimize;
class quadratic {
double y;
double x;
double a;
double b;
double c;
intrinsic create(object parent)
{
return 1;
};
intrinsic init(object parent)
{
double mx = -b/a/2;
gl_verbose("minimum y=%.2f expected at x=%.2f", (a*mx+b)*mx+c, mx);
return 1;
};
intrinsic sync(TIMESTAMP t0, TIMESTAMP t1)
{
double dy = 2*a*x+b;
y = (a*x + b)*x + c;
gl_verbose("function y(%.4f) = %.2f",x,y);
gl_verbose("function y'(%.4f) = %.2f",x,dy);
return TS_NEVER;
};
}
object quadratic {
name quadratic;
a -2;
b 0.25;
c 0.89;
x 0.52;
}
object simple {
objective "quadratic.y";
variable "quadratic.x";
constraint "quadratic.y>1.0";
delta 0.001;
epsilon 0.00001;
}