I am writing some genetic algorithms in python.  Currently I was looking at a book that has java code, so but eventually I am trying to write my own Adaptive Genetic algorithm to optimize neural network parameters and layers, and all my neural network code is in python using keras...so I am just writing my own python code that is equivalent to the books java code.  The problem I am having with the way I have it set up currently, is that the constructor always initializes the object to the constructor in the first statement.   From what I have seen from other questions similar to this, you can use classmethods to do this...and you call also do something with ...isinstanceOf method...and you can do something with init method *args and **kwargs...and I thought you could do something with NoneType parameters which is what I am trying to do...but I have been messing with it on and off and cannot seem to get it to work without adding additional boolean arguments which I would prefer not to do.  What are peoples preferred methods to solving the multiple constructor problem, and can you do it the way I am trying to?  An example of where I am trying to use multiple constructors.  class Individual(object):    #Object Initialisation--&gt;Generally called a constructor #In python, a variable prefixed with _ is effectively private  def __init__(self, chromosome, chromosomeLength, bool1):     if(chromosomeLength is not None and bool1==False):         self.chromosomeLength = chromosomeLength         self.fitness = -100         self.chromosome = np.empty(chromosomeLength)         for gene in range(self.chromosomeLength):                 if(0.5 &lt; np.random.randint(2)):                     #self.setGene(gene,1)                     #cls.chromosome[gene] = 1                     self.chromosome[gene] = 1                 else:                     #self.setGene(gene,0)                     #cls.chromosome[gene] = 0                     self.chromosome[gene] =0      elif(chromosome is not None and bool1 ==True):          self.chromosome = chromosome         self.fitness = -1         print ("All variable initialized")   Thanks,  Matt
I can't find a definitive answer for this. As far as I know, you can't have multiple __init__ functions in a Python class. So how do I solve this problem? Suppose I have a class called Cheese with the number_of_holes property. How can I have two ways of creating cheese objects...  One that takes a number of holes like this: parmesan = Cheese(num_holes = 15) And one that takes no arguments and just randomizes the number_of_holes property: gouda = Cheese()  I can think of only one way to do this, but this seems clunky: class Cheese():     def __init__(self, num_holes = 0):         if (num_holes == 0):             # Randomize number_of_holes         else:             number_of_holes = num_holes  What do you say? Is there another way?
Getting Joker from the existing groups in Rummikub I have a group of tiles made up of 3 fours and a joker:     4 4 4 Joker   Now, if a player removes the joker, do they have to replace it with another 4? Integral $\int\csc^3{x} \ dx$ I found these step which explain how to integrate $\csc^3{x} \ dx$. I understand everything, except the step I highlighted below.  How did we go from: $$\int\frac{\csc^2 x - \csc x \cot x}{\csc x - \cot x}\,dx%$$ to  $$\int \frac{d(-\cot x + \csc x)}{-\cot x + \csc x} \quad?$$  Thank you for your time! $$ \int \csc^3 x\,dx = \int\csc^2x \csc x\,dx$$ To integrate by parts, let $dv = \csc^2x$ and $u=\csc x$. Then $v=-\cot x$ and $du = -\cot x \csc x \,dx$. Integrating by parts, we have: $$\begin{align*} \int\csc^2 x \csc x \,dx &amp;= -\cot x \csc x - \int(-\cot x)(-\cot x\csc x\,dx)\\ &amp;= -\cot x \csc x - \int \cot^2 x \csc x\,dx\\ &amp;= -\cot x\csc x - \int(\csc^2x - 1)\csc x\,dx &amp;\text{(since }\cot^2 x = \csc^2-1\text{)}\\ &amp;= -\cot x \csc x - \int(\csc^3 x - \csc x)\,dx\\ &amp;= -\cot x\csc x - \int\csc^3 x\,dx + \int \csc x\,dx \end{align*}$$ From $$\int \csc^3 x\,dx = -\cot x\csc x - \int\csc^3 x\,dx + \int \csc x\,dx$$ we obtain $$\begin{align*} \int\csc^3x\,dx + \int\csc^3 x\,dx &amp;= -\cot x \csc x + \int\csc x\,dx\\ 2\int\csc^3 x\,dx &amp;= -\cot x\csc x + \int\csc x\,dx\\ \int\csc^3x\,dx &amp;= -\frac{1}{2}\cot x\csc x + \frac{1}{2}\int\csc x\,dx\\ &amp;=-\frac{1}{2}\cot x\csc x + \frac{1}{2}\int\frac{\csc x(\csc x - \cot x)}{\csc x - \cot x}\,dx\\ &amp;= -\frac{1}{2}\cot x \csc x + \frac{1}{2}\int\frac{\csc^2 x - \csc x\cot x}{\csc x - \cot x}\,dx\\ &amp;= -\frac{1}{2}\cot x \csc x + \frac{1}{2}\int\frac{d(-\cot x+\csc x)}{-\cot x +\csc x}\\ &amp;= -\frac{1}{2}\cot x\csc x + \frac{1}{2}\ln|\csc x - \cot x|+ C \end{align*}$$ What's the best way of replacing a plug or switch in a house with aluminum wiring? How to "shuffle" an array? Bash shell script output alignment My script:  date echo -e "${YELLOW}Network check${NC}\n\n"  while read hostname do  ping -c 1 "$hostname" &gt; /dev/null 2&gt;&amp;1 &amp;&amp;  echo -e "Network $hostname : ${GREEN}Online${NC}" || echo -e "${GRAY}Network $hostname${NC} : ${RED}Offline${NC}"  done &lt; list.txt         sleep 30 clear done   Is outputting info like this:    Network 10.x.xx.xxx : Online    Network 10.x.xx.xxx : Offline    Network 10.x.xx.xxx : Offline    Network 10.x.xx.xxx : Offline    Network 10.x.xx.x : Online    Network 139.xxx.x.x : Online    Network 208.xx.xxx.xxx : Online    Network 193.xxx.xxx.x : Online   which I'd like to clean up to get something like this:    Network 10.x.xx.xxx       : Online   Network 10.x.xx.xxx       : Offline    Network 10.x.xx.xxx       : Offline     Network 10.x.xx.x         : Online     Network 139.xxx.x.x       : Online   Network 208.xx.xxx.xxx    : Online     Network 193.xxx.xxx.x     : Online   Network 193.xxx.xxx.xxx   : Offline I have a problem when a lot of figures are in question. Some figures tend to "fly around", that is, be a paragraph below, although I placed them before that paragraph. I use code:  \begin{figure}[ht] \begin{center} \advance\leftskip-3cm \advance\rightskip-3cm \includegraphics[keepaspectratio=true,scale=0.6]{slike/visina8} \caption{} \label{visina8} \end{center}\end{figure}   to place my figures. How can I tell latex I REALLY want the figure in that specific place, no matter how much whitespace will be left? Is "princessship" a real word? Are there any other words which have the same letter 3 times consecutively? Automate keystrokes in Windows 7 64-bit I need to automate the pressing of the  key then pressing 5 digits then press  in Windows 7 64-bit.  I have an app that comes up on the screen and I need the "script" to press the keys.  I don't even need mouse support.  What can I use to do this?  Any examples or links? Why is the charge naming convention wrong? I recently came to know about the Conventional Current vs. Electron Flow issue. Doing some search I found that the reason for this is that Benjamin Franklin made a mistake when naming positive and negative charges. There is even this little comic about that   My question is, how can a naming convention be wrong? Perhaps I don't understand what is the actual mistake here, I don't know. But I don't see how a naming convention could be wrong or right. There is no right and wrong about that. It could've been any other name, like charge A and charge B.  I'll appreciate anyone can help me understand what is wrong in all this. How to install Hp laser jet 1020 plus printer? How to automount NTFS partitions? I have two NTFS partitions, and I don't want to mount them manually every-time I start Ubuntu.   How can I do this?  Is there a tool or a code to use?   If so, is it safe to automount? specially when they are being used by another OS? Linear regression prediction interval As things stand, will House Stark go extinct? According to the family tree in A World of Ice and Fire Ned Stark's children are in fact the only surviving Starks. And as of S06E09;      Bran is the only legitimate, male Stark.   In the Season Six Finale it is revealed that;      Jon is in fact the Son of Lyanna Stark and most likely, Rhaegar Targaryen.   This means that if Jon was legitimised and there was record of his birth in the Citadel;      He would become a Targaryen.   So I guess my big question is: Can Bran father children? I find it to be quite an important issue considering House Stark's long term survival depends on it.  In season 4 (I can't remember which episode) Locke Bolton gives Bran a cut on the leg to confirm his identity. Bran reacts only with fear and not pain, indicating that he has no feeling below his waist.  Does this mean that he wouldn't be able to...get it up? And if so, why hasn't the show addressed House Stark's impending doom? Finding minimum-area-rectangle for given points? As you see in the figure,  the question is:    How to find the minimum-area-rectangle (MAR) fitted on the given points?    and a supporting question is:    Is there any analytical solution for the problem?    (A development of the question will be to fit a box (3D) to a cluster of points in a 3D point cloud.)  As a first stage I propose to find the convex-hull for the points which reforms the problem (by removing those points are not involved in the solution) to: fitting a MAR to a polygon.  The required method will provide X (center of rectangle), D (two dimensions) and A (angle).      My proposal for solution:     Find the centroid of the polygon (see )   [S] Fit a simple fitted rectangle i.e., parallel to the axes X and Y   you may use minmax function for X and Y of the given points (e.g., polygon's vertices)  Store the area of the fitted rectangle Rotate the polygon about the centroid by e.g., 1 degree Repeat from [S] until a full rotation done Report the angle of the minimum area as the result   It looks to me promising, however the following problems exist:   choose of a good resolution for the angle change could be challenging, the computation cost is high, the solution is not analytical but experimental. How do I fix the left mouse opening the menu instead of breaking blocks? Why are there two tensions on my free body diagram? How long can I run a water pump which requires 12V and 50W from a 12V, 40Ah, 400A car battery?  Can you explain how this was calculated? "With who" vs. "with whom" Is this correct?     The person with whom I'm doing the project should be here soon.   If it is, is with always a dative preposition (like mit in German)? Historical flight data outside of the USA? Matrix given by $a_{ij} = 1/(i+j)$ is non-singular.