text:
# Homework Help: Greens theorem-maximises area

1. May 5, 2012

### gtfitzpatrick

1. The problem statement, all variables and given/known data
find a simple closed curve with counter-clockwise orientation that maximises the value of $\oint (cos x^2 + 4yx^2) dx + (4x-xy^2)dy$

2. Relevant equations

3. The attempt at a solution

from greens theorem $\oint Pdx+qdy = \int\int \frac{\partial q}{\partial x} - \frac{\partial p}{\partial y} dA$

so$\int\int_{D} 4-y^2-4x^2 dxdy$

the integrand is positive everywher inside the elipse,zero on the ellipse and negative outside. so to maximise the integral C should be the oriented boundary of the ellipse oriented in the counter-clockwise direction.

x=2cosr y=sinr dx=rdr

sooo i think the maximum value is $\int^{2\pi}_{0} \int^{2}_{0} 4 - sin^2 r - 16 cos ^2 r drd\theta$

which i the simplify.
anyone know if i'm on the right lines here...

2. May 5, 2012

### tiny-tim

hi gtfitzpatrick!
yeees (except you've missed out an "r", and the limits are wrong) …

but the question only asks for the curve

3. May 5, 2012

### gtfitzpatrick

Hi tiny-tim,
thanks for that, i see the missed r thanks. which of my limits are wrong, should my limit be 0 to 4?

4. May 5, 2012

### tiny-tim

it's an ellipse

shouldn't r depend on θ ?

5. May 5, 2012

### gtfitzpatrick

ah yes i see, i had set my limits as if it was a circle. but as you say it is an ellipse. I know the question doesnt ask for it but, i'll have to think about it! cant see straight off what to set my limits to..

6. Jul 23, 2012

### gtfitzpatrick

just reading over this again. So the question only asks for the curve so $\int\int_{D} 4-y^2-4x^2 dxdy$ so the curve C = to the ellipse $4-y^2-4x^2$ this is the curve that maximises the area right but how to i explain it better than that?

7. Jul 23, 2012

### tiny-tim

if you want to find the region D over which ∫∫D f(x,y) dxdy is maximised,

then if you choose D to be the region in which f(x,y) ≥ 0, then clearly either enlarging or dikminishing D will decrease the integral

8. Jul 23, 2012

### LCKurtz

But that isn't the equation of the ellipse because there is no = sign.

9. Aug 20, 2012

### gtfitzpatrick

getting back to this...
So my equation for an ellipse is$\frac{x^2}{1^2} + \frac{y^2}{2^2} = 1$ so parametizing this I get x=cos$\theta$ and y=2sin$\theta$ and from green the area is $\frac{1}{2}\int^{2\pi}_{0} cos\theta(2cos\theta)-sin\theta(-2sin\theta d\theta$ = $\frac{1}{2}\int^{2\pi}_{0} 2(1) d\theta$ = $2\pi$

Last edited: Aug 20, 2012
10. Aug 20, 2012

### tiny-tim

hi gtfitzpatrick!

(ah! you corrected the "2" ! )

to check: put z = 2x, and then halve the area of z2 + y2 = 4


text:
# Source

How you write your code is probably different for everyone, but over the years, I have developed a system that has proved itself useful for a couple of years now and makes things super simple for organizing. Here is my home directory source tree setup with some short descriptions of each location:

/Users/addlema
├── .sh.d
├── src
│   ├── git.worksite.com
│   └── github.com
├── .gitconfig
├── .gitconfig-personal
├── .gitconfig-work

Overall, my pattern has been to keep work in the git.worksite.com and my public projects in github.com. Pesonal projects are also kept in github.com but that is a preference of mine as I am not writing any software that is making any money. If that were the case, I would be using a separate computer and not the company’s property to create the product.

• ##### Mkdocs

If you are okay with MarkDown, writing software, and documentation, then I highly suggest using MkDocs. This Python based project starts with a mkdocs.yml file to describe the project, navigation, options, theme, and plugins.

• ##### Gitconfig

Gitconfig is a interesting file when you are able to use an if statement based on the directory of a project. Below is my tree for projects that both define personal and professional configurations.

format: plain


text:
+0

# Integrate the inverse sine of x ---- by parts ???

0
1
1357
3
+95

I have to integrate the inverse sine of x but I have to do it by parts ???

How do I do that?

Oct 18, 2014

#1
+114493
+15

the formula is

$$\\\boxed{\int f(x)g'(x)\;dx=f(x)g(x)-\int f'(x)g(x)\;dx}\\\\ or\\\\ \boxed{\int uv'\;dx=uv-\int u'v\;dx}\\\\$$

$$\\\int sin^{-1}\;dx=\int sin^{-1}*1\;dx\\ let\;u=sin^{-1}\;\;and\;\;v'=1\\\\ u=sin^{-1}x\\ x=sin\;u\\ \frac{dx}{du}=cos\;u\\ \frac{du}{dx}=\frac{1}{cos\;u}\\ \frac{du}{dx}=\frac{1}{\sqrt{cos^2 u}}\\ \frac{du}{dx}=\frac{1}{\sqrt{1-sin^2 u}}\\ \frac{du}{dx}=\frac{1}{\sqrt{1-x^2}}\\$$

$$so\\ u=sin^{-1}x\\ u'=\frac{1}{\sqrt{1-x^2}}\\ v'=1\\ v=x\\\\ \int sin^{-1}x\;dx\\ =\int sin^{-1}*1\;dx\\ =uv-\int u'v\;dx\\ =sin^{-1}x*x-\int \frac{x}{\sqrt{1-x^2}}\;dx\\ =xsin^{-1}x-\int \frac{x}{\sqrt{1-x^2}}\;dx\\\\ let\;\;t=1-x^2\\\\ \frac{dt}{dx}=-2x\\\\ dx=\frac{dt}{-2x}=\frac{dt}{-2\sqrt{1-t}}\\\\ \sqrt{1-t}=x\\\\$$

$$so\\\\ xsin^{-1}x-\int \frac{x}{\sqrt{1-x^2}}\;dx\\\\ =xsin^{-1}x-\int \frac{\sqrt{1-t}}{\sqrt{t}}\;\frac{dt}{-2\sqrt{1-t}}\\\\ =xsin^{-1}x-\int \frac{\sqrt{1-t}}{\sqrt{t}(-2\sqrt{1-t})}\;dt\\\\ =xsin^{-1}x-\int \frac{\sqrt{1-t}}{-2\sqrt{t}\sqrt{1-t}}\;dt\\\\ =xsin^{-1}x-\int \frac{1}{-2\sqrt{t}}\;dt\\\\ =xsin^{-1}x+\frac{1}{2}\int t^{-0.5}\;dt\\\\ =xsin^{-1}x+\frac{1}{2}\times \frac{t^{0.5}}{0.5}+c\\\\ =xsin^{-1}x+ \sqrt{t}+c\\\\ =xsin^{-1}x+ \sqrt{1-x^2}+c\\\\$$

Oct 18, 2014

#1
+114493
+15

the formula is

$$\\\boxed{\int f(x)g'(x)\;dx=f(x)g(x)-\int f'(x)g(x)\;dx}\\\\ or\\\\ \boxed{\int uv'\;dx=uv-\int u'v\;dx}\\\\$$

$$\\\int sin^{-1}\;dx=\int sin^{-1}*1\;dx\\ let\;u=sin^{-1}\;\;and\;\;v'=1\\\\ u=sin^{-1}x\\ x=sin\;u\\ \frac{dx}{du}=cos\;u\\ \frac{du}{dx}=\frac{1}{cos\;u}\\ \frac{du}{dx}=\frac{1}{\sqrt{cos^2 u}}\\ \frac{du}{dx}=\frac{1}{\sqrt{1-sin^2 u}}\\ \frac{du}{dx}=\frac{1}{\sqrt{1-x^2}}\\$$

$$so\\ u=sin^{-1}x\\ u'=\frac{1}{\sqrt{1-x^2}}\\ v'=1\\ v=x\\\\ \int sin^{-1}x\;dx\\ =\int sin^{-1}*1\;dx\\ =uv-\int u'v\;dx\\ =sin^{-1}x*x-\int \frac{x}{\sqrt{1-x^2}}\;dx\\ =xsin^{-1}x-\int \frac{x}{\sqrt{1-x^2}}\;dx\\\\ let\;\;t=1-x^2\\\\ \frac{dt}{dx}=-2x\\\\ dx=\frac{dt}{-2x}=\frac{dt}{-2\sqrt{1-t}}\\\\ \sqrt{1-t}=x\\\\$$

$$so\\\\ xsin^{-1}x-\int \frac{x}{\sqrt{1-x^2}}\;dx\\\\ =xsin^{-1}x-\int \frac{\sqrt{1-t}}{\sqrt{t}}\;\frac{dt}{-2\sqrt{1-t}}\\\\ =xsin^{-1}x-\int \frac{\sqrt{1-t}}{\sqrt{t}(-2\sqrt{1-t})}\;dt\\\\ =xsin^{-1}x-\int \frac{\sqrt{1-t}}{-2\sqrt{t}\sqrt{1-t}}\;dt\\\\ =xsin^{-1}x-\int \frac{1}{-2\sqrt{t}}\;dt\\\\ =xsin^{-1}x+\frac{1}{2}\int t^{-0.5}\;dt\\\\ =xsin^{-1}x+\frac{1}{2}\times \frac{t^{0.5}}{0.5}+c\\\\ =xsin^{-1}x+ \sqrt{t}+c\\\\ =xsin^{-1}x+ \sqrt{1-x^2}+c\\\\$$

Melody Oct 18, 2014
#2
+121056
+5

Very nice, Melody.

Oct 18, 2014
#3
+114493
0

Thanks Chris

Oct 18, 2014


text:
## Bayesian estimation of parameter $$\tau$$ in variant I of probabilistic model of double choice test.(English)Zbl 0851.62086

### MSC:

 62P15 Applications of statistics to psychology 62F15 Bayesian inference

Zbl 0851.62085
Full Text:

### References:

 [1] Tesaříková E.: Probabilistic model of school-achievement test with double-choice response - variant I. Acta Univ. Palacki. Olomuc., Fac. rer. nat. 105, Math. 31 (1992), 119-126. · Zbl 0825.62747 [2] Tesaříková E.: Statistical analysis of probabilistic model - variant I of the school-achievement test with double choice response. Acta Univ. Palacki. Olomuc., Fac. rer. nat. 105, Math. 31 (1992), 126-147. · Zbl 0825.62748 [3] Tesaříková E.: Variant II of probabilistic model of school-achievement test with double-choice response. Acta Univ. Palacki. Olomuc., Fac. rer. nat. 110, Math. 32 (1993), 159-164. · Zbl 0806.62091 [4] Tesaříková E.: Statistical analysis of variant II of probabilistic model of the school-achievement test with double choice response. Acta Univ. Palacki. Olomuc., Fac. rer. nat. 110, Math. 32 (1993), 165-175. · Zbl 0806.62092
This reference list is based on information provided by the publisher or from digital mathematics libraries. Its items are heuristically matched to zbMATH identifiers and may contain data conversion errors. It attempts to reflect the references listed in the original paper as accurately as possible without claiming the completeness or perfect precision of the matching.


text:
# What is the difference between canonical transformations and gauge transformations?

1. Dec 29, 2011

### zheng89120

I have some ideas of canonical transformation is, but the ideas behind gauge transformation is still eluding me.

2. Dec 30, 2011

### Snicker

Re: What is the difference between canonical transformations and gauge transformation

In short, a canonical transformation is a transformation of the phase space coordinates which maps Hamiltonian flows onto Hamiltonian flows and a gauge transformation defines equivalence classes on field potential functions which leaves "physical fields" invariant.


text:
## An Optimal Choice of Reference for the Quasi-Local Gravitational Energy and Angular Momentum    [PDF]

Gang Sun, Chiang-Mei Chen, Jian-Liang Liu, James M. Nester
The boundary term of the gravitational Hamiltonian can be used to give the values of the quasi-local quantities as long as one can provide a suitable evolution vector field and an appropriate reference. On the two-surface boundary of a region we have proposed using {\em four dimensional isometric matching} between the dynamic spacetime and the reference geometry along with energy extremization to find both the optimal reference matching and the appropriate quasi-Killing vectors. Here we consider the axisymmetric spacetime case. For the Kerr metric in particular we can explicitly solve the equations to find the best matched reference and quasi-Killing vectors. This leads to the exact expression for the quasi-local boundary term and the values of our optimal quasi-local energy and angular momentum.
View original: http://arxiv.org/abs/1307.1039


text:
Loading....

Simultaneous Equilibria

When more than one equilibrium are established in a vessel at the same time and any one of the reactant or product is common in more than one equilibrium, then the equilibrium concentration of the common species in all the equilibrium would be same.

For example, if we take CaCO3(s) and C(s) together in a vessel of capacity V liter and heat it at temperature T kelvin, then CaCO3 decomposes to CaO(s) and CO2(g). Further, evolved CO2 combines with C(s) to give carbon monoxide. Let the moles of CaCO3 and carbon taken initially be a and b, respectively.

Thus, as CO2 is common in both equilibria, its concentration is same in both the equilibrium constant expressions.

Equilibrium constant for first equilibrium,

Equilibrium constant for second equilibrium,


text:
## STPM - L^p Concentration of Semiclassical Quasimodes

Melissa Tacy
September 30, 2010

## STPM - Torsion-Freeness of Certain Cohomology Groups of PEL-Type Shimura Varieties

Junecue Suh
September 30, 2010

## STPM - Sparce Approximation of PSD Matrices

Nikhil Srivastava
September 30, 2010

I will discuss the problem of approximating a given positive semidefinite matrix A , written as a sum of outer products $vv^T$ , by a much shorter weighted sum in the same outer products. I will then mention an application to sparsification of finite undirected graphs.

## STPM - Some Questions Regarding Arithmetic Circuits

Srikanth Srinivasan


text:
# Reinforcement Learning in Real Life/Practical Terms

In every day life, it seems that we all have various habits and actions that we perform. For example, we wake up and check our email/facebook etc. on our phones. We don't look at are current state right now, and consider the values of all the possible future trajectories. We basically choose the action that maximizes our "reward" at our current state.

Question. Is it practical to randomly initialize actions $$a \in A$$, states $$s \in S$$ and a policy $$\pi(a|s)$$ and update this according to some algorithm (e.g. REINFORCE, exploration, etc.) to achieve some desired goal in your life? This could be done, for example, by uniformly sampling a random number in the interval $$(0,1)$$ and acting according to a policy $$\pi(a|s)$$. For example, suppose your goal is to get married, get a new house etc. What would be appropriate reward functions in this case? Reward is usually defined as the immediate reward plus the discounted cumulative reward. But is this the right definition for practical problems like marriage/dating, buying a house, etc.? Would you define reward as $$R_{\text{total}} = R_{\text{marriage}}+R_{\text{buying house}}$$ in our example, where each of those individual rewards are typical immediate plus discounted rewards and try to maximize that? Or would it be better to maximize $$R_{\text{marriage}}$$ and $$R_{\text{buying house}}$$ individually?

• Sorry I meant to post this in ai.stackexhange. – bobberjthoms May 26 at 18:41


text:
# Commutative operators and obserables

1. Jul 14, 2011

### blakegriffin1

I'm just revising some Quantum Mech and I have two questions.

I know that if two operators commute say for instance [$\hat{A}$,$\hat{B}$] = [$\hat{B}$,$\hat{A}$] = 0 Then the observables that the operators extract from the wavefunction can be measured exactly (without losing information about the other).
so that B $\psi$ = b$\psi$ and A $\psi$ = a $\psi$

Question 1) Does this mean that the expectation value of $\hat{B}$ and $\hat{A}$ will be "b" and "a" respectively ? or does this mean that after each and every measurement the measured value of $\hat{B}$ and $\hat{A}$ will be b and a ?

Secondly
Now if two operators don't commute then they can't both be measured simultaneously.
So my question is basically lets assume we have the position and momentum operators and we wish to measure their observables. Assume we know the momentum of the particle exactly. Then we have:
$\hat{p}$ $\psi$ = j $\psi$
(where j is the exact value of the momentum)

Now Clearly since the "x" operator simply acts by "x" we have:
$\hat{x}$ $\psi$ = x $\psi$
So they are measured exactly ?
I know my understanding is off somewhere can someone point out to me where ?

2. Jul 14, 2011

### chogg

Both. (Of course, the second implies the first: if you always get b, then the expectation value is b too.)

The equation
$$\hat{x} \psi = x \psi$$
is only true if $\psi$ is an eigenstate of the $\hat{x}$ operator. Since it's an eigenstate of $\hat{p}$, it couldn't possibly be an eigenstate of $\hat{x}$.

3. Jul 14, 2011

### blakegriffin1

Right but isn't any wavefunction $\psi$ an eigenfunction of $\hat{x}$
as $\hat{x}$ $\psi$ = x $\psi$
This should work for basically everything right since the operator $\hat{x}$ doesn't really do anything besides apply "x" ?

4. Jul 14, 2011

### dextercioby

The x operator acts by multiplication with x only in the coordinate representation. Choosing another representation of the commutation relation means the operator will act in a different way.


text:
# Information loss of particles over time

Due to the nature of the Heisenberg uncertainty principle along with the Schrodinger equation, the position of a particle gains uncertainty / loses certainty over time, because its momentum is also uncertain.

If you know the wave function of a particle at time t0, and reevaluate it at a later time t1, have you gained or lost information now that you are less certain of the position of the particle? Or was there no change in information at all?

The Schrödinger equation is time-symmetric and deterministic, so the wave function at time $$t_1$$ has the same information as at time $$t_0$$. No information is lost or gained. However if you only have some partial information about the wave function, e.g. if you only know the standard deviation $$\Delta x$$, then arguably you will lose or gain information as $$\Delta x$$ increases or decreases over time.


text:
# Tamilnadu Board Class 10 Maths Solutions Chapter 1 Relations and Functions Ex 1.3

## Tamilnadu State Board Class 10 Maths Solutions Chapter 1 Relations and Functions Ex 1.3

Question 1.
Let f = {(x,y)|x,y ∈ N and y = 2x} be a relation on N. Find the domain, co-domain and range. Is this relation a function?
Solution:
F = {(x, y)|x, y ∈ N and y = 2x}
x = {1,2,3,…}
y = {1 × 2, 2 × 2, 3 × 2, 4 × 2, 5 × 2 …}
R = {(1,2), (2,4), (3, 6), (4, 8), (5, 10),…}
Domain of R = {1, 2, 3, 4,…},
Co-domain = {1,2,3…..}
Range of R = {2, 4, 6, 8, 10,…}
Yes, this relation is a function.

Question 2.
Let X = {3, 4, 6, 8}. Determine whether the relation R = {(x,fx))|x ∈ X, f(x) = x2 + 1} is a function from X to N ?
Solution:
x = {3,4, 6, 8}
R = ((x,f(x))|x ∈ X,f(x) = X2 + 1}
f(x) = x2 + 1
f(3) = 32 + 1 = 10
f(4) = 42 + 1 = 17
f(6) = 62 + 1 = 37
f(8) = 82 + 1 = 65

