How to pass address of Objective C function to a C function?

I am working with PJSIP for SIP calling ios application. As the library is written in C some callback C methods expecting address of a Objective C function. I have tried to do

ua_cfg.cb.on_incoming_call = &[self on_incoming_call:<#(pjsua_acc_id)#> _:<#(pjsua_call_id)#> _:<#(pjsip_rx_data *)#>] 

but of course it does not work as I dont know what to pass as parameters to the function, neither it’s giving me the address of the function.

How can I make it work? The C function which is expecting this looks like below

void (*on_incoming_call)(pjsua_acc_id acc_id, pjsua_call_id call_id,                  pjsip_rx_data *rdata); 

How to decide an Objective Function?


In the Njaba river basin, the available water was allocated for the purposes of consumption, irrigation, and electric power supply among three communities. The water allocated per annum per capita for all use in these communities are 10m3 , 10m3 and 30m3 . The allocations were made based on the critical factors of population, land area and the industrialization. The populations of the communities are 300, 200, and 100, power supply capacities are 20W, 10W and 20W while the land areas for irrigation are 50 hectares, 40 hectares, and 30 hectares respectively. Allowable allocations limits of more than 300, 100 and 80 were stipulated for the purposes. Using the above information, formulate, (a) Linear Programming Model for the basin. (b) Maximization the allocations made Assume non-negativity condition?


I’m learning this course for the very first time so for understanding this subject and it’s problems, I’m trying to solve different problems. I’m recently solving this problem showing above. As it is a solved example I found on the internet, here’s the objective function and constraints.


Let the three communities be denoted by the variables x, y, and z. The objective function should be based on the allocation per annum, per capita for the basin as stated;

Z = 10x + 10y + 30z

The constraints can be formulated thus;

300x + 200y + 100z > 300 20x + 10y + 20z > 100 50x + 40y + 30z > 80

Under the negativity conditions of

X, Y, Z > 0


My confusion is writing an objecting function in this question. When different communities are supplied water for different use then it’s obvious that usage of water in every community for different use is different. Like annually, per person usage of water would be different. If a person is using water only for domestic need the whole year, they are nothing to do with the irrigation and electric power supply so how could this line be justifiable that

*The water allocated per annum per capita


for all use


in these communities are 10m3 , 10m3 and 30m3 *?

like every single person is allocated water for all uses like for basic consumption, irrigation, electric power supply means they’re providing extra water?

Hope so everyone is getting my question and will sort out my query so I better solve questions on my own.

The objective of this assignment is to make a c function that takes a string, truncate it into words and writes them in a mirror: [on hold]

Eg. a call in the main to

mirror(“Hello my name is me”); // will print in the terminal:

olleH * ym* * eman* * si* * em*

To solve the exercise you will have to:

  1. truncate words in the sentence based on ‘ ‘ (space). What can you use to save multiple strings? (hint we saw it in last class )
  2. You will need a multidimensional array to store the mirror: count the biggest word +2 to get the number of column for the array to store the result. (That is also the number of stars(*) to save as first and last row of the array) number of rows will be number of words +2 to count the rows of *
  3. reverse each word (remember to put a * before and after it when you save it in the corresponding rows of the array)
  4. print the array

Does anyone can help me ?

Can the partial concavity of the following decomposable objective function be used for optimization?

The problem I am trying to solve is the following:

$ $ \begin{array}{ll} \min & f(x)+g(y) \ \mathrm{s.t.} & y\ge x\ge 0,\ \ & p\le ax+by\le q, \end{array}$ $ where $ a,b,p,q$ are positive real numbers. Call this problem $ (P_1). $ Here $ f,g$ are smooth functions such that $ f$ is a non-negative, concave, increasing function, while $ g$ is an increasing, possibly non-convex/non-concave function.

Consider another optimization problem, $ $ \begin{array}{ll} \min_y & \min_i\{f(v_i)\}+g(y) \ \mathrm{s.t.} & q/b\ge y\ge 0, \end{array}$ $ where $ v_i$ are the vertices obtained as intersections of the constraints $ y\ge x\ge 0$ , and $ p-by\le ax\le q-by$ , i.e., $ v_1=\max\{0,(p-by)/a\},\ v_2=\min\{y,(q-by)/a\}$ . Call this problem $ (P_2)$ .

My question is,

Are $ (P_1)$ and $ (P_2)$ equivalent?

I think the answer is yes. My rationale is that because of the concavity of the function $ f$ , when $ y$ is treated as a fixed variable, the function is minimized at one of the above mentioned vertices. Then using that value of $ f$ we find the final minimum value by optimizing with respect to $ y$ . However, I have two concerns:

1) Are my constraints for $ y$ (in $ (P_2)$ ) correct?

