Monday, October 22, 2018

Image convert to Base64 (from file to string)


Demo:


Thursday, March 1, 2018

Random Restart Hill Climbing For N Queen

Hill climbing is an optimization technique which is a local search algorithm. It is an algorithm that starts with a random solution to a problem. By changing a single element of the solution it attempts to find a better solution. Hill climbing is sometimes called greedy local search because it grabs a good neighbor state without thinking ahead about where to go next.
To find a global maxima random restart hill climbing is used. Random restart hill climbing is a series of hill climbing searches. From randomly generated initial state until a goal is found.

board setup: n queens, one queen per column
successors : The successors of a state are all possible states generated by moving a single queen to another square in the same column. Meaning, there are n queens on the board and each queen can move to n-1 defined positions. So, each state has n*(n-1) successors.
heuristic cost function h : h is the number of pairs of queens that are attacking each other
Basic hill climbing creates a random state of the board. Then it finds the highest value successor of the current state(for n queen the lowest valued successor), which is called the neighbor. If the heuristic cost value of the neighbor is less than the heuristic cost value of the current state, then the neighbor becomes the current state. If not then the current solution is the minima of the current hill.
What random restart does is, it runs the hill climbing until the global minima is found. In each hill climbing, it creates a new initial state of the board then runs the hill climbing algorithm to find the minima of the hill. It stops when the global minima is reached.
h(board)
1  returns the number of attacking pair on board

highest_valued_successor_of_current(current)
1  best_h  
2  best_successor  NULL
3  while(new successor can be created)
4      successor  new_successor(current)
5      if h(successor) < best_h 
6           best_h  h(successor)
7           best_successor  successor
8  return successor


hill_climbing()
1  current  A random state of the board
2  while(1)
3      neighbor  highest_valued_successor_of_current(current)
4      if h(neighbor) >= h(current) 
5           return current
6      neighbor  current

random_restart_hill_climbing()
1  final_h  
2  best_board  NULL
3  while(final_h != 0)
4       result  hill_climbing()
5       now_h  h(result)
6       if final_h > now_h
7            final_h  now_h
8            best_board  result
9  return best_board

Saturday, January 27, 2018

Use of CFGs for Parsing OPEN

We can think of using CFGs to detect various language constructs in the token streams freed from simple
syntactic and semantic errors, as it is easier to describe the constructs with CFGs. But CFGs are hard to
apply practically. In this session we first exercise on simpler implementations of CFGs, and then
implement the FIRST and FOLLOW functions that facilitate efficient parsing algorithms for practical
problems.

Session 5 by Nafis Islam on Scribd





Friday, January 5, 2018

Detecting Simple Syntax Errors

Syntax errors are very common in source programs. Suppose, a given C source program has been scanned, filtered, lexically analyzed and tokenized as that were done in earlier sessions. In addition, line numbers have been assigned to the source code lines for generating proper error messages. As the first step to Syntax Analysis, we now perform detection of simple syntax errors like duplication of tokens except parentheses or braces, Unbalanced braces or parentheses problem, unmatched ‘else’ problem, etc


Session 4 by Nafis Islam on Scribd




Symbol Table Generation

A given C source program has been scanned, filtered and then lexically analyzed as it was done in Session 2. We have all the lexemes marked as different types of tokens like keywords, identifiers, operators, separators, parentheses, numbers, etc. We now get corrected the unknown lexemes first, and then generate a Symbol Table describing the features of the identifiers. Finally, we generate a modified token stream in accordance with the Symbol Table for processing by the next phase, that is, Syntactic Analysis


Session 3 by Nafis Islam on Scribd


Lexical Analysis

we have a C source program scanned and filtered as it was done in Session 1. We now take that modified file as input, and separate the lexemes first. We further recognize and mark the lexemes as different types of tokens like keywords, identifiers, operators, separators, parenthesis, numbers, etc.

Session 2 by Nafis Islam on Scribd


Thursday, January 4, 2018

Scanning and Filtering a Source Program

You are given a C source program with single and multiple line comments. As the first step toward compilation you need to remove the comments and white space (extra spaces, tabs and newline characters). Develop a program that takes as input file the given source program and produces a filtered file as stated above. The program must also display both the files.

Session 1 by Nafis Islam on Scribd




Football Player Transfer Prediction

Football Player Transfer Prediction Using Different Classifiers Project Report :  Football Player Transfer Prediction Report ...