R = {(3, 10), (4,17), (6,37), (8, 65)}
R = {(3, 10), (4,17), (6,37), (8, 65)}
Yes, R is a function from X to N.

Question 3.
Given the function f: x → x2 – 5x + 6, evaluate
(i) f(-1)
(ii) A(2a)
(iii) f(2)
(iv) f(x – 1)
Solution:
Give the function f: x → x2 – 5x + 6.
(i) f(-1) = (-1)2 – 5(1) + 6 = 1 + 5 + 6 = 12
(ii) f(2a) = (2a)2 – 5(2a) + 6 = 4a2 – 10a + 6
(iii) f(2) = 22 – 5(2) + 6 = 4 – 10 + 6 = 0
(iv) f(x- 1) = (x – 1)2 – 5(x – 1) + 6
= x2 – 2x + 1 – 5x + 5 + 6
= x2 – 7x + 12

Question 4.
A graph representing the function f(x) is given in figure it is clear that f (9) = 2.

(i) Find the following values of the function
(a) f(0)
(b) f(7)
(c) f(2)
(d) f(10)
(ii) For what value of x is f (x) = 1?
(iii) Describe the following
(i) Domain
(ii) Range.
(iv) What is the image of 6 under f?
Solution:
From the graph
(a) f(0) = 9
(b) f(7) = 6
(c) f(2) = 6
(d) f(10) = 0
(ii) Atx = 9.5, f(x) = 1
(iii) Domain = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
= {x |0 < x < 10, x ∈ R}
Range = {x|0 < x < 9, x ∈ R}
= {0, 1,2, 3,4, 5,6, 7, 8,9}
(iv) The image of 6 under f is 5.

Question 5.
Let f(x) = 2x + 5. If x ≠ 0 then find

Solution:
Given f(x) = 2x + 5, x ≠ 0.

Question 6.
A function fis defined by f(x) = 2x – 3
(i) find $$\frac{f(0)+f(1)}{2}$$
(ii) find x such that f(x) = 0.
(iii) find x such that f(x) = x.
(iv) find x such that f(x) = f(1 – x).
Solution:
Given f(x) = 2x – 3

Question 7.
An open box is to be made from a square piece of material, 24 cm on a side, by cutting equal squares from the corners and turning up the sides as shown in figure. Express the volume V of the box as a function of x.

