FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
FEBio/FEBioOpt/FEScanOptimizeMethod.cpp at develop · febiosoftware/FEBio · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
febiosoftware
/
FEBio
Public
Notifications
You must be signed in to change notification settings
Fork
89
Star
279
Code
Issues
32
Pull requests
1
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
FEBio
/
FEBioOpt
/
FEScanOptimizeMethod.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
94 lines (74 loc) · 2.63 KB
Breadcrumbs
FEBio
/
FEBioOpt
/
FEScanOptimizeMethod.cpp
Copy path
File metadata and controls
94 lines (74 loc) · 2.63 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#
include
"
stdafx.h
"
#
include
"
FEScanOptimizeMethod.h
"
#
include
"
FEOptimizeData.h
"
#
include
"
FECore/log.h
"
BEGIN_FECORE_CLASS
(FEScanOptimizeMethod, FEOptimizeMethod)
END_FECORE_CLASS
();
FEScanOptimizeMethod::FEScanOptimizeMethod
(FEModel* fem) : FEOptimizeMethod(fem)
{
}
bool
FEScanOptimizeMethod::Solve
(FEOptimizeData* pOpt, vector<
double
>& amin, vector<
double
>& ymin,
double
* minObj)
{
if
(pOpt ==
0
)
return
false
;
FEOptimizeData& opt = *pOpt;
FEObjectiveFunction& obj = opt.
GetObjective
();
//
set the intial values for the variables
int
ma = opt.
InputParameters
();
vector<
double
>
a
(ma);
for
(
int
i=
0
; i<ma; ++i)
{
FEInputParameter* var = opt.
GetInputParameter
(i);
a[i] = var->
MinValue
();
}
//
loop until done
vector<
double
>
y
(ma,
0.0
);
bool
bdone =
false
;
double
fmin =
0.0
;
do
{
//
solve the problem with the new input parameters
if
(opt.
FESolve
(a) ==
false
)
return
false
;
//
calculate objective function
double
fobj = obj.
Evaluate
(y);
//
update minimum
if
((fmin ==
0.0
) || (fobj < fmin))
{
fmin = fobj;
amin = a;
ymin = y;
}
//
update indices
for
(
int
i=
0
; i<ma; ++i)
{
FEInputParameter& vi = *opt.
GetInputParameter
(i);
a[i] += vi.
ScaleFactor
();
if
(a[i] <= vi.
MaxValue
())
break
;
else
if
(i<ma-
1
) a[i] = vi.
MinValue
();
else
{ bdone =
true
; }
}
}
while
(!bdone);
//
store the optimum data
if
(minObj) *minObj = fmin;
return
true
;
}
Back
|
FazBrowse Home
|
New Git URL