Results 1 to 17 of 17
 04182012, 03:34 AM #1Member
 Join Date
 Nov 2010
 Posts
 66
 Rep Power
 0
Optimal Page Replacement Algorithm!
Hey guys,
I have searched online for an "Optimal Page Replacement" algorithm for java, and have found none. Question is.. is there any? Also, once I store the reference string into an array, how will I then "look ahead" and see which of the numbers wouldn't be used for the longest? Here is my code so far:
Java Code:package optimalpagereplacement; public class OptimalPageReplacement { public static void main(String[] args) { int[] referenceString = {7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1}; int[] pageFrames = {1, 1, 1}; for(int a=0; a<pageFrames.length; a++) { if(pageFrames[a]==1) pageFrames[a] = referenceString[0]; System.out.println(pageFrames); } } }
 04182012, 10:15 AM #2
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,421
 Blog Entries
 7
 Rep Power
 26
Re: Optimal Page Replacement Algorithm!
You do have to describe your problem in more detail (or supply a link), because I don't understand what you're talking about now ...
kind regards,
JosBuild a wall around Donald Trump; I'll pay for it.
 04182012, 01:51 PM #3Member
 Join Date
 Nov 2010
 Posts
 66
 Rep Power
 0
Re: Optimal Page Replacement Algorithm!
Sorry for not being clear.. Here is a link to its description:
Page replacement algorithm  Wikipedia, the free encyclopedia
Basically, it's a page[memory] replacement algorithm!
Thanks in advance!
 04182012, 02:29 PM #4
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,421
 Blog Entries
 7
 Rep Power
 26
Re: Optimal Page Replacement Algorithm!
Ah, ok, I know what you're talking about now; nope, such an algorithm doesn't exist because it simply can't predict the future; only for very special cases where a process is known and completely analyzed, its memory consumption is known, otherwise we have to use one of the heuristics described in the link you supplied.
kind regards,
JosBuild a wall around Donald Trump; I'll pay for it.
 04182012, 06:54 PM #5Member
 Join Date
 Nov 2010
 Posts
 66
 Rep Power
 0
Re: Optimal Page Replacement Algorithm!
I'm sorry, I don't understand what you mean by "heuristics." Is that a kind of algorithm or basic framework for implementing an optimal page replacement system?
 04192012, 04:19 PM #6Member
 Join Date
 Nov 2010
 Posts
 66
 Rep Power
 0
Re: Optimal Page Replacement Algorithm!
Bump!
 04192012, 04:22 PM #7
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,421
 Blog Entries
 7
 Rep Power
 26
Re: Optimal Page Replacement Algorithm!
A heuristic is an algoritm/strategy that doesn't necessarily produces an optimal solution but it produces a good one most of the time; and it is generally faster than an algorithm that always produces an optimal solution.
kind regards,
JosBuild a wall around Donald Trump; I'll pay for it.
 04192012, 07:00 PM #8Member
 Join Date
 Nov 2010
 Posts
 66
 Rep Power
 0
Re: Optimal Page Replacement Algorithm!
So, what would be the heuristic for optimal page replacement?
 04192012, 07:41 PM #9
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,421
 Blog Entries
 7
 Rep Power
 26
 04192012, 09:24 PM #10Senior Member
 Join Date
 Apr 2012
 Location
 New York State of Confusion, USA
 Posts
 137
 Blog Entries
 1
 Rep Power
 0
Re: Optimal Page Replacement Algorithm!
Jos, I've been following this thread, curious to see where it went.
It seems Asvin isn't grasping, as you do, that there is no ONE SINGLE optimal solution for his page replacement quandary. He doesn't seem to grasp that the efficacy of algorithms and heuristics depends highly on the environment and constraints under which they are applied. An optimal algorithm for one set of constraints won't be optimal for another set of constraints.
Optimal in what regard? Everything we do has tradeoffs, like memory vs. speed/processor consumption as applied to sorting or traversal problems. An optimal solution in a constrained memory environment will not be give optimal speed or minimal processor consumption.
When I am asked to provide an optimal solution to a problem, I immediately start asking questions in order to bound what the person making the request means by "optimal".
So, forgive my intrusion as I'm sure you are aware of these things. This was intended for Asvin's benefit. Asvin clearly needs to do a bit of researching rather than vainly hoping for a cookie cutter answer that does not exist.
...crawling back under my rock...
 04192012, 09:55 PM #11
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,421
 Blog Entries
 7
 Rep Power
 26
 04202012, 03:53 AM #12Member
 Join Date
 Nov 2010
 Posts
 66
 Rep Power
 0
Re: Optimal Page Replacement Algorithm!
I guess my question is malformed! The assignment has nothing to do with memory, processor speed, or processor consumption. I just wanted to know if there is an algorithm that looks at the first value of the reference string, adds it to the page table.. then looks at the second, adds it to the page table.. then looks at the third, adds it to the page table.. the page table is a threeelement sized array! So, after the first three reference strings are added, the program needs to see which one will not be used for the longest time. Whichever one that is, the program should figure it out and replace it! Hope I am being clear!
 04202012, 07:35 PM #13Member
 Join Date
 Nov 2010
 Posts
 66
 Rep Power
 0
Re: Optimal Page Replacement Algorithm!
Bump!
 04202012, 07:38 PM #14
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,421
 Blog Entries
 7
 Rep Power
 26
 04202012, 07:39 PM #15Senior Member
 Join Date
 Apr 2012
 Location
 New York State of Confusion, USA
 Posts
 137
 Blog Entries
 1
 Rep Power
 0
Re: Optimal Page Replacement Algorithm!
A better bump would have been one where you demonstrated putting some effort into solving this rather than waiting for us to hand you a solution.
So, after the first three reference strings are added, the program needs to see which one will not be used for the longest time. Whichever one that is, the program should figure it out and replace it!
 04202012, 07:42 PM #16Senior Member
 Join Date
 Apr 2012
 Location
 New York State of Confusion, USA
 Posts
 137
 Blog Entries
 1
 Rep Power
 0
Re: Optimal Page Replacement Algorithm!
 04202012, 08:13 PM #17Member
 Join Date
 Nov 2010
 Posts
 66
 Rep Power
 0
Similar Threads

$1500 for Optimal Job Scheduling Algorithm
By bart_bl in forum Jobs OfferedReplies: 0Last Post: 05042011, 04:21 PM 
replacement for complicated if else?
By TopNFalvors in forum New To JavaReplies: 12Last Post: 04092011, 08:05 PM 
String Replacement
By pr3diker in forum Java AppletsReplies: 7Last Post: 12162010, 01:04 PM 
String replacement...
By diskhub in forum New To JavaReplies: 6Last Post: 05192010, 05:20 AM 
Be Optimal!  DNA's Vehicle Routing Initiative 2008
By dnaevolutions in forum Java SoftwareReplies: 0Last Post: 10052008, 02:19 AM
Bookmarks