Solution:
Volume of the box = Volume of the cuboid
= l × b × h cu. units
Here l = 24 – 2x
b = 24 – 2x
h = x
∴ V = (24 – 2x) (24 – 2x) × x
= (576 – 48x – 48x + 4×2)x
V = 4x3 – 96x2 + 576x

Question 8.
A function f is defined bv f(x) = 3 – 2x . Find x such that f(x2) = (f(x))2.
Solution:
f(x) = 3 – 2x
f(x2) = 3 – 2x2

Question 9.
A plane is flying at a speed of 500 km per hour. Express the distance d travelled by the plane as function of time t in hours.
Solution:

Question 10.
The data in the adjacent table depicts the length of a woman’s forehand and her corresponding height. Based on this data, a student finds a relationship between the height (y) and the forehand length(x) as y = ax + b, where a, b are constants.

(i) Check if this relation is a function.
(ii) Find a and b.
(iii) Find the height of a woman whose forehand length is 40 cm.
(iv) Find the length of forehand of a woman if her height is 53.3 inches.
Solution:
(i) Given y = ax + b …(1)
The ordered pairs are R = {(35, 56) (45, 65) (50, 69.5) (55, 74)}
∴ Hence this relation is a function.

Substituting a = 0.9 in (2) we get
⇒ 65 = 45(.9) + b
⇒ 65 = 40.5 + b
⇒ b = 65 – 40.5
⇒ b = 24.5
∴ a = 0.9, b = 24.5
∴ y = 0.9x + 24.5
(iii) Given x = 40 , y = ?
∴ (4) → y = 0.9 (40) + 24.5
⇒ y = 36 + 24.5
⇒ y = 60.5 inches
(iv) Given y = 53.3 inches, x = ?
(4) → 53.3 = 0.9x + 24.5
⇒ 53.3 – 24.5 = 0.9x
⇒ 28.8 = 0.9x

∴ When y = 53.3 inches, x = 32 cm


text:
# Information Security and Cryptography Research Group

## The Leakage-Resilience Limit of a Computational Problem is Equal to its Unpredictability Entropy

### Divesh Aggarwal and Ueli Maurer

Advances in Cryptology - Asiacrypt 2011, Lecture Notes in Computer Science, Springer-Verlag, vol. 7073, pp. 686-701, 2011.

A cryptographic assumption is the (unproven) mathematical statement that a certain computational problem (e.g. factoring integers) is computationally hard. The leakage-resilience limit of a cryptographic assumption, and hence of a computational search problem, is the maximal number of bits of information that can be leaked (adaptively) about an instance, without making the problem easy to solve. This implies security of the underlying scheme against arbitrary side channel attacks by a computationally unbounded adversary as long as the number of leaked bits of information is less than the leakage resilience limit.

The hardness of a computational problem is typically characterized by the running time of the fastest (known) algorithm for solving it. We propose to consider, as another natural complexity-theoretic quantity, the success probability of the best polynomial-time algorithm (which can be exponentially small). We refer to its negative logarithm as the unpredictability entropy of the problem (which is defined up to an additive logarithmic term).

A main result of the paper is that the leakage-resilience limit and the unpredictability entropy are equal. This demonstrates, for the first time, the practical relevance of studying polynomial-time algorithms even for problems believed to be hard, and even if the success probability is too small to be of practical interest. With this view, we look at the best probabilistic polynomial time algorithms for the learning with errors and lattice problems that have in recent years gained relevance in cryptography.

We also introduce the concept of witness compression for computational problems, namely the reduction of a problem to another problem for which the witnesses are shorter. The length of the smallest achievable witness for a problem also corresponds to the non-adaptive leakage-resilience limit, and it is also shown to be equal to the unpredictability entropy of the problem. The witness compression concept is also of independent theoretical interest. An example of an implication of our result is that 3-SAT for $n$ variables can be witness compressed from $n$ bits (the variable assignments) to $0.41 n$ bits.

## BibTeX Citation

@inproceedings{AggMau11,
author       = {Divesh Aggarwal and Ueli Maurer},
title        = {The Leakage-Resilience Limit of a Computational Problem is Equal to its Unpredictability Entropy},
editor       = {D. H. Lee and X. Wang},
booktitle    = {Advances in Cryptology - Asiacrypt 2011},
pages        = 686-701,
series       = {Lecture Notes in Computer Science},
volume       = 7073,
year         = 2011,
publisher    = {Springer-Verlag},
}


text:
Today I was mentally grumbling at a link-only Google Code answer that wasn't very clear, when it occurred to me that very soon, almost all Google Code related answers are going to break, because Google Code is shutting down.

We have until the end of the year (roughly) before Google Code goes completely poof. Fixing things while google code is still up will probably make it easier to follow things up, like where the new repos might be living (if anywhere).

There are a few different categories of questions that may "break", though. I propose the following:

1. Link-only answers: like this one should probably be deleted regardless of the fact that google code is dying.
2. Links to GC repos in legit questions: These are questions that could survive without links to a repo, and all relevant code is in the question or answer, but are enhanced by having the link. To handle these, it's probably best to attempt to link to the new github/whatever repo if it can be found. This would be loads of work, but would make sure the answers were still good quality.
3. Questions about using Google Code: Like this or this. I assume there is probably a policy for handling completely defunct questions, but I'm not sure what it is.

Only problem? An SO search for code.google.com comes up with ~50,000 results >120,000 questions. The results of leaving it unfixed will be pretty drastic, but it's a mind boggling amount of work to fix and I can't imagine how to automate it.

=====

Quick update: Stephane's answer below looks like a good way to handle most of the legit questions. Does anyone know if there's a policy for handling obsolete questions, like in category 3 above?

• Yeah this is an issue. We were supposed to be putting all the relevant code within the question itself, I think. Many of the questions may be old enough to have become obsolete though? But I'm guessing it will sort itself out somehow – Coffee Jun 14 '15 at 16:41
• It will... but if we have the power to prevent the mass obsolescence of tens of thousands of questions before it happens... we should? – yochannah Jun 14 '15 at 16:46
• @yochannah - touche. Is there a way to grab the ones from within a year(ideally the quality ones), and then separate it out as a sort of "community volunteering edit-effort" - I wonder if there's a way to count-down how many posts still need fix-ups, as we continually whittle away at the problem . Because yes, this cannot be automated(someone needs to eyeball the code to bring in only the relevant code ) – Coffee Jun 14 '15 at 16:49
• Actually, it would be in Google's interest to help Stackoverflow sort this out. They're the ones pulling the rug from under us so maybe they should help find a way to auto-migrate – Coffee Jun 14 '15 at 16:57
• @Coffee but migrated to where or what? the service is discontinued, project owners need to migrate their code. Maintainers that doesn't show up will have no new location except the tarballs.... – rene Jun 14 '15 at 17:03
• I'm really not sure if or how this needs to be tackled. There are 25714 low quality answers and about 3047 questions with no answer. That leaves 100K of posts that currently have some value. – rene Jun 14 '15 at 17:15
• How about we start with answers containing that link, not closed, not a duplicate, with 200+ views. Sadly cant filter on "not containing a code block". – Sumurai8 Jun 14 '15 at 18:02
• Doing what exactly @Sumurai8 ? close? delete? edit? leave a comment? – rene Jun 14 '15 at 18:12
• @rene: Someone can probably write a simple script that analyzes these answers to see which are likely to need user input (can a sede query be used?). My reasoning is that 120.000 q&a is too much to do something with. If we have to choose a subset of q&a, we should prefer checking open q&a that have a decent amount of views (and thus relevance). – Sumurai8 Jun 14 '15 at 18:32
• @Sumurai8 I agree (I think) on the script part and if the results stay within 50000 rows SEDE could be used. But I'm more worried about what the likely to need user input will be? Just pick a handful of posts from your search and see if you come up with a small set of guidelines so we could start something similar like this. Even if we want to automate/mechanical turk the action we need to know where to look for...and I can't form a clear picture of that action in my mind yet. – rene Jun 14 '15 at 18:42
• Seems we need a new review queue, possibly with sub-queues: One where we can put all questions/answers matching a query in for collaborative (optionally one-shot) reviewing. – Deduplicator Jun 14 '15 at 18:56
• How about a single comment to every OP that has a post with the link in it with the request to either add the code form the link to the post, update the link to the new location or remove the link all together. – rene Jun 14 '15 at 19:02
• @rene Combine both suggestions, send a comment automatically to every post that has a link to code.google.com asking the user to change their post (include a link to this question for reference). Then check after a certain period of time has passed and any that haven't been edited since the comment was left will be sent to a review queue. That way the majority of the work will be (hopefully) done by the users that left the post, and the rest will (I think) mostly be deletion of link-only or obsolete posts. – user4639281 Jun 14 '15 at 22:32
• Keep in mind that none of this exist yet. I checked in the Tavern if some of the tools used by the CharCoal team could be used which seems to be the case but not without tweaks. That would give use an off-site review queue. Leaves open the comments to be send to users which could start with a SEDE query but I don't feel comfortable doing a mass-mailing... – rene Jun 14 '15 at 23:17
• Do you mind accepting it if that answers all your questions? :) – Stéphane Bruckert Mar 24 '16 at 16:34

Update 6 months later: problem solved by itself.

So finally there is nothing to do on SO's side!

From Chris DiBona (works at Google):

We are planing on taking the majority of these legitimate, open source, 'abandonded' projects and putting them up in cold storage in a git repo on googlesource.com

Once Google Code is down or the new repo is created, the Stack Exchange team could run a script that finds all code.google.com/repo/file links and change them to something which will most probably look like googlesource.com/oldgooglecode/repo/file.

• I think this should mention the old link, strike it and post a new link, instead of just replacing the links. So as to keep a record of what really happened. – noob Jun 15 '15 at 7:42
• @noob Why? If this goes forward a new revision of the post is created... – rene Jun 15 '15 at 7:44
• Yeah, but that just striked in my head that what if the new link doesn't follow a proper standard. For example what if code.google.com/repo/file is not exactly replaceable with a proper URL. Or what if the Google code repo is dropped completely. They are going to migrate only few of them. So people should know the actual link to at least use Google cached view etc. to get the old code. It's hard to automate this IMO, so keeping an abandoned link might help. And not everyone know how to look for revisions or if the post actually had revisions. – noob Jun 15 '15 at 7:49
• We can't say until we know how the new Git repo on googlesource.com is structured, but as you mentioned there will be some particular cases to take care of. – Stéphane Bruckert Jun 15 '15 at 7:50
• @noob We have edit revision history for that don't we? – Anthon Jun 15 '15 at 7:58
• @Anthon How many time do you actually look at the revision history when using an answer? How do you supposed to know if the post has been edited out due to the Google Code shutdown and have been redirected to a new url which may or may not work. If there's a striked out content or even a yellow banner, users will know that they need to look at the revision history or at least they would know that the edit was automated without opening the revision history. I have never looked at the history of edits before using an answer, so there's one case at least. – noob Jun 15 '15 at 8:02
• I actually look relatively often at the revision history of posts and I would find a strikeout of the original URL in the post too much distraction if not absolutely necessary (which is hopefully the case). A smaller inline marker linking to an explanation might be more appropriate e..g a clickable [orig] text, I would find that more acceptable than a full strikeout – Anthon Jun 15 '15 at 8:20
• @noob We have to wait and see what they ultimately do. We have code laying around that sends gracious HTTP HEAD requests to verify the target gives a 200 status, it's something we built a long time ago to try and get link rot in front of reviewers. While we never opened the queue, we could make use of it in something that handles the lion's share of these edits automatically when the time comes. – Tim Post Jun 17 '15 at 1:53
• @TimPost That's another good idea. Anthon If there's a simple indication that the current URL is changed via script, that's enough. Obviously if it's changed manually using a separate revision queue then it's not needed. – noob Jun 17 '15 at 4:40

