Fitting Experimental Data To SRK-Type Equation of State. Minimization

I’m trying to find parameters to fit an EoS to saturation pressures to different temperatures.

My experimental data are like this


Then I defined a function to calculate saturation pressures

psat[T_, p0_, Tc_, a0_, b_, c1_, E11r_, v11_] := (Do[    p[0] = p0;    f11 = Exp[-E11r/T] - 1;    m11 = v11*f11;    a = a0*(1 + c1*(1 - Sqrt[T/Tc]))^2;    \[Alpha] = p[i]*a/(R*T)^2; (* Dimensionless groups*)    \[Beta] = p[i]*b/R/T;    \[Gamma] = p[i]*m11/R/T;    d0 = -\[Gamma]*\[Beta]*(\[Beta] + \[Alpha]);(*Coefficients of the equation*)    d1 = \[Alpha]*(\[Gamma] - \[Beta]) - \[Beta]*\[Gamma]*(1 + \[Beta]);    d2 = \[Alpha] - \[Beta]*(1 + \[Beta]);    d3 = \[Gamma] - 1;    d4 = 1;    polin = d4*z^4 + d3*z^3 + d2*z^2 + d1*z + d0;    Raices = NSolve[polin == 0, z, PositiveReals]; (* Solving the 4th grade polinomy for compressibility factor*)    zv = Max[z /. Raices];    zl = Min[z /. Raices];    vv = zv*R*T/p[i];    vl = zl*R*T/p[i];    ln\[CapitalPhi]v =      zv - 1 - Log[zv] + Log[vv/(vv - b)] + a/b/R/T*Log[vv/(vv + b)] +       Log[vv/(vv + m11)]; (*Fugacity coefficients*)    ln\[CapitalPhi]l =      zl - 1 - Log[zl] + Log[vl/(vl - b)] + a/b/R/T*Log[vl/(vl + b)] +       Log[vl/(vl + m11)];    \[CapitalPhi]v = Exp[ln\[CapitalPhi]v];    \[CapitalPhi]l = Exp[ln\[CapitalPhi]l];    p[i + 1] = p[i]*\[CapitalPhi]l/\[CapitalPhi]v,    {i, 0, 9}];   p[9])  

Where T is the temperature, p0 is the initial guess for pressure, Tc is the critical temperature and a0, b, c1, E11r, v11 are the equation’s parameters.

Up to this point, we have a saturation pressure calculator, given the parameters, and it works just fine, now the thing that I can’t seem to solve is fitting it to my experimental data, by minimizing an objective function, which is:

enter image description here

I declared it like this:

F[a0_, b_, c1_, E11r_, v11_] :=   Sum[(psat[psatx[[k, 1]], psatx[[k, 2]], Tcaceto, a0, b, c1, E11r,        v11] - psatx[[k, 2]])^2/psatx[[k, 3]]^2, {k, 200}]; (* I declared the Tc as "Tcaceto", a constant, and I use as initial guess for each psat calculation the experimental pressure*) 

And then I just used NMinimize, in this way.

NMinimize[F[a0, b, c1, E11r, v11], {a0, b, c1, E11r, v11}] 

I run it, and it just never finishes. I don’t know what could be the thing that doesn’t work, I’ve tried setting the method, starting points, but the result is the same. I would really apreciate if someone helped me in this matter. Thanks.

Nim state evaluation heuristic function for Negamax/Minimax

I am trying to implement Nim game with Negamax algorithm.
Rules of the game: there are three heaps filled with coins. The player who gets the last coin loses.

I am looking for an heuristic function to evaluate each state.

So far what I’ve done is:

int Nim::eval(int player)     {         if(ended()){             return -Inf;         }          int notFavorable = 0;          for(int i = 0; i < HEAPS_NUMBER; i++){             if(2 <= heaps[i] && heaps[i] <= 4){                 continue;             } else if(heaps[i] == 1){                 notFavorable++;             } else if (not((heaps[i] - 3) % 2 == 0 || (heaps[i] - 3) % 4 == 0 || (heaps[i] - 3) % 3 == 0)){                 notFavorable++;             }         }          return notFavorable % 2 == 0 ? Inf : -Inf;     } 

Any suggestions?

