All versions of differential evolution algorithm [closed] - evolutionary-algorithm

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
explain all updates in the basic algorithm of differential evolution. i am not able to find all versions of this algorithm. explain all versions of this algorithm as a survey and i am not clearly understand the theory behind this algorithm as given in the Wikipedia. Wikipedia also define only basic algorithm of differential evolution but i want to all updates of this algorithm

For complete survey in Differential Evolution, I suggest you the paper entitled Differential Evolution: A Survey of the State-of-the-Art but the brief explanation is :
DE has 2 basic crossover and 5 basic mutation operators, so we have 2*5=10 basic DE variants.
Two crossover operators are Exponential and Binomial.
Exponential Crossover:
D is problem space dimensionality, n is randomly chosen from [1,D], Cr is crossover rate and L is drawn from [1,D] according to above pseudocode.
Binomial Crossover:
j is refer to j-th dimension, i is vector number and G is generation number and jrand is randomly chosen index from [1,D].
Five mutation operators are DE/rand/1 , DE/best/1 , DE/target-to-best/1 , DE/best/2 and DE/rand/2.
DE/rand/1: V(i)=X(r1)+F*(X(r2)-X(r3))
DE/best/1: V(i)=X(best)+F*(X(r1)-X(r2))
DE/target-to-best/1: V(i)=X(i)+F*(X(best)-X(i))+F*(X(r1)-X(r2))
DE/best/2: V(i)=X(best)+F*(X(r1)-X(r2))+F*(X(r3)-X(r4))
DE/rand/2: V(i)=X(r1)+F*(X(r2)-X(r3))+F*(x(r4)-X(r5))
V(i) is donor(mutant) vector for target vector X(i), F is difference vector's scale factor, r1,r2,r3,r4,r5 are mutually exclusive, randomly chosen from [1,NP] and differ from i, best is the fittest vector's index in the current population, finally NP is population size.
These are all of things you can know about basic variants of DE.
DE also has many variants for many purposes which has explained in the mentioned paper.

Related

Neural network for AI playing Connect Four: how to encode inputs and outputs, and what kind of NN setup? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
Trying to understand how to build and train neural network based AI for games, and struggling to get some details straight.
Not even concerned yet with whether to use TensorFlow or something else or build my own. First I'm trying to grasp some basics such as what ranges to use, e.g. inputs between -1 and 1 or between 0 and 1, or how to represent input game situations and output moves.
Suppose I'm building a neural network to play Connect Four. Given a game situation, the AI is to generate an 'optimal move'. Let's say the optimal move is the move with the highest probability of eventually winning the game, assuming a reasonably smart opponent.
I guess the input would be 7 columns * 6 rows = 42 input neurons, each containing a value that represents either my color, or the opponent's color, or empty.
How do I encode this? Does it make a difference whether I use:
0 = empty, 1 = my piece, 2 = opponent's piece
0 = empty, 0.5 = my piece, 1 = opponent's piece
0 = empty, 1 = my piece, -1 = opponent's piece
Or should I even use two times 42 = 84 input neurons, all binary/boolean, where 0=empty, 1s in the first 42 neurons represent my pieces, and 1s in the second 42 neurons represent the opponent's pieces?
What does the output look like? 7 neurons that each represent one column, getting an output value in the 0..1 range, and the AI's move would be the one with the highest value? Or just one output value ranging from 0 to 1, where roughly each 1/7th of the interval represents a particular column?
Also, how should I design my neural network, how many hidden layers? Classification or regression? Sigmoid or Relu or tanh as activation function?
Intuitively, based on my limited experience with neural networks, I would say 2 or 3 hidden layers, each with two times the number of input neurons. No idea about the other considerations, I would just make stabs in the dark and trial and error.
Any feedback or suggestions to get me in the right direction?
If you have not yet delved into AI gameplay, then might I suggest OpenAI Gym as a starting place?
I believe starting with that foundation will allow you to 1) start building and learning with active participation right away, and 2) answer a lot of the foundational 'what-should-I-do?' questions that you have now - or at least at the time of asking this question, and then come back with the 'How-do-I' questions that we can really help you with here