If they're useful, try to pull some context out of whatever is being linked and put it into the answer. If the answer is basically just use this, then take a hard look at the question itself.

If they're just a half-assed attempt at answering something, they should probably be deleted.

Links to repos in high quality posts

Hopefully Google does something to avoid breaking these altogether, we have to see what that might be. Stéphane Bruckert's answer gives me hope. If these links can be practically re-written and re-baked, we might be able to do that, just like we did when we split MSE away from MSO.

If you're looking for something to do, and notice an opportunity to help 'future proof' something good by pulling context out of the linked resource and into the question (where it's possible to do so), then by all means do it, but that's not exclusive to existentially-challenged code hosting services :)

Nothing to do here. It existed, developers used it, and then it didn't exist any longer. It's just part of the site, and part of the history of doing our jobs. Continuing to have these questions won't hurt anything, we've got plenty of room. There's no real set policy, just an understanding that things sometimes lose relevance quickly.

Who knows, there might come a day when nobody uses CVS anymore, but we've got an amazing collection of 1300+ heads slamming on desks for our children's children to read about.

• A deletionist would hope Google does its very best to break the links as soon as possible just so they can drive the point home, usefulness be damned. – BoltClock Jun 15 '15 at 10:17
• I dug a bit. The good news is we have some time to get ahead of this. The bad news is handling links to a specific revision / etc is going to be .. hard. I'm going to raise this to core dev internally (while we still have time to get ahead of it). – Tim Post Jun 15 '15 at 18:12
• I still use CVS at work. sob – Shotgun Ninja Jun 16 '15 at 19:36

This is a good idea and it should be done in multiple steps, starting with a clean-up of material that can be updated fully automatically, followed by human effort supported by a website that offers information and keeps track of what has already been handled.

Some people, already moved their code from google somewhere else, as can be seen when following links in this answer from Jon Skeet. Therefore for each of the 100K answers and 25K questions a check should be made whether the URL redirects somewhere else. If so the URL should be updated automatically.

For the other posts information about how much code lines (indented by 4) are available, how many views the question got, upvotes on questions and answers, and last visit to SO of the poster of the question /answer should influence priority and type of action taken.

If people have been active recently, a comment could be added to their post asking to update their posts and especially the links in a way the see fit within the next X days because of the changes at google.code.

As I don't think there has to be complete consensus on what order should be followed for manually updating answers. An online site where the above information is presented should allow ordering according to the potential reviewers needs.

This can all be done outside of SO, although not as efficient, and I am not sure about the "legality" of automatic updates of URLs.

But in the case of a user initiative, as rechecking links for changes is relatively expensive the site should be setup so that links to the material on SO are indirect so that clicking on a description redirects to the SO site, but also stores information that it is likely that the post will change.


text:
# Homework Help: Calculating the minimum vacuum force for a climbing robot

1. Jan 2, 2010

### amrbekhit

1. The problem statement, all variables and given/known data
Hello. I am trying to calculate the minimum vacuum force required to keep a climbing robot attached to a ceiling. The robot body consists of a cuboid with two vacuum cups attached at either end. The robot will move using inchworm-style motion, attaching one of the cups, extending its body, attaching the second cup, retracting etc. In order to calculate the minimum vacuum force that the robot needs to generate, I have constructed the following free body diagram:

To calculate the maximum force, I am consider the situation where the robot has only one of its suction cups active, which in this case is the one on the right.

Description of forces:
• F: The suction force produced by the vacuum cup.
• R: The reaction force produced due to the robot pressing against the ceiling
• uR: Force due to friction between the ceiling and the robot's suction cup
• D: Drag force caused by fluid moving past the robot. This is 1N
• mg: Weight of the robot. This is 0.2*9.81=1.962

List of dimensions:
• r: Radius of the suction cup. 15mm
• H: Distance between the C.o.M of the robot and the ceiling: 17.5mm
• L: Distance between the suction cup centres. 56mm

In order to perform the calculation, I have made the following assumptions:
I have assumed that as the suction force decreases, the robot will not just simply fall vertically, but will behave almost as if it was hinged at point A in the diagram. Based on this assumption, I have assumed that the only reaction force is the one shown on the diagram. This is because if the suction force is at its minimum, I would imagine that the inactive suction cup would be barely touching the ceiling and so no reaction forces would be generated. Likewise, I am guessing that the side of the left hand side of the active suction cup would also be barely touching, leaving the very right hand side in firm contact with the ceiling.

2. Relevant equations
$$Pressure = \frac{Force}{Area}$$
$$Circle area = \pi r^{2}$$

3. The attempt at a solution
Resolving vertically:

$$F = R + mg$$

Resolving horizontally:

$$D = uR$$

$$Fr = DH + mg(\frac{L}{2} + r)$$

Solving the above equation gives a value of $$F = 6.79N$$

Substituting this value back into the first equation gives a value of $$R = 4.83N$$

Finally, inserting this value into the second equation gives a value of $$u = 0.2$$

In order to calculate the pressure required in the suction cup:

$$P = \frac{F}{A}$$
$$A=\pi 0.015^2 = 7.069*10^{-4}m^2$$

giving a pressure of

$$P=9606Pa$$

What I am unsure about is whether this is the correct way of calculating the minimum force. I am especially unsure about the assumption I have made regarding the reaction force. Should there be reaction forces on both suction cups? Should I consider those forces as one force for each cup, or would I need to consider the reaction forces on both sides of each cup? Am I correct in assuming that the robot would rotate around point A as the suction force decreases? Would I then need to consider any friction produced at the inactive suction cup?

Thanks

--Amr

2. Jan 2, 2010

### diazona

Well.... I think you made a reasonable decision to consider the force when only one suction cup is touching the ceiling. That's when the full reaction force from the suction needs to be used, so it determines what the minimum suction pressure needs to be. Obviously, if one cup is not touching the ceiling, there will be no reaction force or friction on it.

The assumption that the robot would rotate around point A also seems reasonable, I think - definitely the rotation would be taking place around some point within the suction cup. You could try doing the calculation assuming that the axis of rotation is at the forward edge of the suction cup, just to see how much your answer for the pressure differs; if the difference is small, that tells you that the assumption about the rotation axis probably doesn't matter that much.


text:
# Math Genius: complex vector space and matrices

The function $$10cos(5t) + 8sin(5t)$$ lies in the complex vector space with basis $$e^{5it}$$ and $$e^{-5it}$$. Find the vector with respect to that basis.

Using matrices, I got that

$$10cos(5t) + 8sin(5t) = begin{pmatrix} e^{5it} & e^{-5it} end{pmatrix} begin{pmatrix} A \ B end{pmatrix}.$$

Now, letting $$LHS = begin{pmatrix} 10cos(5t) + 8sin(5t) end{pmatrix}$$, $$Emat = begin{pmatrix} e^{5it} & e^{-5it} end{pmatrix}$$, and $$C = begin{pmatrix} A \ B end{pmatrix}$$, I have $$LHS = Emat * C.$$

Since the matrices need to be square to be invertible, I thought I could do $$C^{-1} = LHS^{-1}*Emat,$$ then take the inverse of $$C^{-1}$$. However, the answer I got (using matlab) was wrong, and I’m wondering where I went wrong, or if there was another approach that I didn’t think of. Any help would really be appreciated!

begin{align*}Ae^{5it}+Be^{-5it}&=Acos(5t)+Aisin(5t)+Bcos(-5t)+Bisin(-5t)\ &=(A+B)cos(5t)+(A-B)isin(5t),, end{align*}
so $$A+B=10$$ and $$(A-B)i=8$$, or $$A-B=-8i$$.

Solving simultaneously gives
$$A=5-4i, B=5+4i.$$

The answer by A. Goodier is good and what I would have written had it not already been written. But you seemed to want to solve this problem by inverting matrices, and you recognized that matrices need to be square to be invertible. Here is a solution along those lines.

The matrix $$M=pmatrix{1&1\i&-i}$$ converts coordinates

from the basis $${e^{5it},e^{-5it}}$$ to the basis $${cos 5t,sin 5t},$$

because the first column tells us $$e^{5it}=cos 5t+isin5t,$$

and the second tells us $$e^{-5it}=cos5t-isin5t$$.

We can then solve $$pmatrix{10\8}=Mpmatrix{A\B}$$ as $$pmatrix{A\B}=M^{-1}pmatrix{10\8}=pmatrix{1&1\i&-i}^{-1}pmatrix{10\8}$$

$$=dfrac{pmatrix{-i&-1\-i&1}}{-2i}pmatrix{10\8}=pmatrix{frac12&-frac i2\frac12&frac i2}pmatrix{10\8}=pmatrix{5-4i\5+4i}.$$


text:
Browse Questions

# Suppose 3 bulbs are selected at random from a lot.Each bulb is tested and classified as defective (D) or non-defective (N).Write the sample space of this experiment

Given,3 bulbs are selected at random classified as defective (D),non-defective (N)
$\therefore$ The sample space S is
$S=\{DDD,DDN,DND,DNN,NDD,NDN,NND,NNN\}$


text:
# How do you write 47,000 in scientific notation?

Mar 18, 2018

$47 , 000 = 4.7 \cdot {10}^{4}$

#### Explanation:

When writing numbers in scientific notation, we want one non-zero digit in front of the decimal point.

In the number $47 , 000$, the decimal is essentially at the end of the number:

$47 , 000.$

We can loop the decimal point $4$ times to the left to get:

$4.70$

Recall, we looped our decimal $4$ times, and to the left, so the power of $10$ will be a positive $4$, thus:

$47 , 000 = 4.7 \cdot {10}^{4}$


text:
# Fisher’s test of periodicity

I have evenly sampled time series on which I applied Fourier transform. I am trying do determine if the signal contains statistically significant periodic components. I have succeeded with determining period. Now I am trying to calculate p-value for this component using these formulas derived by Fisher:

