Skip to content

Commit

Permalink
Closes #1493
Browse files Browse the repository at this point in the history
  • Loading branch information
alfoa committed Apr 1, 2021
1 parent 5b4d875 commit 924b55d
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 44 deletions.
2 changes: 1 addition & 1 deletion framework/DataObjects/Factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
factory = EntityFactory('DataObject')
factory.registerType('DataSet', DataSet)
factory.registerType('HistorySet', HistorySet)
factory.registerType('PointSet', PointSet)
factory.registerType('PointSet', PointSet)
2 changes: 1 addition & 1 deletion framework/Databases/Factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
from .NetCDF import NetCDF

factory = EntityFactory('Database', needsRunInfo=True, returnInputParameter=True)
factory.registerAllSubtypes(Database)
factory.registerAllSubtypes(Database)
2 changes: 1 addition & 1 deletion framework/EntityFactoryBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,4 @@ def returnInstance(self, Type, caller, runInfo=None, **kwargs):
# """
# if self._pluginFactory is not None and '.' in typeName:
# pluginName, remainder = typeName.split('.', maxsplit=1)
# new = self._pluginFactory.finishLoadPlugin(pluginName)
# new = self._pluginFactory.finishLoadPlugin(pluginName)
2 changes: 1 addition & 1 deletion framework/LearningGate.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,4 @@ def returnInstance(self, Type, romClass, caller, **kwargs):
return self.returnClass(Type, caller)(romClass, caller.messageHandler, **kwargs)

factory = LearningGateFactory('supervisedGate')
factory.registerType('SupervisedGate', supervisedLearningGate)
factory.registerType('SupervisedGate', supervisedLearningGate)
2 changes: 1 addition & 1 deletion framework/MetricDistributor.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,4 @@ def returnInstance(self, Type, estimator, caller):
return self.returnClass(Type, caller)(estimator, caller.messageHandler)