2) Can this approach, if correct for this two variable case, tractably extended to multi-variable scenarios?

3) If the answer to the point 2) above is positive, is there any tractable way of finding the vertices from problem $ (P_1)$ , which are to be used in problem $ (P_2)$ ?

Finally, is there any relevant literature on this approach. Please help. Thanks in advance.

Probabilistic method with multiple objective functions

Let $ \mathcal X$ be a finite set and $ f$ a function from $ \mathcal X$ to $ \mathbb R$ . Basic probabilistic method says that if I can find a probability distribution on $ \mathcal X$ and show that $ E[f(X)]\leq \epsilon_1$ (where $ X$ is a random variable with that probability distribution), then there exists a $ x_0\in\mathcal X$ such that $ f(x_0)\leq \epsilon_1$ .

My question is: suppose I have an additional objective function $ g:\mathcal X\mapsto\mathbb R$ . How could I use the probabilistic method to show that there exists a $ x_0\in\mathcal X$ , such that $ f(x_0)\leq \epsilon_1$ and $ f(x_0)\leq \epsilon_2$ .

If I use the basic methods twice, meaning that if I could show $ E[f(X)]\leq \epsilon_1$ and $ E[g(X)]\leq \epsilon_2$ , it does not imply that there is one $ x_0$ that satisfies both inequalities.

One way to solve this is to show $ E[f(X)+g(X)]\leq \min\{\epsilon_1, \epsilon_2\}$ . But I suspect that there is a more general and more elegant solution to this problem.

Biconvex problem whose objective function depends on only one variable

I am solving the following biconvex problem: $ $ \min_{x,y} f(y)$ $ $ $ s.t. ~~ g(x) \leq 0$ $ $ $ ~~~~~h(x,y) = 0$ $ $ $ x \in X, y \in Y$ $ where $ X$ and $ Y$ are compact convex sets, $ g(x)$ and $ f(y)$ are convex and $ h(x,y)$ is affine for fixed $ x$ or $ y$ . I wonder if there is any efficient algorithm to solve this type of optimization problem, not restricted to algorithms for general biconvex optimization problems.

Can we say McCarthy and Hoare had the same objective in the 60s regarding a mathematical theory of computation?

I don’t think there’s any way to ask a very precise question here, so this might be considered opinion based. Nevertheless, it seems the question is clear enough because I’m asking whether these two initial steps towards a theory are trying to achieve the same thing. It seems to me Hoare went towards an imperative-calculus and McCarthy went towards a functional-calculus for deriving programs hand in hand with mathematical proofs. Can we say they both went towards that each in different (imperative, functional) ways?

I’m comparing A Basis for a Mathematical Theory of Computation by John McCarthy with An Axiomatic Basis for Computer Programming by Sir Charles Anthony Richard Hoare.

To me the main contribution (or the most interesting part) of McCarthy’s paper is given in section 3.2, recursion induction, where he exemplifies how one can prove two algorithms being equivalent — algorithms as specified by the language defined in the paper. (I possibly have this opinion because to me so much of his work is no news, since I’m familiar with Lisp and recursion.)

My understanding it at least partially confirmed by what he says right in the introduction [introduction, point 2, page 2].

To define a theory of the equivalence of computation processes. With such a theory we can define equivalence preserving transformations. Such transformations can be used to take an algorithm from a form in which it is easily seen to give the right answers to an equivalent form guaranteed to give the same answers but which has other advantages such as speed, economy of storage, or the incorporation of auxiliary processes.

Extra-credit. It seems Dijkstra followed along Hoare’s approach because even after the 70s he kept on using precisely Hoare’s notation, introduced in Hoare’s paper in 69. I would appreciate answers also linking Dijkstra’s opinion on the matter — although really not required.

How UUID is generated in Objective C or Swift

I understand that UUID is generated based on bits given by timestamp.

For instance, if two iOS devices at the exact same time executes the following statement then what possibility is there that it will generate same uuid?

let uuid = NSUUID().uuidString 

If uuid is combination of more than just timestamp, what is the internal logic using which UUID is generated?