\begin{align}
I(\lambda) &= \frac{1}{2\pi n}\bigg|\sum_{t=1}^n X_te^{-it\lambda}\bigg|^2 \\[5pt]
Y_r &= \frac{I(\lambda_r)}{\sum_{j=1}^mI(\lambda_j)}, \qquad r = 1, \ldots, m, \\[5pt]
P(Y>y) &= 1- \sum_{j=0}^m (-1)^j{m\choose j}(1-jy)_+^{m-1}
\end{align}

The first formula is just squared discrete Fourier transfom.

$n$ – length of time data series
$m = (n – 1) / 2$ is number of AC harmonic components without Nyquist frequency

The problem I am solving is that for some values of $g$-statistics (denoted as $Y_r$ in this example) the sum of series is diverging. Let’s take an example:
\begin{align}
n &= 287 \\
m &= 143 \\
y &= 0.0044598585072423936
\end{align}
Partial sum for $j = 1$ is:
$$(-1)^1 + 143C1 \times (1 – 0.0044598585072423936)^142 = -75.802$$
The meaning of P value is probability which should be number between 0 (the event never occurs) and 1 (the event occurs always). Adding next terms to the sum just make the resulting value larger in absolute value. Is there something I am doing incorrectly?


text:
## Calculus (3rd Edition)

$$\lim _{x \rightarrow 7} f(x)=6$$
The Squeeze Theorem does not require that the inequalities $$l(x) \leq f(x) \leq u(x)$$ hold for all $x,$ but only that the inequalities hold on some open interval containing $x=c .$ From the given figure, it is clear that $$l(x) \leq f(x) \leq u(x)$$ on some open interval containing $x=7 .$ Because $$\lim _{x \rightarrow 7} u(x)=\lim _{x \rightarrow 7} l(x)=6,$$ the Squeeze Theorem guarantees that $$\lim _{x \rightarrow 7} f(x)=6$$


text:
# Orbital period and nodal precession & apsidal precession

In classical orbital mechanics as per Newton/Kepler, the time taken to complete one orbit around a body of mass $M_e$ is:

$$T = 2 \pi \cdot \sqrt { \frac {a^3} {G \cdot M_e} }$$

But also, for orbits around an oblate spheroid, we also have precession of the orbital plane itself, and the precession of the orbit's major axis which, for every turn of the orbit, are respectively:

$$\Delta\Omega = -3\pi\cdot \cfrac {J_2} {G\cdot M_e} \cdot \left[\frac {1} {a \cdot \left(1-e^2\right)}\right]^2 \cdot \cos i$$

$$\Delta\omega = -6\pi\cdot \cfrac {J_2} {G\cdot M_e} \cdot \left[\frac {1} {a \cdot \left(1-e^2\right)}\right]^2 \cdot \left(\frac 5 4 \cdot \sin^2 i - 1 \right)$$

What I'm unclear is, in presence of these factors, how is the orbital period $T$ defined?

Can it be defined as the time elapsed between two consecutive passes through the periapses (or apoapsis)? How does that work when the periapsis (or apoapsis) is itself shifting? Do I count the time to where the periapsis was when I started, or where the periapsis is now?

Specifically, what happens in an equatorial circular orbit? (Or, if we like, an orbit where $i$ and $e$ are just very, very small?) Substituting $i=0$ and $e=0$ gets us:

$$\Delta\Omega = -3\pi\cdot \cfrac {J_2} {G\cdot M_e \cdot a^2}\qquad \Delta\omega = +6\pi\cdot \cfrac {J_2} {G\cdot M_e \cdot a^2}$$ So if we assume the oblate spheroid is also rotating with time period $T$, and the orbiting body passed directly over a point $P$ on the spheroid's equator at time $t_0$, where will it be at time $t_0 + T$?

• Will it be directly over $P$?
• Or will it be $3\pi\cdot \cfrac {J_2} {G\cdot M_e \cdot a^2}$ ahead (East) of $P$ in longitude (considering $\Delta\Omega + \Delta\omega$)?
• Or will it be $3\pi\cdot \cfrac {J_2} {G\cdot M_e \cdot a^2}$ behind (West) of $P$ in longitude (considering $\Delta\Omega$ only)?
• Anything else?

Cheers!

Note: $a$ = semi-major axis, $e$ = eccentricity of the orbit, $i$ = inclination of the orbit, $G$ = gravitational constant, $J_2$ = a coefficient in the spherical harmonic expansion of the spheroid's gravitational potential field

Since the period $T$ doesn't appear in either of those formulas of precession angle, I don't understand why you need a definition of $T$ (the formulas are self-consistent without $T$). In fact, we can not define period very well in some cases, since the orbit may not close on itself due to precession, which makes the movement aperiodic.

The formulas you mention are obtained from the Lagrange Planetary Equations, that describe the perturbed central motion, with some averaging along the orbit.

For context and notation, in the case of central motion, the set of orbital elements $$\{a,e,i,\omega,\Omega,t_p \}$$ are constant and equivalent to know the initial conditions, the solution being (for $$e <1$$) an ellipse. $$t_p$$ is the time at periapsis; knowing the current time and the period (your formula) $$T=2\pi/n$$ is enough to determine the mean anomaly $$M=n(t-t_p)$$ from which we can determine the true anomaly, the angle from the periapsis to the current position, using Kepler's equation; $$n$$ is the orbital frequency.

In the case of motion perturbed by the oblateness, the orbital elements become time dependent. The intuitive view is that at each instant of time $$t_s$$ we have a different orbit with elements $$a(t_s),e(t_s),\ldots$$. In the present case, it happens that the 3 elements $$a,e,i$$ are periodic with small amplitude, so their average variation is zero and can be ignored except for very high fidelity calculations. Because of that, we can imagine the motion as if the ellipse that is the trajectory (that is the same because $$a,e$$ are constant) rotates in space: the orbital plane rotating around the $$z$$-axis (determined by $$\Omega$$) and the apsidal line rotating in the orbital plane (determined by $$\omega$$).

So, for an orbit with inclination $$i$$, if the central body does not rotate, the orbit rotates towards East for $$i<\pi/2$$, and so the satellite will not pass over $$P$$. When it passes at the same latitude depends on the period and the change in $$\omega$$ (apsidal rotation). The satellite moves in this rotating orbit.

What is the period and how much is it is a little ore complicated. We can have two views: when it completes a turn relative to the inertial reference frame (stars) or relative to the periapsis, which is rotating. We can use both. In the case of the Earth, we call sidereal year to the first and anomalistic year to the second (check Sidereal, tropical, and anomalistic years). What about the period? Lagrange Planetary Equations determine the change in $$M=M_0+n_M(t-t_0)$$ with a changed orbital frequency $$n_s=n+\frac{3nJ_2(3\cos^2 i-1)}{4(1-e^2)^{3/2}}(R_e/a)^2;$$ at each instant $$t$$, we can determine the current $$M$$ using the current osculating orbit for the true anomaly.

I suggest the book of Sidi, "Spacecraft Dynamics and Control: a practical engineering approach", it's the only reference that comes to mind that explains the change in $$M$$.


text:
Free cookie consent management tool by TermsFeed Policy Generator

Version 22 (modified by abeham, 12 years ago) (diff)

updated tutorial client code

# Optimizing External Applications

Sometimes it is not possible to directly write a new problem for HeuristicLab and integrate it through the plugin system. Some people already have an application of which at least a part represents a NP hard problem that they'd like to solve. This guide explains how to use the ExternalEvaluationProblem that is available in HeuristicLab 3.3 to optimize problems written in a language other than C# or written using different frameworks, to name just a few possibilities. First the architecture is described, then a more detailed look into the API is given and finally a short tutorial should give the reader an idea of how to apply this to his/her case.

The most important part in any optimization problem is the evaluation function. Without knowing about the quality of a certain solution configuration the algorithm is not able to come close to an optimal solution. In NP hard problems evaluating a solution is usually a rather simple task, whereas finding the best solution is extremely difficult. Of course there can be complex problems which require high computational effort to calculate the quality of a solution, but in many cases the evaluation of a solution is rather straight forward. So, if the problem is not a HeuristicLab plugin we assume that it is available in another kind of executable format, either in an application itself or as part of another framework for example. We thus have a situation where we need inter-process communication (IPC). There are several possibilities of how to do IPC, in the following we will explain the approach we offer in HeuristicLab 3.3.

## Architecture Overview

### Technology & Background

Among the many possibilities and technologies that have emerged to provide a base for performing "distributed computing" in a wide sense, one of the first technologies was Remote Procedure Call (RPC). The idea is very simple: Instead of calling a local procedure to do some kind of calculation, a procedure is called that is not defined within the same executable or one of its dependencies. The client thus is in some ways hands the parameters of the method to another program or server, waits for the computation and then reads back the return value. In such a broad sense this is how most web applications nowadays work and indeed it is not until the invention of Representational State Transfer (REST) that there was a revolutionary change from this early RPC paradigm.

Recently Google, one of the biggest players in the world wide web released parts of their core RPC technologies to the general public. The framework that they call Protocol Buffers combines a domain specific language (DSL) for describing messages with an RPC framework that is used to pass these messages among different servers. The RPC framework itself is not released, but the DSL for describing messages and translating them to objects of several supported programming languages was released under the BSD license. Google directly supports C++, Java, and Python, but many developers have programmed ports of protocol buffers to different languages such as C#, Visual Basic, Objective C, Perl, Haskell, and many more. The documentation on protocol buffers is extremely helpful in understanding the framework. A similar framework called Thrift has evolved that backs the operation of Facebook and was also released to the public. These technologies provide convenient ways to define messages, manipulate them, and serialize them to small sizes at high speeds.

In HeuristicLab using remote procedure calls seems to fit very well with what we are trying to achieve in "exporting" the problem definition. The problem, to an optimizer, is basically the evaluation function and the solution representation is their common knowledge. A client is provided in HeuristicLab as well as a framework that enables developers to write a service which exposes the evaluation function to HeuristicLab. Using this service foreign language applications and problems can effectively communicate with HeuristicLab and have their parameters optimized by HeuristicLab's powerful optimization library. Please note that while we're talking about RPC, the provided frameworks are not compatible with the RPC standard, but are rather simplified to ease application. Think of RPC as a paradigm rather than a standard.

Communication also requires a given media over which to exchange the information. So far HeuristicLab offers two choices for the underlying media:

1. The external program can be started as a process from HeuristicLab and the communication occurs via the process' stdin and stdout. This requires that the external program can be executed under Windows. If the developer controls the standard input and output streams and does not need to write or read other data through them, this might be a simple solution.
2. The external program is started independently from HeuristicLab and opens a TCP/IP port for communicating over a network. This is independent of the platform and a universal solution that should work in most cases.

Regardless of the chosen media, the solution receiving and quality sending processes are abstracted from the developer through our service framework. For writing services, generally two types of services are supported by our framework: Push Service and Poll Service. It depends on the application which one of these is more suitable. If the developer is in charge of the control flow the push service seems plausible, if however the application flow cannot be fully controlled by the developer the poll service is the better suited option.

