Back to Recipes Homepage
recipe picture
Recipe: Recursive Improvement V1.51
3.333335
Your rating: None Average: 3.3 (9 votes)
Used 166 times with an average impact of -1856 points.

Profile

Name: Recursive Improvement V1.51
ID: 4000
Created on: Wed, 06/30/2010 - 06:35
Updated on: Wed, 06/30/2010 - 13:35
Description:

Sorry for the bouncing GUI. See script for details.



Best For


Comments

Joined: 09/18/2009
Groups: SETI.Germany
That's how the code does look like

-- Recursive improvement V1.x by Crashguard303
-- An expansion of AfterAlignment.Useful after Alignment or rebuild.
-- Does score-conditional:
-- 1.shake
-- 2.wiggle all
-- repeats 1 & 2 as long as score change is below L1
-- 3. wiggle backbone
-- 4. wiggle sidechains
-- repeats 3&4 as long as score change is below L2
-- repeats the whole thing until no score change.

function xtool(method,MaxPasses,maxiter,threshold,NumSegs)
-- unifies score-conditional shake and wiggle into one function
-- function xtool(method,MaxPasses,threshold,NumSegs)
-- Use:
-- method: what to do
-- "S": shake
-- "WB": wiggle backbone
-- "WS": wiggle sidechains
-- everything other: wiggle all
-- MaxPasses: pseudo-iterations
-- if 0, Method is ended if score change is below threshold
-- >0, Method is also ended if score change is below threshold, but also if number of Passes is reached.
-- maxiter: maximum iterations per pass, starting with 1 and increasing
-- threshold: absolute score difference threshold value.
-- if abs(score change) is below this value, method is not repeated anymore.
-- NumSegs: number of segments in Puzzle

OS="Method:"..method.." threshold:"..threshold.." maximum passes:"
if MaxPasses>0 then
OS=OS..MaxPasses
else
OS=OS.."None"
end -- if MaxPasses
print()
print(OS)
current_pass=0
exit_condition=false
iter=0
repeat
current_pass=current_pass+1
iter=iter+1
if iter>maxiter then iter=maxiter end
print("Pass:",current_pass, " Iterations:",iter)
tempScore=xscore(NumSegs)
if method=="S" then -- check which method is to use
do_shake(1)
elseif method=="WB" then
do_global_wiggle_backbone(iter)
elseif method=="WS" then
do_global_wiggle_sidechains(iter)
else
do_global_wiggle_all(iter)
end -- if method
delta_abs=absolute_value(xscore(NumSegs)-tempScore) -- calculate absolute value of score difference before and after method
print("Delta: ",delta_abs)
if (MaxPasses>0) and (current_pass==MaxPasses) then exit_condition=true end
-- is maximum passes reached?
-- only if MaxPasses>0
if delta_abs until exit_condition==true
end -- function

function xscore(NumSegs)
-- if puzzle score gotten by the regular function is 0,
-- it creates a pesudo-sum by adding all segment scores as reference
-- hopefully this function won't be needed in future game updates, as soon as get_score() returns values below 0
temp=get_score()
if temp==0 then
temp=8000
for k=1,NumSegs do
temp=temp+get_segment_score(k)
end -- k
end -- if
return temp
end -- function

function absolute_value(absolute_input) -- returns absolute value
absolute_input2=absolute_input
if (absolute_input2 < 0) then
absolute_input2=(absolute_input2*(-1))
end -- if
return absolute_input2
end

function recursive_improvement(NumSegs,GP,maxiter,tS,tWA,tL1,tWB,tWS,tL2)
RD=0
repeat
repeat
RD=RD+1 -- Restarts
print("Runs: ",RD)
score1=xscore(NumSegs)
xtool("S",GP,maxiter,tS,NumSegs)
score2=xscore(NumSegs)
delta1=score2-score1

xtool("WA",GP,maxiter,tWA,NumSegs)
score3=xscore(NumSegs)
delta2=score3-score2
until (delta1<=tL1) and (delta2<=tL1)

repeat
score3=xscore(NumSegs)
xtool("WB",GP,maxiter,tWB,NumSegs)
score4=xscore(NumSegs)
delta3=score4-score3

xtool("WS",GP,maxiter,tWS,NumSegs)
score5=xscore(NumSegs)
delta4=score5-score4
until (delta3<= tL2) and (delta4<=tL2)
until (delta1==0) and (delta2==0) and (delta3==0) and (delta4==0)
end -- function

select_all()
GP=10 -- General passes. Set this to value above 0 to limit how often each tool is executed.
maxiter=5 -- maximum iterations per pass, starting with 1, increasing each pass
tS=1e-3 -- repeat shake until score change is below this threshold value or number of passes is reached.
tWA=1e-4 -- same for wiggle all
tL1=5e-5 -- repeat two steps before until score change is below
tWB=1e-8 -- repeat wiggle backbone until score change is below this threshold value or number of passes is reached.
tWS=1e-9 -- same for wiggle sidechains
tL2=5e-10 -- repeat two steps before until score change is below

recursive_improvement(get_segment_count(),GP,maxiter,tS,tWA,tL1,tWB,tWS,tL2)

Want to try?
Add to Cookbook!
To download recipes to your cookbook, you need to have the game client running.
Parent
Children

none

Authors
Sitemap

Developed by: UW Center for Game Science, UW Institute for Protein Design, Northeastern University, Vanderbilt University Meiler Lab, UC Davis
Supported by: DARPA, NSF, NIH, HHMI, Amazon, Microsoft, Adobe, RosettaCommons