Example of Polynomial time algorithm [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
What is the example of polynomial time algorithm
Is polynomial time algorithm fastest?
Suppose 100 elements in array , then how can I decide algorithm is polynomial time?
Q: What is the example of polynomial time algorithm?
for (i = 0; i < n; ++i)
printf("%d", i);
This is a linear algorithm, and linear belongs to polynomial class.
Q: Is polynomial time algorithm fastest?
No, logarithmic and constant-time algorithms are asymptotically faster than polynomial algorithms.
Q: Suppose 100 elements in array , then how can I decide algorithm is
polynomial time?
You haven't specified any algorithm here, just the data structure (array with 100 elements). However, to determine whether algorithm is polynomial time or not, you should find big-o for that algorithm. If it is O(n^k), then it is polynomial time. Read more here and here.

How to visualize (make plot) of regression output against categorical input variable? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 6 years ago.
Improve this question
I am doing linear regression with multiple variables. In my data I have n = 143 features and m = 13000 training examples. Some of my features are continuous (ordinal) variables (area, year, number of rooms). But I also have categorical variables (district, color, type). For now I visualized some of my feautures against predicted price. For example here is the plot of area against predicted price:
Since area is continuous ordinal variable I had no troubles visualizing the data. But now I wanted to somehow visualize dependency of my categorical variables (such as district) on predicted price.
For categorical variables I used one-hot (dummy) encoding.
For example that kind of data:
turned to this format:
If I were using ordinal encoding for districts this way:
DistrictA - 1
DistrictB - 2
DistrictC - 3
DistrictD - 4
DistrictE - 5
I would plot this values against predicted price pretty easy by putting 1-5 to X axis and price to Y axis.
But I used dummy coding and now I do not know how can I show (visualize) dependency between price and categorical variable 'District' represented as series of zeros and ones.
How can I make a plot showing a regression line of districts against predicted price in case of using dummy coding?
If you just want to know how much the different districts influence your prediction you can take a look at the trained coefficients directly. A high theta indicates that that district increases the price.
If you want to plot this, one possible way is to make a scatter plot with the x coordinate depending on which district is set.
Something like this (untested):
plot.scatter(0, predict(data["DistrictA"==1]))
plot.scatter(1, predict(data["DistrictB"==1]))
And so on.
(Possibly you need to provide an x vector of the same size as the filtered data vector.)
It looks even better if you can add a slight random perturbation to the x coordinate.

Array search NP complete [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 7 years ago.
Improve this question
Given an unsorted array of size n, it's obvious that finding whether an element exists in the array takes O(n) time.
If we let m = log n then it takes O(2^m) time.
Notice that if the array is sorted, a binary search actually takes O(m) time (which is polynomial) but the binary search cannot apply to an unsorted array.
Is it possible to prove that the problem to find an element in an array (yes or no) is NP complete in terms of m. What problem should I reduce from and how to reduce?
Any idea would be appreciated.
EDIT:
My description above probably did not express clearly what I was trying to say.
Let's reword the problem in the following way.
We have an oracle, which is a binary tree of height h with each node having random values. I.E. a tree that DOES NOT have the property that all values in the left subtree of a node must be smaller than the value in the node or all values in the right subtree of a node must be greater than the value in the node. However all nodes in the oracle tree are guaranteed to have value between 0 and 2^h-1.
The input is a number to be searched. The input is guaranteed to have value between 0 and 2^h-1. (The input has h bits)
(Let's say we are searching through the same array every time and hence we have the same oracle every time so the tree is not a part of input.)
The output is YES or NO, indicating whether the input is in a node of the tree or not.
Question: whether this problem is NP complete or not in terms of h.
This problem is NP because if a path to the YES node in the tree is given it can be verified in O(h) time.
(Note that if the oracle tree has the property that left subtree of a node is less than the node and right subtree of a node is greater than the node then the problem is NOT NP complete because binary search can be applied.)
Finding an element in an array is NOT NP-complete as it can be done in linear time. (Assuming P ≠ NP)
In fact, the naive brute-force search algorithm you mentioned in your question is a linear time algorithm!
When we are talking about the complexity of a computational problem, we always measure the time with respect to the size of the input. You claimed the input size of our algorithm is m = log(n), but in our case, the size of our input is determined by the number of elements in the array, which is n.
For your reference, testing whether a given number n is a prime number is an example computational problem that takes input of size log(n). The input of the problem is n, and it is of size log(n) because we need to use log(n) bits to represent n in binary form.
Update
Deterministic search algorithm requires Ω(n) time for unsorted array.
Any search algorithm must read through the entire input (i.e. the n entries of the array). We are going to prove this by contradiction.
Suppose there is a search algorithm that does not read all n input entries, then there is an entry that is not read by this algorithm. you can then construct a case that the search item is at the entry that is not read by this hypothetical algorithm, this violates the correctness of the algorithm. Hence such algorithm does not exist.

What machine learning algorithm for this simple optimisation? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'll formulate a simple problem that I'd like to solve with machine learning (in R or similar platforms): my algorithm takes 3 parameters (a,b,c), and returns a score s in range [0,1]. The parameters are all categorical: a has 3 options, b has 4, and c has 10.
Therefore my dataset has 3 * 4 * 10 = 120 cases.
High scores are desirable (close to 1), low scores are not (close to 0).
Let's treat the algorihm as a black box, taking a,b,c and returning a s.
The dataset looks like this:
a, b, c, s
------------------
a1, b1, c1, 0.223
a1, b1, c2, 0.454
...
If I plot the density of the s for each parameter, I get very wide distributions, in which some cases perform very well (s > .8 ), others badly (s < .2 ).
If I look at the cases where s is very high, I can't see any clear pattern.
Parameter values that overall perform badly can perform very well in combination with specific parameters, and vice versa.
To measure how well a specific value performs (e.g. a1), I compute the median:
median( mydataset[ a == a1]$s )
For example, median(a1)=.5, median(b3)=.9, but when I combine them, I get a lower result s(a_1,b_3)= .3.
On the other hand, median(a2)=.3, median(b1)=.4, but s(a2,b1)= .7.
Given that there aren't parameter values that perform always well, I guess I should look for combinations (of 2 parameters) that seem to perform well together, in a statistically significant way (i.e. excluding outliers that happen to have very high scores).
In other words, I want to obtain a policy to make the optimal parameter choice, e.g. the best performing combinations are (a1,b3), (a2,b1), etc.
Now, I guess that this is an optimisation problem that can be solved using machine learning.
What standard techniques would you recommend in this context?
EDIT: somebody suggested a linear programming solution with glpk, but I don't understand how to apply linear programming to this problem.
The most standard technique for this question is Linear Regression. You may predict the value for specific parameters; in more general - to get the function that on your 3 parameters gives you maximum value