### Push Service

As the name suggests when implementing a push service the solutions are pushed into the evaluation method. The developer has to provide a class that is able to perform the evaluation task. This class specifies a method that takes a SolutionMessage and returns a double value indicating the quality of the given solution. The method is called in a new thread whenever a new solution is received by the framework.

### Poll Service

In this type the received solutions have to be polled. The service receives solutions in its own thread and puts them into a queue, waiting for the developer to process them. It provides two public methods, one that returns the next solution from the queue and blocks until a solution becomes available and another that sends the quality back to HeuristicLab.

### Application Scenarios

One of the application scenarios that we had in mind when designing this interface is the field of simulation-based optimization. There, a simulation model defines a number of parameters which need to be adjusted such that a measured output of the model improves. This can be inventory sizes in a supply-chain scenario, or similarly buffer sizes in an assembly line, or training the weights in a neural network simulator. There are numerous optimization problems that are implemented as simulation models and one of the main problems is talking to them. Many different frameworks exist with which one can conveniently build, run, and test a simulation model, and most of them already have some support for optimization. However that support often is of proprietary nature and little information is available on how these methods perform. HeuristicLab aims to provide an open source alternative and the means of this interface allows simulation experts to use HeuristicLab in the optimization tasks.

Naturally, there exist several more reasons why a problem cannot be modeled in HeuristicLab, such as language or platform dependency and for these purposes this interface should provide a solution.

## Architecture Details

Optimizing external applications divides into two parts:

1. Providing an evaluation service for HeuristicLab in the external application
2. Preparing an ExternalEvaluationProblem in HeuristicLab

These two tasks are described in this section in more detail.

### Providing an evaluation service

Attached to this wiki page you can find a java library that enables a quick connection with HeuristicLab over a TCP/IP connection. In this library there is an abstract base class Channel on the one hand which provides methods for sending and receiving messages and several concrete implementations and on the other hand an abstract base class Service that provides the concrete PollService and PushService. A Listener listens for connections and opens several channels out of which the service will receive solutions and send back qualities. As a user of the library you will prepare an IListenerFactory and hand this to your service instance. Then, depending on the type of service, you can get solutions out of it and push the qualities back. It is quite easy.

Similarly a C# port of this library has also been added, which is handy when your application cannot be compiled to a dll and called directly from your C# problem plugin.

In the following code sample you may find some test applications that provide very simple examples of how to use the service framework. They do not really evaluate a solution, but return a random number in the interval [0;1) for every received solution.

#### Usage examples

Here is the java code for the RandomSocketPollEvaluator