factory = MetricDistributorFactory('Distributor')
factory.registerType('MetricDistributor', MetricDistributor)
factory.registerType('MetricDistributor', MetricDistributor)
9 changes: 6 additions & 3 deletions framework/Optimizers/stepManipulators/ConjugateGradient.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Step size manipulations based on gradient history
Created 2020-01
@author: zhoujia
@author: zhoujia, alfoa
"""
#for future compatibility with Python 3--------------------------------------------------------------
from __future__ import division, print_function, unicode_literals, absolute_import
Expand Down Expand Up @@ -94,7 +94,7 @@ def handleInput(self, specs):
shrink = specs.findFirst('shrinkFactor')
if shrink is not None:
self._shrink = shrink.value

print(self._initialStepScaling)
def initialize(self, optVars, persistence=None, **kwargs):
"""
initializes this object
Expand All @@ -116,6 +116,8 @@ def initialStepSize(self, numOptVars=None, scaling=1.0, **kwargs):
@ In, numOptVars, int, number of optimization variables
@ In, scaling, float, optional, scaling factor
"""
print("figa")
print(mathUtils.hyperdiagonal(np.ones(numOptVars) * scaling) * self._initialStepScaling)
return mathUtils.hyperdiagonal(np.ones(numOptVars) * scaling) * self._initialStepScaling

def step(self, prevOpt, gradientHist=None, prevStepSize=None, objVar=None, **kwargs):
Expand Down Expand Up @@ -381,7 +383,7 @@ def _startLineSearch(self, lastStepInfo, curPoint, curObjVal, curGrad, curGradMa
# since we've accepted a pivot, we need to store the old pivot and set up the new one
## first grab the savable params
pivot = lastStepInfo.pop('pivot', None)
if True: #pivot is None:
if pivot is None:
# ONLY RUN ONCE per trajectory! First time ever initialization of line step search
# use the current gradient to back-guess the would-be previous objective value
prevObjVal = curObjVal + curGradMag / 2 # oldOldFVal
Expand Down Expand Up @@ -416,6 +418,7 @@ def _startLineSearch(self, lastStepInfo, curPoint, curObjVal, curGrad, curGradMa
'task': b'START',
'persistence': 0,
})

return lastStepInfo

def _lineSearchStep(self, lastStepInfo, curObjVal):
Expand Down
2 changes: 1 addition & 1 deletion framework/Runners/Factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
from .InternalThreadedRunner import InternalThreadedRunner

factory = EntityFactory('Runner')
factory.registerAllSubtypes(Runner)
factory.registerAllSubtypes(Runner)
2 changes: 1 addition & 1 deletion framework/Samplers/Factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@
factory.registerType('AdaptiveDynamicEventTree', AdaptiveDynamicEventTree)
factory.registerType('AdaptiveMonteCarlo' , AdaptiveMonteCarlo)
factory.registerType('Metropolis' , Metropolis)
factory.registerType('AdaptiveMetropolis' , AdaptiveMetropolis)
factory.registerType('AdaptiveMetropolis' , AdaptiveMetropolis)
2 changes: 1 addition & 1 deletion framework/unSupervisedLearning.py
Original file line number Diff line number Diff line change
Expand Up @@ -1407,4 +1407,4 @@ def getDataMiningType(self):
factory = EntityFactory('unSuperVisedLearning')
factory.registerType('SciKitLearn', SciKitLearn)
factory.registerType('temporalSciKitLearn', temporalSciKitLearn)
factory.registerType('Scipy', Scipy)
factory.registerType('Scipy', Scipy)
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
x,y,const,ans,stepSize,iteration,accepted,conv_gradient,CG_task
2.0,2.0,3.14,356.703125,0.0707106781187,0.0,first,0.0,START
1.70384856647,1.03439432043,3.14,15.9212745395,0.0010237121002,1.0,accepted,0.0,FG
1.68396247804,0.024590109959,3.14,1.22747253369,0.0191548452521,2.0,accepted,0.0,CONV
2.68430410873,0.163933649094,3.14,0.687335505932,0.365356000259,3.0,accepted,0.0,CONV
2.29686751933,0.10996530078,3.14,0.406302738346,0.22385205969,4.0,accepted,0.0,FG
2.15357470297,1.10974886175,3.14,22.230291568,0.407893933481,5.0,accepted,0.0,CONV
2.26891300147,0.305009742761,3.14,0.219630681419,0.0795746677073,6.0,accepted,0.0,FG
3.10231242954,-0.265556110843,3.14,6.57423877541,0.788449441735,7.0,accepted,0.0,CONV
2.34256081143,0.254588631177,3.14,0.167215297471,0.0696755633535,8.0,accepted,0.0,FG
2.71968775918,0.968056572725,3.14,11.948524954,1.0,9.0,accepted,0.0,CONV
2.40652071771,0.375591235064,3.14,0.153189838403,0.169597814898,10.0,accepted,0.0,FG
2.37537558076,0.31666928084,3.14,0.133560833837,0.0870125285916,11.0,accepted,0.0,FG
3.0414638977,0.106816981281,3.14,2.22313229993,1.0,12.0,accepted,0.0,CONV
2.43941639613,0.296493108957,3.14,0.109428785572,0.0961446308932,13.0,accepted,0.0,FG
2.66410541694,0.948735049198,3.14,10.7939300676,1.0,14.0,accepted,0.0,CONV
2.46869910464,0.381496864579,3.14,0.106556702209,0.130325497914,15.0,accepted,0.0,FG
2.45384798749,0.338386073355,3.14,0.0920803288159,0.0642291791029,16.0,accepted,0.0,FG
2.93747884866,0.246660713527,3.14,0.8391234392,1.0,17.0,accepted,0.0,CONV
2.51378774788,0.327017906988,3.14,0.0764374355558,0.12393700486,18.0,accepted,0.0,FG
2.64633505333,0.939973786934,3.14,10.3064978399,1.0,19.0,accepted,0.0,CONV
2.52707899351,0.388482356485,3.14,0.0734924266129,0.100275487204,20.0,accepted,0.0,FG
2.52049337598,0.358027622012,3.14,0.0651900295807,0.0505904520017,21.0,accepted,0.0,FG
2.87967661904,0.330560120705,3.14,0.30492053052,1.0,22.0,accepted,0.0,CONV
2.58494445739,0.353098911675,3.14,0.0534855680247,0.179437884858,23.0,accepted,0.0,FG
2.63038806468,0.970974768765,3.14,12.2069760027,1.0,24.0,accepted,0.0,CONV
2.58959501013,0.41633034135,3.14,0.061477097246,0.102336786507,25.0,accepted,0.0,FG
2.58691364225,0.379873013895,3.14,0.0445463485377,0.0433324945671,26.0,accepted,0.0,FG
2.85912618114,0.367445817834,3.14,0.15349268709,1.0,27.0,accepted,0.0,CONV
2.64188025153,0.377363648114,3.14,0.0368975580255,0.201925339283,28.0,accepted,0.0,FG
2.67533820576,0.897152304938,3.14,8.02636575518,1.0,29.0,accepted,0.0,CONV
2.64365331073,0.404909147687,3.14,0.0315434192087,0.0529936527308,30.0,accepted,0.0,FG
2.91691595088,0.221471238942,3.14,0.936421806112,1.0,31.0,accepted,0.0,CONV
2.65740997523,0.395674465023,3.14,0.0287763942695,0.0503422805448,32.0,accepted,0.0,FG
2.79096989782,0.585403569673,3.14,0.445384679984,1.0,33.0,accepted,0.0,CONV
2.79096989782,0.585403569673,3.14,0.445384679984,1.0,33.0,final,0.0,CONV
1.44680123895,-4.5,3.14,18020.2080624,0.247595287373,2.0,accepted,0.0,CONV
1.62162790178,-3.14072406187,3.14,2727.7043487,0.0791972797243,3.0,accepted,0.0,FG
1.67979102545,-0.187233868809,3.14,1.5127980521,0.0231729068648,4.0,accepted,0.0,FG
3.60001834266,1.93395675089,3.14,798.67360953,1.0,5.0,accepted,0.0,CONV
2.20531728983,0.393291870203,3.14,0.481828535766,0.27367919395,6.0,accepted,0.0,FG
2.48672980521,-0.0882879986157,3.14,1.52099484761,0.149388805361,7.0,accepted,0.0,CONV
2.29035352393,0.247769776392,3.14,0.196241133494,0.0451417784581,8.0,accepted,0.0,FG
2.87206167866,0.725611149876,3.14,2.02197565674,1.0,9.0,accepted,0.0,CONV
2.42679561207,0.359849475236,3.14,0.118657036427,0.234554195311,10.0,accepted,0.0,FG
2.52011405355,0.257146684768,3.14,0.170972786626,0.122870155234,11.0,accepted,0.0,CONV
2.46081266915,0.322411573036,3.14,0.090893859893,0.0447894437336,12.0,accepted,0.0,FG
2.55178531049,0.40675508086,3.14,0.074686471002,0.274418778119,13.0,accepted,0.0,CONV
2.51741870702,0.374892755596,3.14,0.0705952587595,0.170751992227,14.0,accepted,0.0,FG
2.56323128738,0.334913001268,3.14,0.0675758562998,0.0901679797521,15.0,accepted,0.0,CONV
2.54190386137,0.353525034154,3.14,0.0593768121142,0.0481914985888,16.0,accepted,0.0,FG
2.5835924844,0.401764018416,3.14,0.0527028679055,0.179378396809,17.0,accepted,0.0,CONV
2.56931032409,0.38523776122,3.14,0.051206178046,0.117924915432,18.0,accepted,0.0,FG
2.59488490583,0.364374105761,3.14,0.0465399080103,0.0660025702894,19.0,accepted,0.0,CONV
2.58715061232,0.3706837157,3.14,0.0455275620855,0.0460419994155,20.0,accepted,0.0,FG
2.6123413963,0.400018045067,3.14,0.039989918874,0.130337720969,21.0,accepted,0.0,CONV
2.62830109518,0.38389525876,3.14,0.035457496568,0.046008797839,22.0,accepted,0.0,CONV
2.64320926141,0.411098787989,3.14,0.0334321969646,0.105104701218,23.0,accepted,0.0,CONV
2.63743775462,0.400567287919,3.14,0.0325069625379,0.0644147540096,24.0,accepted,0.0,FG
2.6558435096,0.391065190391,3.14,0.0301264524256,0.0719892627745,25.0,accepted,0.0,CONV
2.66013402491,0.404783612024,3.14,0.0275745991482,0.0429651670812,26.0,accepted,0.0,CONV
2.6840216625,0.399808104646,3.14,0.0249881225863,0.115500391601,27.0,accepted,0.0,CONV
2.68704823798,0.414385419075,3.14,0.0226868744107,0.0424252092863,28.0,accepted,0.0,CONV
2.70767469869,0.406231270359,3.14,0.0214936312659,0.105827419347,29.0,accepted,0.0,CONV
2.70072705822,0.408977844015,3.14,0.0211390270491,0.0701814172669,30.0,accepted,0.0,FG
2.7054319511,0.420682567639,3.14,0.0197132772651,0.0508968023745,31.0,accepted,0.0,CONV
2.71766478928,0.414172911185,3.14,0.0185647594652,0.0666725641958,32.0,accepted,0.0,CONV
2.72098597642,0.423751686908,3.14,0.0172628024162,0.0443030015661,33.0,accepted,0.0,CONV
2.72098597642,0.423751686908,3.14,0.0172628024162,0.0443030015661,33.0,final,0.0,CONV

0 comments on commit 924b55d

Please sign in to comment.