How to reset MariaDB into a “fresh install” state?

I had InnoDB corruption and managed to start the server in read only mode and perform a fresh backup using innodb_force_recovery=5.

This way of starting the service puts the databases in read only mode, even deletion is disallowed.

Is there an official procedure to reset the whole server into a fresh installed (or at least “empty”) version?

And in case there isn’t, then what are the correct uninstall/reinstall steps to make sure there will be no remaining residues of data that could generate problems in the future?

A state space for river crossing puzzle

I am solving the river crossing puzzle with 6 participants. You must transfer all the people across the river in this flash game respecting the following rules:

The ferry can carry no more than 2 people. Only the Adults (mom, dad and policeman) can operate the ferry. Dad can not be in the presence of the girls w/out Mom Mom can not be in the presence of the boys w/out Dad The thief can not be alone with any of the family w/out the policeman.

We need to create the state space and as I am creating mine I am not sure if I am doing it properly.

In my case I represent the state as A/B where A are the people on the left side and B are the people on the right side. This is what I have so far. I feel like I will get a lot of states, so I am worried that I am doing something wrong. Is this correct?

enter image description here

Finite State Machine In hardware

I have to implement a state machine in some special hardware which has a lot of limitations. This hardware can be understood as a box that gets events as inputs and could output events.

The state machine is very small 3-4 states that are al connected as a ring 0->1->2->3->0 plus some states have loops with themselves. Thus the new state will always be either the same or current + 1 mod N.

A state change can be triggered by two things:

  1. A given event can trigger a state change.
  2. There is a global counter that increases every time an event arrives. If the counter reaches certain value (depending on the current state) that can trigger a state change.

The biggest problem is that every time an event arrives at the box I can only do the following:

  1. Read the counter value, increase it by one and save it in memory again.
  2. Read the current state and I have to compute instantaneously the next state and save it. Variables can not be accesses twice. Meaning that I can not read it, do a complex operation and then write the new state down. The only thing I am allowed to do is: I can define 2 simple boolean expressions of the form (+- current_state +/- variable (==, !=, >, >=,…) Constant. The output of those 2 bolean expressions can be used to decide how the state is updated. However the only thing you can do is: update the state in way A (i.e state+1), update state in way B (i.e state -1) and not modify it.

For example:

if expression1: state= state+1 if expresion2 and not expresion1: state= state-1

if not expresion1 and not expresion2: state = state.

I know it might be a bit confusing, but I did not find a better way to explain the hardware using a small text. I can clarify things.

Converting DFA to Regular Expression Using State Removal

I’m trying to convert the following NFA to a regular expression.

I’ve attached my work below and end up with the expression $ aa^*bb^*$ . As far as I can tell, this doesn’t seem correct but I’ve been working at it for quite a while. Can anyone tell me where I went wrong? And if it happens to be correct, can you tell me why?

Thanks a lot in advance.


Upon further work, I came up with the regular expression: $ aa^*b(b\cup aaa^*b)^*$ . This seems like the correct response.

Can you be in a perpetual state of short/long rest?

Based on this question: Does the Aspect of the Moon Eldritch Invocation effectively allow for unending Wild Shape?

In that question the OP is wanting to know if they could keep regaining use of wildshape to stay in wildshape for a week of downtime. Perpetual state of resting to me means that each hour of downtime would count as the end of a short rest or each 8 hours spent in downtime as the end of a long rest.

Is it possible to be in a perpetual state of short/long rest whether during downtime or not for the purpose of regaining class/racial features?

In other words: Can a PC use 16 short rests then an 8 hour long rest each day and continuously regain features that replenish on short rests?

Probability of terminating in a state in a probabilistic algorithm

Suppose i have a circular array of $ n$ elements. At time $ t=0$ i am in position 0 of the array. The algorithm moves left or right with probability $ p=1/2$ (since the array is circular when it moves left from 0 it goes to position $ n$ ). When i visited all the positions at least once the algorithm returns the position it terminated into.
Launching the algorithms many times shows that it stops with the same probability in any of the n positions (except for zero obviously). How do i demonstrate that the probability of ending up in each state is uniform?
My understanding is that this process is explained by a doubly stochastic Markov chain, but is there a theorem i can quote about this specific case?