public class RandomSocketPollEvaluator {

public static void main(String[] args) {
ServerSocketListenerFactory factory = new ServerSocketListenerFactory(8842);
PollService service = new PollService(factory, 1);
service.start();

Random random = new Random();
while (true) {
SolutionMessage msg = service.getSolution();
try {
service.sendQuality(msg, random.nextDouble());
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

This code shows a concrete example of how to use the PollService and the ease of integrating this into an external java application. Using a PushService is slightly different as can be seen in the following example. As mentioned it depends on the application which of the two possibilities is more suited.

public class RandomSocketPushEvaluator {
private PushService service;

public static void main(String[] args) {
RandomSocketPushEvaluator main = new RandomSocketPushEvaluator();
main.run();
System.out.println("Service is running, terminate by pressing <Return> or <Enter>.");
System.console().readLine(); // note: you may not always have a console
main.terminate();
}

private void run() {
ServerSocketListenerFactory factory = new ServerSocketListenerFactory(8842);
service = new PushService(factory, 1, new RandomEvaluator());
service.start();
}

private void terminate() {
service.stop();
}

private class RandomEvaluator implements IEvaluationService {
Random random;

public RandomEvaluator() {
random = new Random();
}

@Override
public double evaluate(SolutionMessage msg) {
return random.nextDouble();
}

}
}

### Preparing an ExternalEvaluationProblem

In the HeuristicLab Optimizer a number of algorithms and problems are available which can be created, viewed and parameterized. A problem in HeuristicLab consists of several parameters whose values describe the problem instance, but also consists of several operators. The two most important operators are the Evaluator which is used to evaluate a solution and the SolutionCreator which is used to create new solution configurations from scratch. Although solutions are usually created randomly, for some problem one might use certain heuristics and start with partly optimal solutions. Finally every problem also contains an operator list of operators that are known to work with the problem's solution representations. This list is usually hidden in many problems as the list is populated all by itself by discovering all operators that implement a certain interface for example.

Among these problems, there is a special problem designed for the purpose of calling an external evaluation function called ExternalEvaluationProblem. The problem allows the user to define a customized solution representation, as well as configure the operator list with operators that are available to solve the problem. The following screenshot shows the default parameters of this problem.

The list of parameters that are available there are briefly described:

• BestKnownQuality - Displays the best known quality of the problem, this is updated through a special analyzer.
• BestKnownSolution - Houses the best known solution so far, that is the scope that contains the solution representation
• Client - The client that transmits the solution to the external application. The user configures the client by defining the appropriate channel and channel connection information.
• Evaluator - The evaluator is an operator that collects variables from the scope and includes them in a message which will be sent to the external application. The user has to configure the evaluator such that it can find the variables to collect.
• Maximization - Is necessary for the algorithm to know whether it should minimize or maximize the quality value.
• Operators - Contains a list of operators that the problem provides to the algorithm. In this list any Crossover, Manipulation or other operator will be passed to the algorithm and will be made selectable there.
• SolutionCreator - Is an operator that creates a solution. This operator can also be adjusted by the user as needed. One can use the included representation generators in the HeuristicLab.Encodings namespace, or use own generators from an own plugin.

In the tutorial section it will be shown how to configure these parameters to solve a real problem.

For completeness reasons a class diagram of the HeuristicLab.Problems.ExternalEvaluation namespace shall also be given. The interaction of the classes shall be explained and the operators described.

The equivalent to the channels in the java service framework are implemented also in C# for use in HeuristicLab. There is an Interface IEvaluationChannel that defines a channel. As can be seen from the class diagram the methods that each channel has to provide are exactly the same as in the java service framework. Basically a channel can be opened and closed and there are two functions for sending and receiving. In HeuristicLab however there exists a third channel, the EvaluationProcessChannel, that provides a convenience wrapper around an EvaluationStreamChannel that is attached to the stdin and stdout streams of a process started from HeuristicLab.

Also shown in the class diagram are a number of converters that are used to convert HeuristicLab data types, such as the variables that contain the solution representation, to a SolutionMessage. The SolutionMessageBuilder is the class that contains a number of converters and allows the ExternalEvaluator to construct the message. Which converter shall be used can be configured in the GUI when creating the ExternalEvaluationProblem and the converters are naturally extensible. A user can define an own converter implementing IItemToSolutionMessageConverter and add it to the SolutionMessageBuilder in the GUI. By default the SolutionMessageBuilder is configured with all the converters that can be seen which in turn cover all the data types in the HeuristicLab.Data namespace. The solution representations in HeuristicLab.Encodings are derived from those, so the converters also cover them too. But any solution representation not derived directly from one of the objects in HeuristicLab.Data naturally requires an own converter (e.g. HeuristicLab.Encodings.SymbolicExpressionTree is such a type). Next in the class diagram is the EvaluationServiceClient which holds a Channel and allows the ExternalEvaluator to communicate with the remote process. Finally, there is a class that describes the ExternalEvaluationPRoblem itself, as well as the QualityMessage (the expected answer from the service) and the SolutionMessage. These two are automatically created by parsing the ExternalEvaluationMessages.proto file with the compiler tools of Google's protocol buffer framework.

## Tutorial

In this tutorial we're going to connect the HeuristicLab 3.3 Optimizer with the Race Car Setup Optimization Competition that was organized for the EvoStar 2010 conference. Unfortunately the submission is already closed for this year, but let's hope there will be another competition hopefully in 2011.

The problem is a classic "simulation-based optimization problem" so there is a simulator, a simulation model, and several configuration parameters that have to be optimized. Additionally there might or might not be noise present in the evaluation of a configuration. More concretely the simulator is called TORCS, the simulation model consists of a certain simulated driver that tries to race as fast as possible and the configuration parameters are various settings of the race car that can be tuned. The challenging part in this problem is the limitation of the number of simulation time. Each optimizing run is given a certain number of simulation time in which the best parameter has to be found. Each solution is evaluated with a certain slice of that simulation time. It is possible to choose the size of this slice such that one evaluates a shorter time, with more noise on the quality values, but with a bigger number of possible evaluated solutions or a longer time with less noise, but the algorithm can calculate fewer generations. The driver in the simulation model starts where it left off after the last configuration, so there is some noise that depends on the driver's position on the track and some that depends on the previous configuration, which could have sent the driver off the track.

To prepare for this tutorial there's a couple of things that we need to obtain.

2. Download the Windows Server, Java Client and the manual from http://cig.dei.polimi.it/?page_id=103

Once you're done, you should get a latest copy of HeuristicLab 3.3 and unzip it into a folder or [DevelopersManual#BuildSources build it from source] using Visual Studio. We're now going to configure the problem in HeuristicLab and then take a look at the client and finally let it run.

### Configuring the Race Car Configuration Problem in HeuristicLab

In the Optimizer we select New from the File menu and choose the External Evaluation Problem from the list of Creatables among which we find the section Problems. You may have to scroll down a little until you reach the Problems.

Now we are presented with a new External Evaluation Problem such as we have seen in the architecture description above. It shall be shown here again.

So, first let's give the problem a proper name and a proper description so that when we load the problem later we know what this is all about.

• In the title type "Race Car Configuration Problem (EvoStar 2010)"
• In the description type "Problem that represents race car configuration challenge of EvoStar 2010"

Now we want to configure the solution representation and for this purpose we click the operator called SolutionCreator and get following screen.

We can examine the operators parameters by selecting the "Parameters" tab, and we will see that there is only a "Successor" parameter defined which is null. This parameter defines the next operator that would be executed after the SolutionCreator, but we don't need to bother with this parameter in this case and switch back to the "Operators" tab. There is a button with a yellow plus icon that we're going to press.

The type selector appears that has the ability to show every HeuristicLab object, but in this case, because the SolutionCreator exposes a list of only IOperators we see a dialog with only operators to choose from. We're interested in creating our solution representation and given that our simulation model expects a vector of real values that describe the car's configuration, we will look into the HeuristicLab.Encodings.RealVectorEncoding namespace. Click on the "+" infront of that namespace to list all the available operators there.

That is quite a list of operators, but don't get confused. From the names we can see what they are doing, there are several crossovers, manipulators, and a few other operators. Each of these operators has a description that you can see when you click onto it. The description is very helpful in describing what the operator does and there are even references to publications for operators that are taken from the literature. The one operator we are looking for to create a vector of real values is the UniformRandomRealVectorCreator. Look for it in the list down the bottom and click OK.

Views are usually nested in each other and when you click on the operator you should see its view opening to the right. If you can't see the operator's details due to low screen resolution you can double click the operator and it will open in a completely new view and in a new tab next to the tab of the problem.

What we have to do next is configure this operator. We see in the operators details that it has five parameters: Bounds, Length, Random, RealVector, and Successor. Like before we can ignore the Successor parameter, but the other 4 are interesting to us. You can click on any of these parameters to get a helpful description in the parameter's own view (which is nested again), you can also double click a parameter to open a view in a new tab. The Bounds parameter tells us that it represents "A 2 column matrix specifying the lower and upper bound for each dimension. If there are less rows than dimension the bounds vector is cycled." This is very helpful information indeed! We know, from reading the challenge's manual that the solution vector is bound in every dimension by 0 and 1 and now we have two choices. We could now click on the button with the pencil icon and create a new Bounds matrix directly in the parameter of this operator or we can set the Actual Name of this parameter to the name of the parameter that we create in a higher level. If we'd create the parameter directly in the parameter, other operators do not have access to it and because the Bounds are also needed in other operators like Crossover and Mutation it is a better idea to create the bounds matrix at the problem level.

So we click the yellow plus icon in the parameters list of our problem (marked in the following screenshot). If you have opened the operator in a new tab, switch to the tab of our problem (it starts with "Race Car Configuration...").

Again we see a dialog similar to the type selector.

This time it is restricted to all kinds of IParameters of which there are some in the HeuristicLab.Parameters namespace. There are several kinds of parameters of which there are two important types:

1. Lookup parameters
2. Value parameters

Lookup parameters do not have a value of their own, but rather search for this value in a higher scope. Value parameters on the other hand contain a value of their own and do not look for the value in a higher scope. The combination of the two is a ValueLookupParameter that either has a value in which case it will not look in a higher scope or it does not have a value in which case it will look in a higher scope. So it's the best of the two worlds. Usually when a parameter can be either set directly or looked up a ValueLookupParameter is well suited. The Bounds parameter for example of the solution creator is such a parameter. In this case however, we're at the problem scope and there's no higher scope so what we need is a new ValueParameter<T>. The <T> basically states that we have to define the type of the parameter and that we could make a parameter of IOperator for example or in our case, we need a ValueParameter<DoubleMatrix>. So we select the ValueParameter, after which a new field becomes visible.

Click the "T" in this box and the pencil button on the right to set the type. You're presented with a new window of the type selector that you now know already. You can type "matrix" in the search text box which limits your choices to just a few types, among them the DoubleMatrix. Double click the DoubleMatrix and see how the textbox now says "T: DoubleMatrix". Finally we need to give the parameter a name. Because our real vector solution creator expected it to be called Bounds, it is less configuration effort if we also just name this parameter Bounds. We can also add a description to remind us again what this parameter describes. Let's type: "Defines the upper and lower bounds for the solution vector." It should look like in the next screen before you click OK.

Now we need to assign the Bounds, so we click the newly created parameter in the parameter list and click the pencil icon in its detail view just under "Value".

That's simple! Select OK.

Now you should configure the Bounds matrix. Remember the description from the Bounds parameter of the SolutionCreator: Each row specifies the lower and upper bound for each dimension, if there are less rows than dimensions the rows are cycled. Because all our parameters will have the same bounds we just need to set 1 row and 2 columns and put 0 and 1 in the respective cells. It should look like in the next screenshot.

Now we have the bounds for our vector defined at the problem level and every operator that needs these bounds can find them if they have a LookupParameter or ValueLookupParameter defined for it. Let's go back to our UniformRandomRealVectorCreator. Click on SolutionCreator and there it is in its operators list. If you have opened the tab earlier you can also just switch to that tab. The next parameter that we're going to examine is the Length parameter. This defines the length of our solution vector. This is not a parameter that will not be used by other operators that we encounter in this tutorial, so we just set the value directly there. Click the pencil icon. If that pencil icon is hidden to you, again due to screen resolution just double click the Length parameter and perform the actions in the tab. Close this tab again when you're done.

In the upcoming dialog confirm that it is an IntValue and click ok to create the value. Our solution vector is of length 22, because according to the manual we have 22 values to optimize so insert that number in the value text box. If you can't see the value text box, double click on the Length parameter.

Let's look at the other parameters. There's Random next and then there is RealVector. If we click on RealVector we see that this is the name of the variable that will house our solution vector. We can change this to another name by setting the Actual Name, but since this is our only vector we can leave it at that.

So we have defined our SolutionCreator! Now we need to define the Evaluator, specify some operators to manipulate that real vector and finally specify the connection to our evaluation service.

#### Configuring the Evaluator

The evaluator in our case is an external application, the TORCS simulator. The Evaluator in the External Evaluation Problem is the operator that performs the task of collecting the solution variables, including them in a message and sending that message via the Client to the external process. If we click on the Evaluator we see a similar view to the SolutionCreator. However the Operators tab in the SolutionCreator is now named "Collected Values". First lets examine the Parameters tab which lists the parameters of this Evaluator. We can see that there are four parameters: Client, MessageBuilder, Quality, and Successor. The Client again is a ValueLookupParameter and its Actual Name is the same as the actual name of the ValueParameter that is defined under the problem parameters. The MessageBuilder is more interesting for us.

As you can see there are a number of different converters. These are used to transform the value found in the scope to a variable of a SolutionMessage. This message is in turn sent to the external process, so here we can influence how our solution objects are represented in the solution message. When you define a new ExternalEvaluationValuesCollector these are the default converters that are preselected. They will transform any type that is available in HeuristicLab.Data and also derived types. Our representation is a RealVector object which lives in the HeuristicLab.Encodings.RealVectorEncoding namespace. Let's take a look at the class definition of RealVector:

public class RealVector : DoubleArray

We see that it derives from DoubleArray and if we look at the definition of DoubleArray we see that it derives from ValueTypeArray<double>. When you now however over the DoubleConverter to get the tooltip you can see that it indeeds converts a ValueTypeArray<double> among others and thus also our derived RealVector. We can uncheck or remove the others, but there is no harm in leaving them.

For writing your own solution representation you can also write an own encoder. All you have to do is implement IItemToSolutionMessage, add your code as HeuristicLab plugin and you can add your converter using the yellow plus button. Note that if you have several converters for a given type, the last added converter will be used for that type.

So in our case there exists a converter which will convert the RealVector into a DoubleArrayVariable and add it to the SolutionMessage's DoubleArrayVars.

The last parameter we're going to look at is called "Quality" and denotes the variable that houses the fitness value. Let's leave its Actual Name as it is. And let's go back to the "Collected Values" tab instead.

As you may have guessed the next thing we're going to do is to tell the ExternalEvaluationValuesCollector which variables that it should hand to the converters to include in the solution message. Of course we want to send the RealVector, so we're going to add a parameter where to find that vector. You probably now know already how this works, basically it should look like in the following screenshot. This time we use a simple LookupParameter because this parameter always should be looked up.

If we now switch back to the Parameters tab, we can also see that there is a RealVector parameter there. All parameters that we add to the "Collected Values" appear also under Parameters.

Next in the configuration of the problem and right below the Evaluator we can see another parameter called Maximization. This tells the algorithm wether it should attempt to increase the quality value (if Maximization = true) or decrease it otherwise. From the possible fitness values we obtain from the simulator there's top speed and distance which we likely want to increase and damage which we want to decrease. Overall, because the ExternalEvaluationProblem is a single objective problem we have to calculate a single fitness value and it's likely that we want to maximize distance, so we set this to true here.

We can change this parameter also at any later time.

#### Configuring the operators

So let's add some Operators that we can get a GeneticAlgorithm going. Click the Operators parameter right below the Maximization parameter and again we see a list with one operator already present.

The BestScopeSolutionAnalyzer is a generic analyzer operator that will output the best found solution so far as a result of the algorithm. You can examine its parameters, but there should be no reason to change. Note however, that it expects a variable "Quality" so if you renamed that parameter in the Evaluator you also have to set the corresponding Actual Name here.

What we want to do is add some operators for crossover and mutation of our real vector. So we click the yellow plus icon and open the HeuristicLab.Encodings.RealVectorEncoding namespace. We can select from the many crossover and manipulation (mutation) operators. For example add a DiscreteCrossover, a BlendAlphaBetaCrossover, and a SimulatedBinaryCrossover. Click all of them to examine their parameters. Some operators have parameters that can configure their behavior. Make sure that each of their Child and Parents parameters has its Actual Name set to RealVector. The parents are RealVectors and the children are also again called RealVector. If you look at the BlendAlphaBetaCrossover you can see that you can also set the values for Alpha and Beta which determines to which extent the offspring should be closer to the better parent. If you double click the description of this crossover you can also see that in a new window and you see the publication that describes this crossover.

Let's also add a manipulator and let's take a UniformOnePositionManipulator. Don't forget to also examine its parameters. If an operator is new to you, always be sure to check what kind of parameters it requires and if the Actual Name points to the right parameter or variable.

It's a good idea to save the problem so far. You can do that by selecting the tab with the problem, then go to the Edit menu and select "Copy to Clipboard". This will place a clone of that item in the clipboard. So when you continue editing in the current window these changes will not be synced with the clipboard! Thus close the problem tab and open again the problem from the clipboard by double clicking it. That way we are directly modifying the problem in the clipboard. Press the disk icon in the clipboard window (not the one in the toolbar) to save the clipboard to the disk.

The clipboard will be loaded every time the HeuristicLab optimizer is started. It is not saved automatically though, you have to manually save it after making the changes.

### Configuring the client

Finally, the last task is to configure the EvaluationServiceClient in the problem, but we don't yet have an endpoint for that client. So we should start with the example client from the competition's website. Go to the competition's website and download the "Java Client" if you don't have already. Unpack that into a folder and open it using your favorite Java IDE - which is Eclipse in my case. Get an overview of the software, it has two packages: evaluator and ga. The !SimpleGA should give us a good overview of what we need to do to communicate to the TORCS driver. Create a new package "heuristiclab" and add a client there to connect our optimization environment. Be sure to include the java service library that you find under attachments and which was described in more detail above.

Here is the code that I have written using the framework.

public class HLEvaluator {
private ServerCommunication simulation;
private double bestQuality;

public static void main(String[] args) {
HLEvaluator main = new HLEvaluator();
main.run();
}

private void run() {
ServerSocketListenerFactory factory = new ServerSocketListenerFactory(8844);
PollService service = new PollService(factory, 1);
service.start();

initializeSimulation();
bestQuality = Double.MIN_VALUE;

while (true) {
SolutionMessage solution = service.getSolution();

double[] params = getParameters(solution);
int time = getTime(solution);

try {
Double quality = (Double)simulation.launchSimulation(params, time);
updateBestParams(quality, params);
service.sendQuality(solution, quality);
} catch (Exception e) {
break;
}
}
simulation.close();
service.stop();
}

private double[] getParameters(SolutionMessage solution) {
SolutionMessage.DoubleArrayVariable paramVar = solution.getDoubleArrayVars(0);
List<Double> params = paramVar.getDataList();
double[] arr = new double[params.size()];
for (int i = 0; i < arr.length; i++) arr[i] = params.get(i).doubleValue();
return arr;
}

private int getTime(SolutionMessage solution) {
SolutionMessage.IntegerVariable timeVar = solution.getIntegerVars(0);
return timeVar.getData();
}

private void initializeSimulation() {
simulation = new ServerCommunication("localhost", 3001);
simulation.setFitnessFunction(new Fitness());
}

private void updateBestParams(double quality, double[] params) throws Exception {
if (quality > bestQuality) simulation.saveBest(params);
}

private class Fitness implements FitnessFunction {
public Object getFitness(double bestlap, double topspeed, double distraced, double damage) {
return new Double(distraced);
}
}
}

This means that by executing the client we open the port 8844 on this computer and listen for connections to HeuristicLab there. All solution messages are unpacked and the parameters passed on to the simulator. We receive a quality which our client again forwards to HeuristicLab, so it basically sits in between HeuristicLab and the TORCS simulator forwarding the messages and translating them from one format into another. This client will run as long as it receives an exception in which case it stops. That means when the simulator says that enough simulation runs have been performed we cut the connection to HeuristicLab which will again inform the user of an exception and that the algorithm has terminated. This is probably not the most convenient approach, but we are probably eager to get the optimization going and can improve this later on.

By writing that client we learned that we can also pass the time variable that defines the length of the solution evaluation to the simulator. We don't yet include that in our problem, but since that affects our algorithms and the amount of time they can calculate we should better include this as well.

#### Include additional information in the evaluator

So we go back to our problem, stored in the clipboard. We'll open it from the clipboard and add another parameter to it. It is a ValueParameter<IntValue> and we call it "SimulationTime".

The value of that parameter is null initially so let's assign it a value. Click the pencil icon, confirm the IntValue and input 600 as value. This is the default setting of the !SimpleGA and probably a good base to start from. We also need to transmit that parameter to the forwarding java client. Open the Evaluator parameter, add a new LookupParameter<IntValue> and also call it SimulationTime.

#### Configure the client in the HeuristicLab problem

Finally visit the Client parameter in our problem, you can see that it has a Channel parameter that is still null. We need to define the channel here. Because our java client listens for connections on a socket will be using an EvaluationTCPChannel. Click the Channel, create a new value using the pencil icon and select the TCP channel. Configure the TCP channel according to our java forwarding client.

If you start the java client now and press "Connect" you should be able to establish a connection. Be aware though that the client currently serves just a single connections. So if you disconnect, you have to restart the client.

### Optimize the problem

So now we have the problem configured, we have saved it so that we don't have to do that again, we have written the forwarding client and if the setup with the TORCS simulator was done right we have everything to start optimizing.

This is so simple it's just a few steps:

1. Create a GA by selecting File>New and select the "Genetic Algorithm".
2. Drag the problem from the clipboard into the empty Problem tab (note that this again creates a clone!)
3. Go to the Parameters tab and configure the GA as you like. Select among the crossovers and manipulators that you have added. Choose the Selection scheme (Proportional, Tournament, Linear Rank,...). Choose the number of Elites, the mutation probability and population size.
4. Start the TORCS simulator and select the race that you want to evaluate on (look in the manual to see how this is done). I start the simulation using "wtorcs -nofuel -nodamage -nolaptime". To start a race I choose "Race > Practice > New Race".
5. Start the java forwarding client
6. Click the green arrow button at the bottom of the Genetic Algorithm and watch the optimization run.


text:
Proof - Product of Any Number and Zero is Zero.

I don't understand why this proof is valid. The proof just swaps the left and right hand side of the equality. Is this a valid method of proof for equalities? If so, what's the logical intuition behind it?

Theorem: $0⋅a = 0$ for any integer $a$.

\begin{align} 0 + \color{Green}{0⋅a} = 0⋅a & = (0 + 0)⋅a \\ & = 0⋅a + \color{Green}{0⋅a} \end{align} by using the identity property twice and then the distributive law. Use cancellation on the first and last piece to get $0 = 0⋅a$

Edit:

The problem is not algebra. I don't understand why transforming $0.a =0$ to $0=0.a$ proves this. I mean to prove $a=b$ , we transform it to $b=a$ ,why is it a proof method. What logic does it depend on ?

-
Make a list of all the properties that you have assumed and are allowed to use. Each step in your deduction can be justified by appealing to these assumptions, hence the proof is valid. –  Per Manne Sep 16 '12 at 13:36
I think it is important to understand the question first. You did not write what $a$ means, but I assume that you are working in arbitrary field and the goal is to show $0\cdot a=0$ using nothing but the axioms from the definition of field. –  Martin Sleziak Sep 16 '12 at 13:58

You did not start with $0\cdot a = 0$. What happened is that you started with $0+0\cdot a$, proved that $0+0\cdot a = 0\cdot a + 0\cdot a$ using identities, and ended up with $0 = 0\cdot a$ which is equivalent to saying $0\cdot a = 0$.

-

The first equality is true since $0$ plus any element is that element

The second equality is true since $0=0+0$ by the same axiom used to get the first equality

The third equality is true since we use the distributive law

Finally, we reduce $0\cdot a$ from both sides (or in other wording: we add the inverse in respect to addition of $0\cdot a$ to both sides) to get $$0\cdot a-0\cdot a=(0\cdot a+0\cdot a)-0\cdot a$$ i.e. $0=0\cdot a$

-

you want to prove

$$0\cdot a = 0$$

assume, where x is any number

$$0\cdot a = x \tag{1}$$

We know that

$$0\cdot a = (0+0)\cdot a$$

so

$$(0+0)\cdot a = x$$

$$0\cdot a + 0\cdot a = x\tag{2}$$

subtracting $(2)-(1)$

$$(0\cdot a + 0\cdot a) - (0\cdot a) = x-x = 0$$

that is

$$0\cdot a + 0\cdot a = 0\cdot a$$

so

$$0\cdot a = 0\cdot a - 0\cdot a$$

as a result

$$0\cdot a = 0$$

-
this is nice tnx –  mehdi Sep 16 '12 at 13:59


text:
# HTML Templates with Substitutable Areas - PHP

In order to separate my views (markup) and code, I elected to write my views like this:

    <!DOCTYPE HTML>

<title>%PAGE_TITLE%</title>
<meta charset="UTF-8">
<link href='PotatoDocs/views/stylesheets/docs2013.css' type='text/css' rel='stylesheet'>
<link rel="shortcut icon" href="favicon.ico" />

<link rel="stylesheet" href="highlight.js/styles/default.css">

%PAGE_TITLE%

%CONTENT%

%SIDEBAR%

Potato Seed 2013

A method then replaces the substitution area with parts of the website, like so:

    private function generatePageSource($page_title) {$page_template = file_get_contents(REGISTRY_CODE_PATH . "views/templates/" .
$this->template_dir . "/main.html");$page_content = str_replace("%PAGE_TITLE%", pdisplay($page_title),$page_template);
$page_content = str_replace("%CONTENT%",$this->pagecontent_content, $page_content);$page_content = str_replace("%SIDEBAR%", $this->sidebar_content,$page_content);

$this->page_content =$page_content;
}

The $this->page_content is later echoed. Not too relevant to my question, but for the sake of completion, this is the pdisplay() function. function pdisplay($pdisplay)
{
$pdisplay = htmlentities(stripslashes($pdisplay), ENT_QUOTES);
return $pdisplay; }  My question is this (though I accept any code criticism at all): is this a sensible way to render pages? I used to implant php tags with echoes onto a page -- but this meant that code (even a little bit) was on the views, so I thought this would be a better solution. • This is a sensible way to render pages, but why not use Twig, or Smarty, or even Savant? – jsanc623 Aug 15 '13 at 19:33 • I considered a template engine -- but for what I needed, this simple solution seemed to work best. – Racktash Aug 15 '13 at 20:42 • It's fine but a bit limited. Will you ever want to share the same head template between multiple pages? Or perhaps the side bar? Once you move past one template per web page then it can quickly get complicated. – Cerad Aug 18 '13 at 20:27 ## 1 Answer According your comment you don't want to use a template engine, but are actually creating a new one. At some point you will need loops or ifs and it starts becoming ugly. PHP is already a template engine. Actually it was designed for exactly this purpose. There is a braceless/echoless syntax for all control structures. Your template/view: <!DOCTYPE HTML>   <title><?=$page_title?></title>
...

<?=$page_title?>
 <?=$content?>

...

Your controller:

private function generatePageSource($page_title) {$page_title=pdisplay($page_title));$content = $this->pagecontent_content; ob_start();$template=REGISTRY_CODE_PATH . "views/templates/" .
$this->template_dir . "/main.html"; include$template;
\$this->page_content=ob_get_clean();
}

Of course you could wrap this in a View class to DRY.

• Thanks for the reply. Currently, my loops reside in the controllers -- which then use more templates to build up the inner contents of the page. The sidebar has another template to describe how the navigation links will look. This template becomes the string for %SIDEBAR%. – Racktash Aug 16 '13 at 7:14
• I tried this approach some year ago, but as soon as the structure gets a little more complex you have a lot of templates. So it will be really hard to change your layout afterward as you also have to change your controller in most cases. Separation of logic and representation does not mean that there is not something like a representation logic (displaying a list, conditional style classes, etc.) which belongs to the representation. – mheinzerling Aug 16 '13 at 7:43
• +1 for pointing out that php is in fact a template engine and a really good one. I would however opt for one of the realy good engines out there. Personally I favor twig since it is part of Symfony – Pinoniq Aug 19 '13 at 12:36


text:
# DPF2015

4-8 August 2015
America/Detroit timezone

## Radiative B decays as probes of physics beyond the Standard Model (BSM)

5 Aug 2015, 16:15
15m
Vandenberg (Michigan League)

BSM Collider

### Speaker

Zhirui Xu (Ecole Polytechnique Federale de Lausanne (CH))

### Description

The LHCb experiment has performed during Run-I of the LHC several studies sensitive to physics that may affect, among other observables, the polarisation of the emitted photon and the branching fractions of several decay modes. In this talk, the latest results on radiative decays are presented, which access different sources of physics BSM: on one side, the branching fraction of the $B_s^0\to J/\psi\gamma$ decay is sensitive to the presence of a charged Higgs, and, on the other, the $B_s^0\to\phi\gamma$ time-dependent CP asymmetry gives access to the polarisation of the photon, which can be affected by the existence of right-handed currents or the MSSM.
Oral or Poster Presentation Oral

### Primary author

Zhirui Xu (Ecole Polytechnique Federale de Lausanne (CH))