Profile


Name
Total LWS V2.0
ID
45315
Shared with
Public
Parent
None
Children
Created on
February 01, 2014 at 23:04 PM UTC
Updated on
February 01, 2014 at 23:04 PM UTC
Description

Lua V2 with dialog, good for filters and New Chapter

Best for


Code


--Total LWS V2.0 --Based on Total LWS 1.0.4. by Rav3n_pl --Bruno Kestemont 6 Feb 2013 --adapted to NC + minppi diminishes with loops 01/02/2014 --------------------------------------------------------------------------------------- --Generic parameters and functions p=print --"quicker" print segCnt=structure.GetCount() --runnum=1 --minlen=1 --maxlen=7 --minppi=0.01 --NotAllLoops=true timeLeft=os.difftime(puzzle.GetExpirationTime(),os.time())/86400 startTime=os.time() PROBABLEFILTER=false OriginalFilterSetting = behavior.GetSlowFiltersDisabled() -- new BK 8/4/2013 function Score() return current.GetEnergyScore() end startingscore= Score() function down1(x)--cut all afer 1-rd place return x-x%0.1 end function down(x) return x-x%1 end function detectfilter() local descrTxt=puzzle.GetDescription() if #descrTxt>0 and (descrTxt:find("filter") or descrTxt:find("filters")) then PROBABLEFILTER=true end return end detectfilter() function AllLoop() local ok=false -- First save structure ! for i=1, segCnt do local ss=structure.GetSecondaryStructure(i) if ss~="L" then save.SaveSecondaryStructure() ok=true break end end if ok then selection.SelectAll() structure.SetSecondaryStructureSelected("L") end end function lw(minppi) local gain=true while gain do local ss=Score() if PROBABLEFILTER then behavior.SetSlowFiltersDisabled(true) end-- new BK 8/4/2013, always disable filter here structure.LocalWiggleSelected(2) --structure.WiggleSelected if PROBABLEFILTER then behavior.SetSlowFiltersDisabled(OriginalFilterSetting) end -- new BK 8/4/2013, always back to user settings local g=Score()-ss if g<minppi then gain=false end if g<0 then recentbest.Restore() end end selection.DeselectAll() -- new freeze.UnfreezeAll() -- new end --Total lws function totalLws(minlen,maxlen,minppi) local function Freeze(start, len) freeze.UnfreezeAll() selection.DeselectAll() for f=start, segCnt, len+1 do if f<= segCnt then selection.Select(f) end end freeze.FreezeSelected(true, false) end local function wiggle(start,len,minppi) if start>1 then selection.DeselectAll() selection.SelectRange(1,start-1) lw(minppi) end for i=start, segCnt, len+1 do selection.DeselectAll() local ss = i+1 local es=i+len if ss >= segCnt then ss=segCnt end if es >= segCnt then es=segCnt end selection.SelectRange(ss,es) lw(minppi) end end freeze.UnfreezeAll() selection.DeselectAll() behavior.SetClashImportance(1) save.SaveSecondaryStructure() if NotAllLoops==true then AllLoop() end local ssc=Score() p("Starting Total LWS: "..ssc) p("Lenght: "..minlen.." to "..maxlen.." ;minimum ppi: "..minppi) for l=minlen, maxlen do for s=1, l+1 do p("Len: "..l.."..start point: "..s) Freeze(s,l) local sp=Score() recentbest.Save() wiggle(s,l,minppi) local g=Score()-sp p("Gained another: "..g) end end p("Total LWS gain: "..Score()-ssc) save.LoadSecondaryStructure() end function AskOptions() local ask=dialog.CreateDialog("TotalLWS options") --repeat if timeLeft<2 then ask.minlen=dialog.AddSlider("min lenght",1,1,3,0) ask.maxlen=dialog.AddSlider("max lenght",7,3,15,0) ask.minppi=dialog.AddSlider("Min points per iteration",0.01,0.001,0.3,3) ask.runnum=dialog.AddSlider("Number runs",10,1,20,0) elseif Score()<5000 then--]] ask.minlen=dialog.AddSlider("min lenght",1,1,5,0) ask.maxlen=dialog.AddSlider("max lenght",7,5,12,0) ask.minppi=dialog.AddSlider("Min points per iteration",300,100,500,-1) ask.runnum=dialog.AddSlider("Number runs",1,1,5,0) else ask.minlen=dialog.AddSlider("min lenght",1,1,6,0) ask.maxlen=dialog.AddSlider("max lenght",7,6,12,0) ask.minppi=dialog.AddSlider("Min points per iteration",0.1,0.01,3,2) ask.runnum=dialog.AddSlider("Number runs",1,1,5,0) end ask.NotAllLoops = dialog.AddCheckbox("Keep structure",true) ask.OK = dialog.AddButton("OK",1) ask.Cancel = dialog.AddButton("Cancel",0) askresult=dialog.Show(ask) --until askresult<2 --return askresult > 0 --end if askresult > 0 then minlen=ask.minlen.value -- minimum lenggh of sgmnts - if you have done lws by 1 and 2 you may want set it to 3 maxlen=ask.maxlen.value --segCntmum lenght of sgments - more than 7 looks useless minppi=ask.minppi.value --minimum gain per local wiggle iter runnum=ask.runnum.value NotAllLoops=ask.NotAllLoops.value print("Options:minlen =",minlen,", maxlen =",maxlen,", minppi =",minppi, ", runnum =",runnum, ", NotAllLoops =",NotAllLoops) return true end return false end if AskOptions()==false then return end --M A I N ----- --AskOptions() while(true) do for i=1, runnum do print("run "..i.." / "..runnum) totalLws(minlen,maxlen,minppi) minppi=minppi*(1-(1/runnum)) -- new 01/02/2014 end end --recipe.ReportStatus() duration=(os.time()-startTime)/60 -- in minutes score=Score() Recipegain=score-startingscore RecipeReturn=Recipegain/duration*60 -- in pts/hour print("Duration = "..down(duration).." min. Return= "..down1(RecipeReturn).." pts/hour.")

Comments


Bruno Kestemont Lv 1

Pour test, apres je partage avec public.

C'est un avant-gout de JET3.

Il propose des options par defaut qui correspondent à l'etat de la protéine (au tout début, il propose des grands écarts de points).

Merci de signaler les bugs ici. Je corrigerai dans 1 semaine.

Bruno Kestemont Lv 1

Starts authomatically with the best options relative to the state of the puzzle (begin, middle, end).

But you can choose your own options.

Usage: to optimize a beautifull structure, either when starting an given structure, or when you are stucked with other recipes, or at the very end of the competition.

Decreasing but certain return: it will gain a certain percentage of points on first round, then less and less. At the beginning, this could be hundreds of points, at the very end, you will be happy with the 2 points to Join the Evolver Team (JET)!

Bruno Kestemont Lv 1

Code cleaning for better performance.
Slow filters management in order to be much faster on filtered puzzles (I think it does not change the velocity on normal puzzles: please do not be disturbed by the strange scoreline appearance: the scores and best scores are well good recorded).

Bruno Kestemont Lv 1

Slightly better for New Chapter now
Reduces minppi with successive loops (runs) in order to find latest micro points.

NOTE: This recipe is good for stabilizing a structure and/or to find latest micro points on end game. Don't expect to gain a large amount of points with this, but I promise you'll get some small gain at least. Sometimes it can help to unstiff puzzle.

SaraL Lv 1

This seems to work as good if not better than other LWS recipes. The only issue I'm having, is there is often a hangup at the end of a protein where the recipe gets stuck in a wiggle loop - keeps starting and stopping on the same segment.