class: center, middle ### W4995 Applied Machine Learning # Linear Models for Classification, SVMs 02/12/20 Andreas C. Müller ??? Today we're going to talk about linear models for classification, and in addition to that some general principles and advanced topics surrounding general models, both for classification and regression. FIXME: in regularizing SVM, long vs short normal vectors. FIXME do we need ovo? we kinda do, right? --- class: center, middle # Linear models for
binary
classfication ??? We'll first start with linear models for binary classification, so if there are only two classes. That makes the models much easier to understand. --- .center[ ![:scale 55%](images/linear_boundary_vector.png) ] $$\hat{y} = \text{sign}(w^T \textbf{x} + b) = \text{sign}\left(\sum\limits_{i}w_ix_i + b\right)$$ ??? Similar to the regression case, basically all linear models for classification have the same way to make predictions. As with regression, they compute an inner product of a weight vector w with the feature vector x, and add some bias b. The result of that is a real number, as in regression. For classification, however, we only look at the sign of the result, so whether it is negative or positive. If it's positive, we predict one class, usually called +1, if it's negative, we predict the other class, usually called -1. If the result is 0, by convention the positive class is predicted, but because it's a floating point number that doesn't really happen in practice. You'll see that sometimes in my notation I will not have a $b$. That's because you can always add a constant feature to x to achieve the same effect (thought you would then need to leave that feature out of the regularization). So when I write $w^Tx$ without a $b$ assume that there is a constant feature added that is not part of any regularization. Geometrially, what the formula means is that the decision boundary of a linear classifier will be a hyperplane in the feature space, where w is the normal vector of that plane. In the 2d example here, it's just a line separating red and blue. Everything on the right hand side would be classified as blue by this classifier, and everything on the left-hand side as red. Questions? So again, the learning here consists of finding parameters w and b based on the training set, and that is where the different algorithms differ. There are quite a lot of algorithms out there, and there are also quite a lot in scikit-learn, but we'll only discuss the most common ones. The most straight-forward way to approach finding w and b is to use the framework of empirical risk minimization that we talked about last time, so finding parameters that minimize some loss o the training set. Where classification differs quite a bit from regression is on how we want to measure misclassifications. --- # Picking a loss? $$\hat{y} = \text{sign}(w^T \textbf{x} + b)$$ `$$\min_{w \in ℝ^{p}, b \in \mathbb{R}} \sum_{i=1}^n 1_{y_i \neq \text{sign}(w^T \textbf{x} + b)}$$` .center[ ![:scale 40%](images/binary_loss.png) ] ??? So we need to define a loss function for given w and b that tell us how well they fit the training set. Obvious Idea: Minimize number of misclassifications aka 0-1 loss but this loss is non-convex, not continuous and minimizing it is NP-hard. So we need to relax it, which basically means we want to find a convex upper bound for this loss. This is not done on the actual prediction, but on the inner product $w^T x$, which is also called the decision function. So this graph here has the inner product on the x axis, and shows what the loss would be for class 1. The 0-1 loss is zero if the decision function is positive, and one if it's negative. Because a positive decision function means a positive predition, means correct classification in the case of y=1. A negative prediction means a wrong classification, which is penalized by the 0-1 loss with a loss of 1, i.e. one mistake. The other losses we'll talk about are mostly the hinge loss and the log loss. You can see they are both upper bounds on the 0-1 loss but they are convex and continuous. Both of these losses care not only that you make a correct prediction, but also "how correct" your prediction is, i.e. how positive or negative your decision function is. We'll talk a bit more about the motivation of these two losses, starting with the logistic loss. --- # Logistic Regression .left-column[ $$\log\left(\frac{p(y=1|x)}{p(y=-1|x)}\right) = w^T\textbf{x} + b$$ $$p(y=1|\textbf{x}) = \frac{1}{1+e^{-w^T\textbf{x} -b }}$$ `$$\min_{w \in ℝ^{p}, b \in \mathbb{R}} \sum_{i=1}^n \log(\exp(-y_i(w^T \textbf{x}_i + b)) + 1)$$` $$\hat{y} = \text{sign}(w^T\textbf{x} + b)$$ ] .right-column[ ![:scale 90%](images/logit.png)] ??? Logistic regression is probably the most commonly used linear classifier, maybe the most commonly used classifier overall. The idea is to model the log-odds, which is log p(y=1|x) - log p(y=0|x) as a linear function, as shown here. Rearranging the formula, you get a model of p(y=1|x) as 1 over 1 + ... This function is called the logistic sigmoid, and is drawn to the right here. Basically it squashed the linear function $w^Tx$ between 0 and 1, so that it can model a probability. Given this equation for p(y|x), what we want to do is maximize the probability of the training set under this model. This approach is known as maximum likelihood. Basically you want to find w and b such that they assign maximum probability to the labels observed in the training data. You can rearrange that a bit and end up with this equation here, which contains the log-loss as seen on the last slide. The prediction is the class with the higher probability. In the binary case, that's the same as asking whether the probability of class 1 is bigger or smaller than .5. And as you can see from the plot of the logistic sigmoid, the probability of the class +1 is greater than .5 exactly if the decision function $w^T x$ is greater than 0. So predicting the class with maximum probability is the same as predicting which side of the hyperplane given by w we are on. Ok so this is logistic regression. We minimize this loss and get a w which defines a hyper plane. But if you think back to last time, this is only part of what we want. This formulation tries to fit the training data, but it doesn't care about finding a simple solution. --- # Penalized Logistic Regression `$$\min_{w \in ℝ^{p}, b \in \mathbb{R}}C \sum_{i=1}^n\log(\exp(-y_i(w^T \textbf{x}_i + b )) + 1) + ||w||_2^2$$` `$$\min_{w \in ℝ^{p}, b \in \mathbb{R}}C \sum_{i=1}^n\log(\exp(-y_i (w^T \textbf{x}_i + b)) + 1) + ||w||_1$$` - C is inverse to alpha (or alpha / n_samples) ??? - Both versions strongly convex, l2 version smooth (differentiable). - All points contribute to $w$ (dense solution to dual). So we can do the same we did for regression: we can add regularization terms using the L1 and L2 norm. The effects are the same as for regression: both push the coefficients towards zero, but the l1 norm encourages coefficients to be exactly zero, for the same reasons we discussed last time. You could also use a mixed penalty to get something like the elasticnet. That's not implemented in the logisticregression class in scikit-learn right now, but it's certainly a sensible thing to do. Here I used a slightly different notation as last time, though. I'm not using alpha to multiply the regularizer, instead I'm using C to multiply the loss. That's mostly because that's how it's done in scikit-learn and it has only historic reasons. The idea is exactly the same, only now C is 1 over alpha. So large C means heavy weight to the loss, means little regularization, while small C means less weight on the loss, means strong regularization. Depending on the model, there might be a factor of n_samples in there somewhere. Usually we try to make the objective as independent of the number of samples as possible in scikit-learn, but that might lead to surprises if you're not aware of it. Some side-notes on the optimization problem: here, as in regression, having more regularization makes the optimization problem easier. You might have seen this in your homework already, if you decrease C, meaning you add more regularization, your model fits more quickly. One particular property of the logistic loss, compared to the hinge loss we'll discuss next is that each data point contributes to the loss, so each data point has an effect on the solution. That's also true for all the regression models we saw last time. --- # Effect of regularization .center[ ![:scale 90%](images/logreg_regularization.png) ] - Small C (a lot of regularization) limits the influence of individual points! ??? So I spared you with coefficient plots, because they looks the same as for regression. All the things I said about model complexity and dependency on the number of features and samples is as true for classification as it is for regression. There is another interesting way to thing about regularization that I found helpful, though. I'm not going to walk through the math for this, but you can reformulate the optimization problem and find that what the C parameter does is actually limit the influence of individual data points. With very large C, we said we have no regularization. It also means individual data points can have basically unlimited influence, as you can see here. There are two outliers here, which basically completely tilt the decision boundary. But if we decrease C, and therefore increase the regularization, what happens is that the influence of these outlier points becomes limited, and the other points get more influence. --- #Max-Margin and Support Vectors .center[ ![:scale 75%](images/max_margin.png) ] ??? A point is within the margin if 〖y_i w〗^T x is smaller than one. That means if you have a smaller w, you basically have a smaller margin given that you're on the correct side. If you're on the wrong side, you'll have always have a loss. If you're in the correct side, if you're w^x is small, then you also have a loss. --- class: center #Max-Margin and Support Vectors `$$ \min_{w \in \mathbb{R}^p, b \in \mathbb{R}} C \sum_{i=1}^n \max(0, 1 - y_i (w^T\mathbf{x} + b)) + ||w||^2_2 $$` $$\text{Within margin} \Leftrightarrow y_i(w^T x + b)< 1$$ Smaller $w \Rightarrow$ larger margin --- class: center #Max-Margin and Support Vectors .left-column[ ![:scale 80%](images/max_margin_C_0.1.png) ] .right-column[ ![:scale 80%](images/max_margin_C_1.png) ] ??? Here are two examples on the same dataset. Where I learned linear support vector machine with c-0.1, and c=1. With c=0.1, you have a wider margin. There are points inside the margin and all the points inside the margin are support vectors which contribute to the solution. Points that are outside of the margin and on the correct side doesn't contribute to the solution. These points are sort of classified correctly, not when they’re ignored. The normal vector is w and basically, the size of the margin is the inverse of the length of w. C=0.1 means I have less emphasis on the data fitting and more emphasis on the shrinking w. This will lead to a smaller w. If I have larger C that means less regularization, which will lead to a larger W, larger W means a smaller margin. So there are fewer points here, they are inside the margin and therefore, fewer support vectors. More regularization usually means a larger margin but more points inside the margin. Also, more support vectors mean there are more data points that actually influence the solution. --- # (soft margin) linear SVM .larger[ `$$\min_{w \in ℝ^{p}, b \in \mathbb{R}}C \sum_{i=1}^n\max(0,1-y_i(w^T \textbf{x}_i + b)) + ||w||_2^2$$` `$$\min_{w \in ℝ^{p}, b \in \mathbb{R}}C \sum_{i=1}^n\max(0,1-y_i(w^T \textbf{x}_i + b))+ ||w||_1$$` ] ??? - Both versions strongly convex, neither smooth. - Only some points contribute (the support vectors) to $w$ (sparse solution to dual). Moving from logistic regression to linear SVMs is just a matter of changing the loss from the log loss to the hinge loss. The hinge-loss is defined as ... And we can penalize using either l1 or l2 norm, or again, in principle also elastic net. This formulation with the hinge loss doesn't really make sense without the penalty, because of the formulation of the hinge loss. What this loss says is basically "if you predict the right class with a margin of 1, there is no loss". Otherwise the loss is linear in the decision function. So you need to be on the right side of the hyperplane by a given amount, and then there is no more loss. That's the reason you need the penalty, for the 1 to make sense. Otherwise you could just scale up $w$ to make it far enough on the right side. But the regularization penalizes growing $w$. The hinge loss has a kink, same as the l1 norm, and so it's not a smooth optimization problem any more, but that's not really a big deal. What's interesting is that all the points that are classified correctly with a margin of at least 1 have a loss of zero, and so they don't influence the solution any more. All the point that are not classified correctly by this margin are the ones that do influence the solution and they are called the support vectors. FIXME graph of not influencing the solution? --- class: center # Logistic Regression vs SVM .compact[ `$$\min_{w \in ℝ^{p}, b \in \mathbb{R}}C \sum_{i=1}^n\log(\exp(-y_i(w^T \textbf{x}_i+b)) + 1) + ||w||_2^2$$` `$$\min_{w \in ℝ^{p}, b \in \mathbb{R}}C \sum_{i=1}^n\max(0,1-y_i(w^T \textbf{x}_i + b)) + ||w||_2^2$$` ![:scale 35%](images/binary_loss.png) ] ??? So this is the main difference between logistic regression and linear SVMs: Does it penalize misclassifications according to the green line, or according to the blue line? In practice it doesn't make a big difference. --- # SVM or LogReg? .center[ ![:scale 80%](images/svm_or_lr.png) ] - Need compact model or believe solution is sparse? Use L1 ??? So which one of them should you use? If you need probability estimates, you should use logistic regression. If you don't, you can pick either, and it doesn't really matter. Logistic regression can be a bit faster to optimize in theory. If you're in a setting where there's many more feature than samples, it might make sense to use linear SVMs and solve the dual, but you can actually solve either of the problems in the dual, and we'll talk about what that means in practice in a little bit. --- class: center, middle # Multiclass classification ??? Ok, so I think that's enough on the two loss functions and regularization, and hopefully you have a bit of a feel for how these two classifiers work, and also an understanding that they are in fact quite similar in practice. Next I want to look at how to go from binary classification to multi-class classification. Basically there is a simple but hacky way, and there's a slightly more complicated but theoretically sound way. --- class: center # Reduction to Binary Classification .padding-top[ .left-column[ ## One vs Rest ] .right-column[ ## One vs One ] ] ??? The slightly hacky way is using what's known as a reduction. We're doing a reduction like in math: reducing one problem to another. In this case we're reducing the problem of multi-class classification into several instances of the binary classification problem. And we already know how to deal with binary classification. There are two straight-forward ways to reduce multi-class to binary classification. the first is called one vs rest, the second one is called one-vs-one. --- class: spacious # One Vs Rest For 4 classes: 1v{2,3,4}, 2v{1,3,4}, 3v{1,2,4}, 4v{1,2,3} In general: n binary classifiers - each on all data ??? FIXME terrible slide Let's start with One vs Rest. here, we learn one binary classifier for each class against the remaining classes. So let's say we have 4 classes, called 1 to 4. First we learn a binary classifier of the points in class 1 vs the points in the classes 2, 3 and 4. Then, we do the same for class 2, and so on. The way we end up building as many classifiers as we have classes. --- class: spacious # Prediction with One Vs Rest "Class with highest score" $$\hat{y} = \text{arg}\max_{i \in Y} \textbf{w}^T_i\textbf{x} + b_i$$ ??? To make a prediction, we compute the decision function of all classifiers, say 4 in the example, on a new data point. The one with the highest score for the positive class, the single class, wins, and that class is predicted. It's a little bit unclear why this works as well as it does. Maybe there's some papers about that now, but I'm not So in this case we have one coefficient vector w and one bias b for each class. --- # One vs Rest Prediction .center[ ![:scale 80%](images/ovr_lines.png) ] ??? Here is an illustration of what that looks like. Unfortunately it's a bit hard to draw 4 classes in general position in 2 dimensions, so I only used 3 classes here. So each class has an associated coefficient vector and bias, corresponding to a line. The line tries to separate this class from the other two classes. # Fixme draw ws? --- # One vs Rest Prediction .center[ ![:scale 80%](images/ovr_boundaries.png) ] ??? Here are the decision boundaries resulting from the these three binary classifiers. Basically what they say is that the line that is closest decides the class. What you can not see here is that each of the lines also have a magnitude associated with them. It's not only the direction of the normal vector that matters, but also the length. You can think of that as some form of uncertainty attached to the line. --- class: some-space # One Vs One - 1v2, 1v3, 1v4, 2v3, 2v4, 3v4 - n * (n-1) / 2 binary classifiers - each on a fraction of the data - "Vote for highest positives" - Classify by all classifiers. - Count how often each class was predicted. - Return most commonly predicted class. - Again - just a heuristic. ??? FIXME terrible slide The other method of reduction is called one vs one. In one vs one, we build one binary model for each pair of classes. In the example of having four classes that is one for 1 vs 2, one for 1v3 and so on. So we end up with n * (n - 1) /2 binary classifiers. And each is trained only on the subset of the data that belongs to these classes. To make a prediction, we again apply all of the classifiers. For each class we count how often one of the classifiers predicted that class, and we predict the class with the most votes. Again, this is just a heuristic and there's not really a good theoretical explanation why this should work. --- class: center # One vs One Prediction ![:scale 80%](images/ovo_lines.png) ??? Here is an example for predicting on three classes in 2d using the one-vs-one heuristic. In the case of three classes, there's also three pairs. Three is a bit of a special case, with any more classes there would be more classifiers than classes. The dashed lines are colored according to the pair of classes they separate. So the green and blue line separates the green and blue classes. The data points belonging to the grey class were not used in building this model at all. --- class: center # One vs One Prediction ![:scale 80%](images/ovo_boundaries.png) ??? Looking at the predictions made by the one vs one classifier the correspondence to the binary decision boundaries is a bit more clear than for the one vs rest heuristic, because it only takes the actual boundaries into account, not the length of the normal vectors. That makes it easier to visualize the geometry, but it's also a bit of a downside of the method because it means it discards any notion of uncertainty that was present in the binary classifiers. The decision boundary for each class is given by the two lines that this class is involved in. So the grey class is bounded by the green and grey line and the blue and grey line. There is a triangle in the center in which there is one vote for each of the classes. In this implemenatation the tie is broken to just always predict the first class, which is the green one. That might not be the best tie breaking strategy, but this is a relatively rare case, in particular if there's more than three classes. OVR and OVO are general heuristics not restricted to linear models. They can be used whenever a binary model for classification needs to be extended to the multi-class case. For logistic regression, there is actually a natural extension of the formulation, and we don't have to resort to these hacks. --- class: spacious .left-column[ ## One vs Rest - n_classes classifiers - trained on imbalanced datasets of original size - Retains some uncertainty? ![:scale 80%](images/ovr_boundaries.png) ] .right-column[ ## One vs One - n_classes * (n_classes - 1)/2 classifiers - trained on balanced subsets - No uncertainty propagated ![:scale 80%](images/ovo_boundaries.png) ] ??? If original problem was balanced, that is... --- # Multinomial Logistic Regression Probabilistic multi-class model: `$$p(y=i|x) = \frac{e^{\textbf{w}_i^T\textbf{x} + b_i}}{\sum_{j=1}^k e^{\textbf{w}_j^T\textbf{x} + b_j}}$$` `$$\min_{w \in ℝ^{pk}, b \in \mathbb{R}^k} -\sum_{i=1}^n \log(p(y=y_i|x_i, w, b))$$` $$\hat{y} = \text{arg} \max_{i=1,...,k} \textbf{w}^T_i\textbf{x} + b_i$$ - Same prediction rule as OvR ! ??? The binary logistic regression case can be generalized to multinomial logistic regression, in which we model the probability that i is one of the classes using this formula, which is also known as softmax. The probability is proportional to e to the minus $w^t x$ which is the same as in the binary case. But now we need to normalize it so that the sum over all classes is one. So we just divide it by this sum. --- class: some-space # In sckit-learn - OvO: only SVC - OvR: default for all linear models except for logistic regression - `LogisticRegression(multi_class='auto')` - `clf.decision_function` = $w^Tx + b$ - `logreg.predict_proba` - `SVC(probability=True)` not great ??? All the models in scikit-learn have multi-class built-in and most of them use One versus Rest. There's only one model that uses One versus One which is SVC. The Kernel SVM uses One versus One because of the authors of the SVM like that. For historical reasons, logistic regression also uses One versus Rest by default in scikit-learn. That's probably not a good idea, but we can’t really change the default easily. Usually, if you do multiclass you probably want to use multinomial logistic regression and so you set multinomial to true and then it does multinomial logistic regression. Question: Does that make it run faster? Answer: Its unlikely to make it run faster, but it makes it more theoretically sound and gives you better probabilities. The probabilities that come out of it, if you do OvR, are a complete hack in the multi-class case but in the binary case, it’s the same. Logistic regression also has a predict_prob method. This method gives the probability estimates, so you get a vector of length number of classes for each data point. You might be tempted to do SVC (probability) equal to true. That is something we're going to talk about in a couple of weeks. This is is running calibration. Basically, this does the One versus One SVM and then it builds a second model on top that tries to estimate probabilities using built-in cross-validation. This will take forever and the outcome will probably be not that great. Don't do this unless you're really sure this is what you want to do.  If you call predict_proba, it will give you an array that has number of samples times number of classes and these entries will sum to one. And the prediction is just the arg max of these. You can call predict which will give you arg max while predict_proba will give you the probabilities as given by the model. --- # Multi-Class in Practice OvR and multinomial LogReg produce one coef per class: .center[ ![:scale 80%](images/multiclass_coef.png) ] SVC would produce the same shape, but with different semantics! ??? FIXME screenshots In practice, I'm using logistic regression on the iris dataset. We have 50 data points, 4 features, 3 classes, each class has 50 samples, and we’re trying to classify different kinds of irises. Here, I'm looking at logistic regression and linear SVM, I built the model. So the coefficient W is stored in coef on this score. Everything in scikit-learn that's estimated from the data ends with an underscore. If it doesn't, it wasn't learned from the data. So coef_ are the coefficient that is learned by the model. They’re for logistic regression and linear Support Vector Machine, they're the same shape, three classes times four features but they have different semantics --- class: center ![:scale 80%](images/multiclass_array.png) ![:scale 80%](images/multiclass_barchart.png) (after centering data, without intercept) ??? FIXME screenshots Here I’ve interpreted them. You can see the four features, for each feature and for each class, you have a coefficient. If the sepal width is big, then the setosa classifier is happy. If the sepal with is small then versicolor will have a large response. If the petal width is big then virginica will have a large response. This is a bar plot after coefficient vector here. This tells you what the classifier has learned. This is maybe for a very simple problem this is little much to look at but it's still way less to look at for any other model. If you used a random forest or something like that, there would be no way to visualize what's happening. --- class: center, middle # Computational Considerations #(for all linear models) ??? Now I want to talk about more general things, how to make your homework run faster, also called Computational Considerations. --- class: some-space # Solver choices - Don’t use `SVC(kernel='linear')`, use `LinearSVC` - For `n_features >> n_samples`: Lars (or LassoLars) instead of Lasso. - For small n_samples (<10.000?), don’t worry. - `LinearSVC`, `LogisticRegression`: `dual=False` if `n_samples >> n_features` - `LogisticRegression(solver="sag")` for `n_samples` large. - Stochastic Gradient Descent for `n_samples` really large ??? Some of the things here are specific to scikit-learn and some are not. Scikit-learn has SVC and the linear SVC, and they're both support vector machines. SVC uses One versus One while linear SVC uses one versus rest. SVC uses the hinged loss while linear SVC uses squared hinge loss. Linear SVC will provide faster results than SVC. If you want to do regression with a large number of features, you should probably use Lars or LassoLars, which allows you to do feature selection much more quickly than Lasso. Generally, if you have a few samples, don't worry, any model will find and everything will be sparse. If you have, let's say 10,000 samples all linear models will be fast all the time. Otherwise, use this for regression. For classification, if the number of samples is much greater than the number of features use dual=false. Basically, solving a dual problem means solving something where there are as many variables as the number of samples, that's the default. Whereas solving the primal problem, so dual=false means solving something that's with the number of variables as the same number of features. If the number of features is big, dual should be true, and if the number of samples is big dual should be false. If you have really a whole lot of samples you can use a recent solver called sag. This works really for really large samples. So LogisticRegression(solver=”sag”) that can use L1 or L2 penalties or whatever you want. Then finally, if you have an extremely large amount of data you can use Stochastic Gradient Descent. It has the STD classifier, STD regressor, and hopefully, we'll have enough time to talk about these today. But generally often setting dual to false will help you a lot and setting the solver to something else might help you. All of these basically give you the same solution but only at different speeds. I want to talk about some tips for getting cross-validation. There are some built-in tools for doing quicker cross-validation for linear models. --- class: center, middle # Kernel SVMs --- class: spacious # Motivation - Go from linear models to more powerful nonlinear ones. - Keep convexity (ease of optimization). - Generalize the concept of feature engineering. ??? The main motivation for kernel support vector machines is that we want to go from linear models to nonlinear models but we also want to have the same simple kernel optimization to solve. So basically, the optimization problem we have to solve from a kernel SVM is about as hard as a linear SVM. So it's sort of very simple problem to solve. It’s much easier than learning in neural networks for example. But we get nonlinear decision boundaries. The idea behind this is to generalize the concept of feature engineering. We'll see in a little bit how, for example, kernels SVM with polynomial kernels relate to using polynomials explicitly in your feature engineering. Before we talk about kernels, I want to talk a little bit more about linear support vector machines, which we already discussed last week. --- class: spacious # Reminder on Linear SVM `$$ \min_{w \in \mathbb{R}^p, b \in \mathbf{R}} C \sum_{i=1}^n \max(0, 1 - y_i (w^T\mathbf{x} +b)) + ||w||^2_2 $$` $$ \hat{y} = \text{sign}(w^T \mathbf{x} + b) $$ ??? The idea behind the linear support vector machine is it's a linear classifier, the minimization problem is up a hinge loss, which is basically linear in the decision function w^x. Basically, as long as you have a distance on the right side of the hyper plane, that’s bigger than one, your data point does not contribute to the loss. So you want all of the points outside of this margin of one around the separating hyper plane. --- # Reformulate Linear Models .smaller[ - Optimization Theory $$ w = \sum_{i=1}^n \alpha_i \mathbf{x}_i $$ (alpha are dual coefficients. Non-zero for support vectors only) $$ \hat{y} = \text{sign}(w^T \mathbf{x}) \Longrightarrow \hat{y} = \text{sign}\left(\sum_i^{n}\alpha_i (\mathbf{x}_i^T \mathbf{x})\right) $$ $$ \alpha_i <= C$$ ] ??? Now I want to go from this linear model and extended to a nonlinear model. The idea here is that with some improvisation theory, you can find out that the W at the optimum can be expressed as a linear combination of the data points which is relatively straightforward to C. Expressing W as a linear combination, these alphas are called dual coefficients. Basically, you’re expressing the linear weights as a linear combination of the data points with this two coefficients alpha and you can show that these alpha are only non-zero for the points that contribute to this solution. So you can always write W as a linear combination of the support vectors with some alphas. If you want you can do this optimization problem either in trying to find W or you can rewrite the optimization problem and you can try to find these alphas. If you do this in terms of alphas, the decision function can be rewritten like this. Instead of looking at you w^T x, we just replace W transposed by the sum over all the training data points x_i and then basically we move the sum out of the inner products and we can see that it's the sum over all the alpha i in the inner product of the training data points x_i was a test data point x. Optimization theory also tells us that if I find the alpha w to minimize this problem, then all the alpha i (s) will be smaller than c. This is another way to say what I said last time that basically c limits the influence of each data point. So, if you have a smaller c the alpha i belong to each training data point can only be as big as this c, and so each of the data points has only limited influence. --- class: spacious # Introducing Kernels $$\hat{y} = \text{sign}\left(\sum_i^{n}\alpha_i (\mathbf{x}_i^T \mathbf{x})\right) \longrightarrow \hat{y} = \text{sign}\left(\sum_i^{n}\alpha_i (\phi(\mathbf{x}_i)^T \phi(\mathbf{x}))\right) $$ $$ \phi(\mathbf{x}_i)^T \phi( \mathbf{x}_j) \longrightarrow k(\mathbf{x}_i, \mathbf{x}_j) $$ k positive definite, symmetric $\Rightarrow$ there exists a $\phi$! (possilby $\infty$-dim) ??? The idea of this rewrite is that now I observed that the optimization problem and the prediction problem can be written only in terms of these inner products. Let's say I want to use the feature function ∅, like doing a polynomial expansion with the polynomial feature transformation and while if I use ∅x_i as these inputs then they just replace the x and then I just need the inner products between these feature vectors, but the only thing I really ever need is these inner products. Instead of trying to come up with some feature functions that are good to separate the data points, I can try it to come up with inner products. I can try to engineer this thing here instead of trying to engineer the features. If you write down any positive definite quadratic form that is symmetric, there's always a ∅. So whenever I write down any function that is positive definite and symmetric into vectors, there's always a feature function ∅ so that this is the inner product in this feature space, which is kind of interesting. The feature space might be infinite dimensional though. So the idea that it might be much easier to come up with these kinds of inner products than trying to find ∅. So we're now trying to design the k, which makes this whole thing a good nonlinear classifier. So in this case, obviously, the kernel. --- # Examples of Kernels $$k_\text{linear}(\mathbf{x}, \mathbf{x}') = \mathbf{x}^T\mathbf{x}'$$ $$k_\text{poly}(\mathbf{x}, \mathbf{x}') = (\mathbf{x}^T\mathbf{x}' + c) ^ d$$ $$k_\text{rbf}(\mathbf{x}, \mathbf{x}') = \exp(-\gamma||\mathbf{x} -\mathbf{x}'||^2)$$ $$k_\text{sigmoid}(\mathbf{x}, \mathbf{x}') = \tanh\left(\gamma \mathbf{x}^T\mathbf{x}' + r\right)$$ `$$k_\cap(\mathbf{x}, \mathbf{x}')= \sum_{i=1}^p \min(x_i, x'_i)$$` - If $k$ and $k'$ are kernels, so are `$k + k', kk', ck', ...$` ??? There's a couple of kernels that are commonly used. So the linear kernel just means I just use the inner product in the original space. That is just the original linear SVM. Other kernels that are commonly used are like the polynomial kernel, in which I take the inner products, I add some constant c and I raise it to power d. There's the RVF kernel, which is probably the most commonly used kernel, which is just a Gaussian function above the curve around the distance of the two data points. There's a sigmoid kernel. There's the intersection kernel, which computes the minimum. And if you have any kernel, you can create a new kernel by adding two kernels together or multiplying them or multiplying them by constant. The only requirement we have is that they're positive, indefinite and symmetric. What does this look like in practice? So, for example, let's look at this polynomial kernel. It's not very commonly used, but I think it's one of the ones that are relatively easy to understand. So the idea of the polynomial kernel is it does the same thing as computing polynomials. But if you compute polynomials of a very high degree, your feature vector becomes very long. Whereas here, I always just need to compute this inner product and raise them to this power. --- # Polynomial Kernel vs Features $$ k_\text{poly}(\mathbf{x}, \mathbf{x}') = (\mathbf{x}^T\mathbf{x}' + c) ^ d $$ Primal vs Dual Optimization
Explicit polynomials $\rightarrow$ compute on `n_samples * n_features ** d` Kernel trick $\rightarrow$ compute on kernel matrix of shape `n_samples * n_samples`
For a single feature: $$ (x^2, \sqrt{2}x, 1)^T (x'^2, \sqrt{2}x', 1) = x^2x'^2 + 2xx' + 1 = (xx' + 1)^2 $$ ??? So if I compute explicit polynomials, if I end features and then I do all the interactions, my data set becomes number of samples times number of features to the power D. So if I have 1000 features, and I take D to be 5, this will be enormous. If I'm using the kernel trick, which is replacing this inner product in the feature space by the kernel, then I only need to compute the inner product on the training data. So I only need to compute on this inner product matrix which is number of samples times number of samples. So this is much smaller if number of features to the D is smaller than number of samples then I can compute, essentially the same result on something that’s a different representation of the data. You can see that they're not entirely equivalent. So doing the polynomial expansion is not entirely equivalent to the polynomial features but it's about the same. You can see this quite easily for a single feature. If I do this for many features, adding extra features would make a very long feature vector, but the thing on the right-hand side always stays the same. --- # Poly kernels vs explicit features .smaller[ ```python poly = PolynomialFeatures(include_bias=False) X_poly = poly.fit_transform(X) print(X.shape, X_poly.shape) print(poly.get_feature_names()) ``` ``` ((100, 2), (100, 5)) ['x0', 'x1', 'x0^2', 'x0 x1', 'x1^2'] ``` ] .center[ ![:scale 70%](images/poly_kernel_features.png) ] ??? You can see that they're very similar, by just applying them scikit-learn, either the Kernel SVM or the explicit polynomial features. Here I have this dataset consisting of classes orange and blue. These are not linearly separable. So if I use a linear SVM, it wouldn't work. But I can do a polynomial transformation to go from two features to five features. In here I just added degree two features. And then I can learn linear SVM on top of these expanded features space. I get a very similar result if I instead of expanding the features, I use the original dataset. But now instead of learning linear SVM, I use a SVM with the polynomial kernel of degree 2, they're not exactly the same because there was this factor of squared of two that I mentioned, but they're pretty much the same. Question is if we increase the capacity of the model and we overfit and we'll talk about this in a little bit, but so, for now, we want to increase the capacity of a model making more flexible I mean, we definitely don't want to increase it infinitely. But we really making out model more flexible. So here for the polynomial kernel, you could get the same result just by expanding. If you have a very high degree polynomial it would be a large expansion. If you use one of the other kernels, for example, the RVF kernel doing this expansion would actually be resolved in infinite dimensional vector, so you couldn't actually do this with a feature vector. Now I'm looking at this model here on the right-hand side where I'm using the polynomial features. --- class: smaller # Understanding Dual Coefficients ```python linear_svm.coef_ ``` ``` array([[0.139, 0.06, -0.201, 0.048, 0.019]]) ``` $$ y = \text{sign}(0.139 x_0 + 0.06 x_1 - 0.201 x_0^2 + 0.048 x_0 x_1 + 0.019 x_1^2) $$ ```python linear_svm.dual_coef_ #array([[-0.03, -0.003, 0.003, 0.03]]) linear_svm.support_ #array([1,26,42,62], dtype=int32) ``` .smallest[ `$$ y = \text{sign}(-0.03 \phi(\mathbf{x}_1)^T \phi(x) - 0.003 \phi(\mathbf{x}_{26})^T \phi(\mathbf{x}) +0.003 \phi(\mathbf{x}_{42})^T \phi(\mathbf{x}) + 0.03 \phi(\mathbf{x}_{62})^T \phi(\mathbf{x})) $$` ] ??? FIXME formula goes over And so if I look at the linear SVM and I have five coefficients corresponding to the five features. And so if I make a prediction, its first coefficient times the first feature, second coefficient times the second feature and so on, and I look at the sine of it. This is just a linear prediction if I want to look what this looks like in terms of dual coefficients, I can look at the dual coefficients of linear SVM and the support. Out of these many data points, there's four, they were selected as support vectors by the optimization. These are the ones that have these black circles around them. And so the solution can be expressed as a linear combination of these four support vectors where the coefficients are dual coefficients. If I want to express this in terms of dual coefficients, I can say its dual coefficient -0.03 times the inner product of the first data point and my test data point in feature space. I do the same thing for the train each point 26 and 42 and 63 with their respective weights. Now I can look at how does this look like for kernel. --- # With Kernel `$$y = \text{sign}\left(\sum_i^{n}\alpha_i k(\mathbf{x}_i, \mathbf{x})\right) $$` ```python poly_svm.dual_coef_ # array([[-0.057, -0. , -0.012, 0.008, 0.062]]) poly_svm.support_ # array([1,26,41,42,62], dtype=int32) ``` `$$ y = \text{sign}(-0.057 (\mathbf{x}_1^T\mathbf{x} + 1)^2 -0.012 (\mathbf{x}_{41}^T \mathbf{x} + 1)^2 \\ +0.008 (\mathbf{x}_{42}^T \mathbf{x} + 1)^2 + 0.062 (\mathbf{x}_{62}, \mathbf{x} + 1)^2) $$` ??? So for kernel, the prediction is this. For kernel SVM there are no coefficients in the original space, there's only dual coefficients. For each of support vectors, I compute the kernel of support vector with the test point for which I want to make a prediction. This is basically the prediction function of the kernel support vector machine. And you can see it's very similar to this only that I’ve replaced these inner products by the kernels. The original idea behind this kernel trick was to make computation faster. In some cases, it might be faster. $$ y = sign(-0.03 * np.inner(poly(X[1]), poly(x)) – 0.003 * np.inner(poly(X[26]), poly(x)) +0.003 * np.inner(poly(X[42]), poly(x)) + 0.03 * np.inner(poly(X[63]), poly(x)) $$ --- # Runtime Considerations .center[ ![:scale 85%](images/svm_runtime.png) ] ??? So how does it look like in terms of runtime, here I have the same plot in linear space and log-log space. This is for a fixed number of features, more features make the kernel better. But if I fix the number of features, you can see which of the two is faster. Log-log space is better for this. So you can see that if I have a very small number of samples, then linear kernel and doing explicit polynomials is slower than doing the kernel because of the matrix that's number of samples times the number of samples is very small. But if I have a lot of features, then doing the explicit expansion is faster since the number of samples is large. In the case where we can do explicit feature expansion if we have a lot of samples, maybe that's faster. --- class:spacious # Kernels in Practice - Dual coefficients less interpretable - Long runtime for “large” datasets (100k samples) - Real power in infinite-dimensional spaces: rbf! - Rbf is “universal kernel” - can learn (aka overfit) anything. ??? So what does this mean for us in practice? One issue is that the dual coefficients are usually less interpretable because they give you like weightings of inner products with the training data points which is maybe less intuitive than looking at like five times x squared and if you have large data sets they can become very slow. The real power of kernels is when the feature space would actually be infinite-dimensional. The RBF kernel is called the universal kernel, which means you can learn any possible concept or you can overfit any possible concept. Same is true for like neural networks and trees and nearest neighbors, for example, they can learn anything but linear models and even polynomial models of a fixed degree cannot learn everything. --- class:spacious #Preprocessing - Kernel use inner products or distances. - StandardScaler or MinMaxScaler ftw - Gamma parameter in RBF directly relates to scaling of data and n_features – the default is `1/(X.var() * n_features)` ??? Nearly all of these kernels use the distance in the original space. These inner products are distances and so scaling is really important. People use a center scale or min-max scalar. For the RBF kernel or for any of the kernels really the default parameters work well for scale data. If you don't scale your data default parameters will not work at all. If you multiply that by five then the default parameters will give you terrible results. --- # Parameters for RBF Kernels - Regularization parameter C is limit on alphas (for any kernel) - Gamma is bandwidth: $k_\text{rbf}(\mathbf{x}, \mathbf{x}') = \exp(-\gamma||\mathbf{x} -\mathbf{x}'||^2)$ .center[ ![:scale 85%](images/svm_gamma.png) ] ??? Support vector machine with RBF kernel has these two parameters you need to tune. These both control complexity in some way. We already said that the C parameter limits the influence of each individual data point and the other one is to kernel bandwidth gamma. A smaller gamma means a wider kernel. So wider kernel means a simpler model because the decision boundary will be smoother. Whereas a larger gamma means a much narrower kernel and that means each data point will have much more local influence, which means it's more like the nearest neighbor algorithm and has more complexity. Usually, you should tune both of these parameters to get a good tradeoff between fitting and generalization. --- .center[ ![:scale 85%](images/svm_c_gamma.png) ] ??? This plot tries to illustrate these two parameters in the RBF SVM kernel. On the vertical is C and on the horizontal is gamma and support vectors are marked with circles. So the simplest model is basically the one with the smallest gamma and smallest C. Basically, all data points are support vectors, everything gets averaged and have a very broad kernel. Now, if I increase C, I overfit the data more, each data point can have more influence. And so only the data points that are really close to the boundary have influence now. If you increase gamma, the area of influence of each data point sort of shrinks. So here from it being basically linear or having this very little curvature if you increase gamma, it gets more and more curvature. And in the end, if you make gamma very large, each data point basically has a small sort of isolated island of its class around it giving a very complicated decision boundary. So here, for example, these clearly overfit the training data and so this is probably too large gamma. There's sort of a tradeoff between the two. Usually, they're multiple combinations of C and gamma that will give you similarly good results. --- ```python from sklearn.datasets import load_digits digits = load_digits() ``` .center[ ![:scale 65%](images/digits_images.png) ] ??? Looking at the digit dataset. Let's say we want to learn kernel support vector machine on this dataset. So set the two important parameters to tune is C and gamma. --- # Scaling and Default Params .smaller[ ``` gamma : {‘scale’, ‘auto’} or float, optional (default=’scale’) Kernel coefficient for 'rbf', 'poly' and 'sigmoid'. if gamma='scale' (default) is passed then it uses 1 / (n_features * X.var()) as value of gamma if ‘auto’, uses 1 / n_features. ``` ```python print('auto', np.mean(cross_val_score(SVC(gamma='auto'), X_train, y_train, cv=10))) print('scale', np.mean(cross_val_score(SVC(gamma='scale'), X_train, y_train, cv=10))) scaled_svc = make_pipeline(StandardScaler(), SVC()) print('pipe', np.mean(cross_val_score(scaled_svc, X_train, y_train, cv=10))) ``` ``` auto 0.563 scale 0.987 pipe 0.977 ``` ```python gamma = (1. / (X_train.shape[1] * X_train.var())) print(np.mean(cross_val_score(SVC(gamma=gamma), X_train, y_train, cv=10))) ``` ``` 0.987 ``` ] ??? Gamma by default in scikit-learn is one over the number of features. This really makes sense only if you scale the data to have a standard deviation of one, then this is a pretty good default. Here if I compare cross-validation, kernel SVM with default parameters on this dataset versus kernel SVM with the scaled data, the performance is either 57% or 97%. There's a giant jump between the scaled data and the upscale data. Actually here in this data set, all the pixels are on the same scale more or less, so they all are between 0 and 16. So if we change the gamma to be to take into account the standard deviation of the data set, I actually get pretty good results. This is actually just a very peculiar dataset because I basically I know the scale should be from zero to one when it's from 0 to 16. So scaling by the overall standard deviation gives me good results here. But in principle day, I want to convey is that gamma scales with the standard deviation of the features. Usually, each of the features has a different standard deviation or a different scale and so you want to use a centered scale to estimate the scale for each feature and bring it to one. And then the default gamma, which is one over number of features will be sort of reasonable. --- # Grid-Searching Parameters ```python param_grid = {'svc__C': np.logspace(-3, 2, 6), 'svc__gamma': np.logspace(-3, 2, 6) / X_train.shape[0]} param_grid ``` ```json {'svc_C': array([0.001, 0.01, 0.1, 1., 10., 100.]), 'svc_gamma': array([ 0.000001, 0.000007, 0.000074, 0.000742, 0.007424, 0.074239])} ``` ```python grid = GridSearchCV(scaled_svc, param_grid=param_grid, cv=10) grid.fit(X_train, y_train) ``` ??? To tune them, I use the scaled SVM and both C and gamma usually learn auto log space, so here I have a log space for C and gamma. I actually divide this by the number of features, I could also just change the range, but as I said, this is sort of something that scales with the number of features and standard deviation. Then I can just do my standard grid searchCV with the two-dimensional parameter grid. --- # Grid-Searching Parameters .center[ ![:scale 95%](images/svm_c_gamma_heatmap.png) ] ??? Usually, there's a strong interaction between these two parameters. And the SVM is pretty sensitive to the setting of these two parameters. So you can see here if you look at the scales, balance 10 classification dataset. So chance performance is 10% accuracy. And so if I set the parameters wrong, I get chance accuracy. If I set them right, I get the high 90s. So that's the difference between setting gamma to 0.007 and 0.000007 or between setting c to 1 and c to 0.0001. So usually they're some correlation between the C and gamma values which are good. So you can decrease or increase C if you decrease gamma and the other way around. So usually I like to look at grid search results as a 2d heat map for this and if your optimum is somewhere on the boundary, you want to extend your search space. For example, you can see that I wouldn't need to search this very small Cs, they don't work at all, but maybe something better might be over here. A C of 100 is already like a very big C so if I want to use even less regularization, learning the model will be even slower. --- class: center, middle # Questions ?


--- title: Page 1 kind: article created_at: 2019-06-01 preview_image: /pages/page-1.png --- <% content_for(:comic) do %> <% end %> <% content_for(:newspost) do %>
This is a very basic example of a comic


|
KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
|
#include <beam_math_utilities.hpp>
Public Types | |
| typedef Matrix | MatrixType |
| typedef Vector | VectorType |
| typedef Quaternion< double > | QuaternionType |
| typedef MathUtils< TDataType > | MathUtilsType |
| typedef BeamMathUtils< TDataType > | BeamMathUtilsType |
Static Public Member Functions | |
| template<class TVector3 > | |
| static TVector3 & | MapToCurrentLocalFrame (QuaternionType &rQuaternion, TVector3 &rVector) |
| template<class TVector3 > | |
| static TVector3 & | MapToReferenceLocalFrame (QuaternionType &rQuaternion, TVector3 &rVector) |
| template<class TVector3 > | |
| static void | ExponentialTransform (const TVector3 &rVector, MatrixType &rExponentialTensor) |
| template<class TVector3 > | |
| static void | InverseExponentialTransform (const MatrixType &rExponentialTensor, TVector3 &rVector) |
| template<class TVector3 > | |
| static void | CayleyTransform (const TVector3 &rVector, MatrixType &rCayleyTensor) |
| template<class TVector3 > | |
| static void | InverseCayleyTransform (const MatrixType &rCayleyTensor, TVector3 &rVector) |
| template<class TVector3 , class TMatrix3 > | |
| static void | VectorToSkewSymmetricTensor (const TVector3 &rVector, TMatrix3 &rSkewSymmetricTensor) |
| template<class TMatrix3 , class TVector3 > | |
| static void | SkewSymmetricTensorToVector (const TMatrix3 &rSkewSymmetricTensor, TVector3 &rVector) |
| static double | KroneckerDelta (int i, int j) |
| static double | LeviCivitaEpsilon (int i, int j, int k) |
| static void | AddVector (const VectorType &rInputVector, VectorType &rOutputVector, const unsigned int InitialRow) |
| static void | SubstractVector (const VectorType &rInputVector, VectorType &rOutputVector, const unsigned int InitialRow) |
| template<class TMatrix , class TInputMatrix > | |
| static void | AddMatrix (TMatrix &rDestination, const TInputMatrix &rInputMatrix, const unsigned int rInitialRow, const unsigned int rInitialCol) |
| template<class TMatrix , class TInputMatrix > | |
| static void | SubtractMatrix (TMatrix &rDestination, const TInputMatrix &rInputMatrix, const unsigned int rInitialRow, const unsigned int rInitialCol) |
| static void | MapLocalToGlobal2D (const QuaternionType &rLocalToGlobalQuaternion, MatrixType &rMatrix) |
| static void | MapLocalToGlobal2D (const QuaternionType &rLocalToGlobalQuaternion, VectorType &rVector) |
| static void | MapLocalToGlobal2D (const MatrixType &rLocalToGlobalMatrix, MatrixType &rMatrix) |
| static void | MapLocalToGlobal2D (const MatrixType &rLocalToGlobalMatrix, VectorType &rVector) |
| static void | MapLocalToGlobal3D (const QuaternionType &rLocalToGlobalQuaternion, MatrixType &rMatrix) |
| static void | MapLocalToGlobal3D (const QuaternionType &rLocalToGlobalQuaternion, VectorType &rVector) |
| static void | MapLocalToGlobal3D (const MatrixType &rLocalToGlobalMatrix, MatrixType &rMatrix) |
| static void | MapLocalToGlobal3D (const MatrixType &rLocalToGlobalMatrix, VectorType &rVector) |
| template<class TVector3 > | |
| static void | CalculateLocalAxesMatrix (const TVector3 &rLocalX, MatrixType &rRotationMatrix) |
| template<class TVector3 > | |
| static void | CalculateLocalAxesVectors (TVector3 &rLocalX, TVector3 &rLocalY, TVector3 &rLocalZ) |
| template<class TVector3 > | |
| static void | CalculateLocalAxesMatrix (const TVector3 &rLocalX, const TVector3 &rLocalY, MatrixType &rRotationMatrix) |
| template<class TVector3 > | |
| static void | CalculateLocalAxisVector (TVector3 &rLocalX, TVector3 &rLocalY, TVector3 &rLocalZ) |
| static bool | CheckOrthogonality (const Matrix &rTensor, const std::string &Name, bool Verbose) |
| typedef BeamMathUtils<TDataType> Kratos::BeamMathUtils< TDataType >::BeamMathUtilsType |
| typedef MathUtils<TDataType> Kratos::BeamMathUtils< TDataType >::MathUtilsType |
| typedef Matrix Kratos::BeamMathUtils< TDataType >::MatrixType |
name Type Definitions
| typedef Quaternion<double> Kratos::BeamMathUtils< TDataType >::QuaternionType |
| typedef Vector Kratos::BeamMathUtils< TDataType >::VectorType |
|
inlinestatic |
"InputMatrix" is ADDED to "Destination" matrix starting from InitialRow and InitialCol of the destination matrix "Destination" is assumed to be able to contain the "input matrix" (no check is performed on the bounds)
| rInputMatrix | The input matrix to be computed |
| rInitialRow | The initial row to compute |
| rInitialCol | The initial column to compute |
|
inlinestatic |
Add a Nodal vector to a Elemental vector
| rInputVector | LocalNodalVector (input parameter) |
| rOutputVector | LocalElementalVector (output parameter) |
| InitialRow | InitialRowNumber, initial index of the OutputVector note the initialization of the outputvector must be done previously to the call of the method |
|
inlinestatic |
Deffault expression for GID local beam axes:: E1 is considered the local beam axial direction
| rLocalX | Local Beam axis vector (input parameter) |
| rLocalY | Local axis 2 vector (input parameter) |
| rRotationMatrix | transformation matrix from local to global frame (output parameter) |
|
inlinestatic |
Deffault expression for GID local beam axes:: E1 is considered the local beam axial direction
| rLocalX | Local Beam axis vector (input parameter) |
| rRotationMatrix | transformation matrix from local to global frame (output parameter) |
|
inlinestatic |
Deffault expression for GID local beam axes:: E1 is considered the local beam axial direction
| rLocalX | Local Beam axis director vector E1 (input parameter) (output parameter) |
| rLocalY | Local Beam axis director vector E2 (output parameter) |
| rLocalZ | Local Beam axis director vector E3 (output parameter) |
|
inlinestatic |
Deffault expression for GID local beam axes:: E1 is considered the local beam axial direction
| rLocalX | Local Beam axis director vector E1 (input parameter) (output parameter) |
| rLocalY | Local Beam axis director vector E2 (input parameter) (output parameter) |
| rLocalZ | Local Beam axis director vector E3 (output parameter) |
|
inlinestatic |
Transform a rotation vector to a rotation matrix with the Cayley transform
| rVector | rotation vector (input parameter) |
| rCayleyTensor | rotation matrix (output parameter) |
|
inlinestatic |
Check if a Tensor is orthogonal
| rTensor | transformation matrix to be checked |
| Name | Name of the checked tensor to be verbosed |
| Verbose | Set verbosity for the check |
|
inlinestatic |
Transform a rotation vector to a rotation matrix with the Exponential transform
| rVector | rotation vector (input parameter) |
| rExponentialTensor | rotation matrix (output parameter) |
|
inlinestatic |
Transform a rotation tensor to a rotation vector with the inverse of the Cayley transform
| rCayleyTensor | rotation matrix (input parameter) |
| rVector | rotation vector (output parameter) |
|
inlinestatic |
Transform a rotation matrix to a rotation vector with the inverse of the Exponential transform
| rCayleyTensor | rotation matrix (input parameter) |
| rVector | rotation vector (output parameter) |
|
inlinestatic |
Get kroneckrDelta :: two order tensor that gives the value of the identity
| i | coefficient i |
| j | coefficient j Returns a double with the value |
|
inlinestatic |
Get Levi Civita Epsilon :: third order tensor that gives the value of a vectorial product
| i | coefficient i |
| j | coefficient j |
| k | coefficient k Returns a double with the sign |
|
inlinestatic |
Map a Matrix expressed on the Local frame of an element to a Global frame expression
| rLocalToGlobalMatrix | transformation matrix from local to global frame |
| rMatrix | matrix to be transformed (output parameter) note the initialization of the Matrices must be done previously to the call of the method return value : A = Q * A' * QT |
|
inlinestatic |
Map a Vector expressed on the Local frame of an element to a Global frame expression
| rLocalToGlobalMatrix | transformation matrix from local to global frame |
| rVector | vector to be transformed (output parameter) note the initialization of the Matrices must be done previously to the call of the method |
|
inlinestatic |
Map a Matrix expressed on the Local frame of an element to a Global frame expression
| rLocalToGlobalQuaternion | transformation quaternion from local to global frame |
| rMatrix | matrix to be transformed (output parameter) note the initialization of the Matrices must be done previously to the call of the method return value : A = Q * A' * QT |
|
inlinestatic |
Map a Vector expressed on the Local frame of an element to a Global frame expression
| rLocalToGlobalQuaternion | transformation quaternion from local to global frame |
| rVector | vector to be transformed (output parameter) note the initialization of the Matrices must be done previously to the call of the method |
|
inlinestatic |
Map a Matrix expressed on the Local frame of an element to a Global frame expression
| rLocalToGlobalMatrix | transformation matrix from local to global frame |
| rMatrix | matrix to be transformed (output parameter) note the initialization of the Matrices must be done previously to the call of the method return value : A = Q * A' * QT |
|
inlinestatic |
Map a Vector expressed on the Local frame of an element to a Global frame expression
| rLocalToGlobalMatrix | transformation matrix from local to global frame |
| rVector | vector to be transformed (output parameter) note the initialization of the Matrices must be done previously to the call of the method |
|
inlinestatic |
Map a Matrix expressed on the Local frame of an element to a Global frame expression
| rLocalToGlobalQuaternion | transformation quaternion from local to global frame |
| rMatrix | matrix to be transformed (output parameter) note the initialization of the Matrices must be done previously to the call of the method return value : A = Q * A' * QT |
|
inlinestatic |
Map a Vector expressed on the Local frame of an element to a Global frame expression
| rLocalToGlobalQuaternion | transformation quaternion from local to global frame |
| rVector | vector to be transformed (output parameter) note the initialization of the Matrices must be done previously to the call of the method |
|
inlinestatic |
name Math Utilities for beams Transform a vector from the reference to the current local frame (MATERIAL frame for a beam)
| rQuaternion | Quaternion representing the rotation from the reference to the current local frames |
| rVector | Vector to be rotated the rotated vector rVector is returned. |
|
inlinestatic |
Transform a vector from the current to the reference local frame (SPATIAL frame for a beam)
| rQuaternion | Quaternion representing the rotation from the reference to the current local frames |
| rVector | Vector to be rotated the rotated vector rVariable is returned. |
|
inlinestatic |
Transform a skew symmetric matrix to a rotation vector
| rSkewSymmetricTensor | skew symmetric matrix (input parameter) |
| rVector | rotation vector (output parameter) |
|
inlinestatic |
Substract a Nodal vector from an Elemental vector
| rInputVector | LocalNodalVector (input parameter) |
| rOutputVector | LocalElementalVector (output parameter) |
| InitialRow | InitialRowNumber, initial index of the OutputVector note the initialization of the outputvector must be done previously to the call of the method |
|
inlinestatic |
"InputMatrix" is SUBTRACTED to "Destination" matrix starting from InitialRow and InitialCol of the destination matrix "Destination" is assumed to be able to contain the "input matrix" (no check is performed on the bounds)
| rInputMatrix | The input matrix to be computed |
| rInitialRow | The initial row to compute |
| rInitialCol | The initial column to compute |
|
inlinestatic |
Transform a rotation vector to a skew symmetric matrix
| rVector | rotation vector (input parameter) |
| rSkewSymmetricTensor | skew symmetric matrix (output parameter) |


This config file contains information about the major cities of the setting. The generated minor settlements will take their naming and demographic cues from the nearest big city from this list.
| Key | Data Type | Comments |
| Name | string | A unique identifier used to connect to other files. |
| Nation | string | This must match a value declared in the Nation field of the Culture file. |
| Population | int | |
| Size | string | A description such as city, capital, sprawling, etc. |
| Region | string | This must match a value declared in the Name field of the Regions file. |
| Terrain | string | |
| Races | {string : decimal} | Each key is a race name that must match a value declared in the Race field of the Culture file. The values are the decimal abundance of that race in the city and its surroundings. |
| Tech | int | 0 ≤ x ≤ 4. This sets the general cap on what goods and services are available near this city. See Items file for more discussion. |
| Prefixes | list(string) | Settlement names will be generated from these three lists as prefix + combiner + infix + suffix. If the names should only have 2 parts (or 1), leave the prefixes (and then infixes) fields as empty lists []. |
| Infixes | list(string) | See above. |
| Suffixes | list(string) | See above. |
| Combiner | string | See above. |
Data types are set out in italics like string. The relevant data types are:
| Data Type | Meaning | Example |
| list(type) | A comma separated list of that data type. Lists start and end with square brackets. | ["item 1", "item 2"]; [1, 2, 3, 4] |
| string | A double-quoted piece of information that can contain any UTF-8 character. | "a value" |
| int | A whole number, written without quotes. If the range is limited, it's noted as start ≤ int ≤ stop (including both endpoints) | 42 |
| decimal | A number with a decimal point. In this app, that will always be in the range 0.0 ≤ x ≤ 1.0 and will mean a probability of occurance. | 0.5 |
| {string : type} | A mapping between a string (the key) and a value of type. Written as a comma-separated list of "key":value, enclosed in curly braces. The colon is important. | {"This": 1, "That": 2} |


Simple workshop that cuts logs into 4 blocks.
Simple workshop that fills barrels and buckets with water or magma.
It must be build next to/above water or magma to work.
Build labor: Leatherworker
Skill: Any
The Breeding Warren allows any female kobold to get pregnant and give birth instantly. Kobold children come of age in only 1 year, so this is a great way to increase your civ member count. You just need 1 stack of meat to feed the newborn.
Build labor: Leatherworker
Skill: Bonecarver
A workshop that upgrades bone to bonerattle, an armor-material that fools undeads into thinking that you are one of them. You can make bone armors and armorsets here, or upgrade and make bonerattle armor and armorsets. Keep in mind that every reaction uses up an entire stack of bones, so it is more economical to use the craftsbold for the bone armor. Once upgraded to bonerattle the reactions work normally, using one item for each product.
Build labor: Leatherworker
Skill: Leatherworker
A simple workshop that allows the production of clay items. You take clay, fire clay or kaolinite and form it into items. There items are unuseable until fired in the kiln, turning them into stoneware, earthenware and porcelain.
Build labor: Leatherworker
Skill: Leatherworker
A simple workshop that allows the production of chitin armors. An armorset consists of 2 shin-guards, 2 wrist-guards, greaves, a cap and a suit of armor. Everything else, like weapons and shields, you have to create yourself.
Build labor: Leatherworker
Skill: Weaving & Tailoring
A simple workshop that allows the production of specific clothing types. A set consists of 2 shoes, a shirt and pants. You can choose between wool, cotton, silk and rare silk. You can also unravel cloth back to thread, if need be.
Skill: Glassmaking
The glassblower can create a multitude of different objects from clear, green and crystal glass. It is a simple extension to the glass furnace. Barrels, bins, buckets and beds can be made, as well as several basic weapons.
You will need fuel for these reactions.
Build labor: Leatherworker
Skill: Leatherworking
A simple workshop that allows the production of leather armors. An armorset consists of 2 shin-guards, 2 wrist-guards, greaves, a cap and a suit of armor. Everything else, like weapons and shields, you have to create yourself.
Build labor: Leatherworker
Skill: Leatherworking
A simple workshop that allows the production of leather furniture. Doors, chairs, beds, blocks, the usual interior items, all done from normal leather.
Build labor: Leatherworker
Skill: Leatherworker
A simple workshop that allows the production of scale armors. An armorset consists of 2 shin-guards, 2 wrist-guards, greaves, a cap and a suit of armor. Everything else, like weapons and shields, you have to create yourself.
Build labor: Leatherworker
Skill: Leatherworker
A simple workshop that allows the production of shell armors. An armorset consists of 2 shin-guards, 2 wrist-guards, greaves, a cap and a suit of armor. Everything else, like weapons and shields, you have to create yourself.
Build labor: Leatherworker
Skill: Herbalism
Allows five kinds of plants to be bundled into wicker bales, with 2 plants used for one bale. These are used to create blocks for constructions or for furniture. For stockpiling reasons they are treated as stone. Bales are counted as tools, which means that your wicker bales can be found in stone tool stockpiles.
Wicker bins are very light, keeping kobolds at a fast speed.
Build labor: Leatherworker
Skill: Mechanic
The trap setter creates early traps made of mostly bone, wood or skull materials. Whips of rope or leather are also possible.
Kobolds can also create shrapnel traps. These need 2 stacks of bones to be made, but hit 4 times with each attack.
Build labor: Leatherworker
Skill: Woodcrafting
A simple workshop that produces items of wood. Think of it as a carpentry for items the vanilla carpenter cant produce. Slabs, mechanisms, querns, millstones as well as batches of furniture can be done here, so can wooden braziers and candelabras.
This is mostly done to reduce the amount of items, so it is nor very efficient in creating ash or coal. I advise to build one or two of these next to your refuse piles.
Turns alcohol into fuel. Since kobolds have access to drinks, but are not dependent on them, you can use them to replenish your fuel resources without wasing valueable wood.
Dance around the totem pole to control the weather. Let the sun shine, start rain or snow storms. The rain is especially interesting since it stops forest fires.
Build labor: Leatherworker
Skill: Fighting and Doging skills
Use this parcour to train your kobolds general skills, like throwing, dodging and coordination, as well as armor and shield. You need either a trap component or a shield/armor for these reactions. The items have a 5% chance of breaking.
Build labor: Leatherworker
Skill:Weapon and armor skills
The training room allows melee combat training, as well as any weapon skill. You need one training weapon of the type, and you have a 5% chance to break it while training.


[gecode-users] Bugs with tuples+EPK_SPEED and sequence
Manuel Baclet
manu.baclet at gmail.com
Tue Aug 7 16:13:33 CEST 2012
This is a duplicate of another message (attachment went wrong).
Hi Guido,
thanks for the fix. I have found two other problems (using osX 10.8). When possible, i tried with Gecode 3.7.3 and the trunk version.
- EPK_SPEED does not work with restart search and several threads. I provide an example:
This gives me seg faults. gdb says:
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000008
[Switching to process 8791read 0x1203]
0x000000010004cbcd in Gecode::Int::Extensional::Incremental<Gecode::Int::BoolView>::remove_support (this=0x103008990, home=@0x102800000, l=0x101308280, i=1, n=1) at incremental.hpp:254
254 while ((*a)->t != l) {
- sequence is not working properly with restart search and several threads. An example:
This gives different random error messages including Segmentation fault: 11, Abort trap: 6 and
<<test2(8717,0x10d484000) malloc: *** error for object 0x7fb3c3c081d0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug>>
gdb reports one of the following error (depending on the execution):
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: 13 at address: 0x0000000000000000
[Switching to process 8828 thread 0x1203]
0x00000001001a1f78 in Gecode::IntSet::~IntSet () at core.hpp:2286
2286 delete o;
or
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
[Switching to process 8834 thread 0x1203]
Gecode::VarImp<Gecode::Int::IntVarImpConf>::advise (this=<value temporarily unavailable, due to optimizations>, home=@0x1013086d0, me=1, d=@0x1012cee20) at core.hpp:3346
3346 switch (p.advise(home,*a,d)) {
or
test2(8866,0x1012cf000) malloc: *** error for object 0x1013081f0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Program received signal SIGABRT, Aborted.
[Switching to process 8866 thread 0x1203]
0x00007fff916e2212 in __pthread_kill ()
The following example shows that this can also happen with bab search:
Hope you can fix this,
Cheers,
Manuel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.gecode.org/pipermail/users/attachments/20120807/3f6f6fbb/attachment-0004.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.cp
Type: application/octet-stream
Size: 1488 bytes
Desc: not available
URL: <http://www.gecode.org/pipermail/users/attachments/20120807/3f6f6fbb/attachment-0003.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.gecode.org/pipermail/users/attachments/20120807/3f6f6fbb/attachment-0005.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test2.cp
Type: application/octet-stream
Size: 1326 bytes
Desc: not available
URL: <http://www.gecode.org/pipermail/users/attachments/20120807/3f6f6fbb/attachment-0004.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.gecode.org/pipermail/users/attachments/20120807/3f6f6fbb/attachment-0006.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test3.cp
Type: application/octet-stream
Size: 1375 bytes
Desc: not available
URL: <http://www.gecode.org/pipermail/users/attachments/20120807/3f6f6fbb/attachment-0005.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.gecode.org/pipermail/users/attachments/20120807/3f6f6fbb/attachment-0007.html>
More information about the users
mailing list


@* * Copyright 2023 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *@ @(params: Map[String, Any]) @uk.gov.hmrc.hmrcemailrenderer.templates.helpers.html.template_main(params, "Your tax credits declaration for " + {params("awardStartDate")} + " to " + {params("awardEndDate")} + " has been received", true, footerMessage = None, true) {
Dear @{params("customerFName")}
Your reference number is @{params("renewalReference")}
If we have an up-to-date mobile number on your tax credits claim, you may get some text messages about the progress of your renewal.
@defining(params("currentTaxYear").toString.toInt + 1) { nextTaxYear => @defining((params("incompleteClaims").toString.toInt, params("anyEstimates").toString.toInt)) { case (ic, ae) => @if(ic > 0 || ae > 0){You must contact us by webchat or telephone to tell us the actual amount for the estimate@if(ae > 1){s} you gave, by 31 January @nextTaxYear. For contact details, search for 'tax credits general enquiries'.
} @if(ic == 1 && ae == 0){You must complete your last annual declaration to finish your renewal.
} @if(ic > 1 && ae == 0){You must complete your @ic remaining annual declarations to finish your renewal.
} @if((ic >= 1) && ae > 0){You must:
You can visit Manage your tax credits and sign in to:
You can also manage your tax credits using the HMRC app. It is available on Android, iOS and Windows.
We will work out how much tax credits you:
If the amount you got already was wrong, we will pay you the right amount or ask you to pay back any extra money.
From HMRC Tax Credits
} }


Gecode::Iter::Ranges::ValCache< I > Class Template Reference
[Range iterators]
Detailed Description
template<class I>
class Gecode::Iter::Ranges::ValCache< I >
Range iterator cache
Allows to iterate the ranges as defined by the input iterator several times provided the ValCache is reset by the reset member function.
Definition at line 164 of file ranges-cache.icc.
Constructors and initialization | |
| ValCache (void) | |
| Default constructor. | |
| ValCache (I &i) | |
| Initialize with ranges from i. | |
| void | init (I &i) |
| Initialize with ranges from i. | |
Iteration control | |
| bool | operator() (void) const |
| Test whether iterator is still at a range or done. | |
| void | operator++ (void) |
| Move iterator to next range (if possible). | |
| void | operator-- (void) |
| Move iterator to previous range (if possible). | |
| void | reset (void) |
| Reset iterator to start from beginning. | |
| void | last (void) |
| Start iteration from end. | |
| void | finish (void) |
| Stop iteration. | |
Range access | |
| int | min (void) const |
| Always returns val. | |
| int | max (void) const |
| Always returns val. | |
| int | val (void) const |
| Return value. | |
| unsigned int | width (void) const |
| Return width of range (distance between minimum and maximum). | |
| unsigned int | size (void) const |
| Return size of the union over all ranges. | |
Index acces | |
| void | index (unsigned int i) |
| Start iteration from ith range in cache. | |
| unsigned int | index (void) |
| Get the index of the current range. | |
Protected Attributes | |
| SharedArray< int > | r |
| Array for ranges. | |
| int | c |
| Current range. | |
| int | n |
| Number of ranges in cache. | |
| int | s |
| Number of elements in cache. |
Constructor & Destructor Documentation
template<class I>
| Gecode::Iter::Ranges::ValCache< I >::ValCache | ( | void | ) | [inline] |
template<class I>
| Gecode::Iter::Ranges::ValCache< I >::ValCache | ( | I & | i | ) | [inline] |
Member Function Documentation
template<class I>
| void Gecode::Iter::Ranges::ValCache< I >::init | ( | I & | i | ) | [inline] |
template<class I>
| bool Gecode::Iter::Ranges::ValCache< I >::operator() | ( | void | ) | const [inline] |
template<class I>
| void Gecode::Iter::Ranges::ValCache< I >::operator++ | ( | void | ) | [inline] |
template<class I>
| void Gecode::Iter::Ranges::ValCache< I >::operator-- | ( | void | ) | [inline] |
template<class I>
| void Gecode::Iter::Ranges::ValCache< I >::reset | ( | void | ) | [inline] |
template<class I>
| void Gecode::Iter::Ranges::ValCache< I >::last | ( | void | ) | [inline] |
template<class I>
| void Gecode::Iter::Ranges::ValCache< I >::finish | ( | void | ) | [inline] |
template<class I>
| int Gecode::Iter::Ranges::ValCache< I >::min | ( | void | ) | const [inline] |
template<class I>
| int Gecode::Iter::Ranges::ValCache< I >::max | ( | void | ) | const [inline] |
template<class I>
| int Gecode::Iter::Ranges::ValCache< I >::val | ( | void | ) | const [inline] |
template<class I>
| unsigned int Gecode::Iter::Ranges::ValCache< I >::width | ( | void | ) | const [inline] |
Return width of range (distance between minimum and maximum).
Definition at line 311 of file ranges-cache.icc.
template<class I>
| unsigned int Gecode::Iter::Ranges::ValCache< I >::size | ( | void | ) | const [inline] |
template<class I>
| void Gecode::Iter::Ranges::ValCache< I >::index | ( | unsigned int | i | ) | [inline] |
template<class I>
| unsigned int Gecode::Iter::Ranges::ValCache< I >::index | ( | void | ) | [inline] |
Member Data Documentation
template<class I>
SharedArray<int> Gecode::Iter::Ranges::ValCache< I >::r [protected] |
template<class I>
int Gecode::Iter::Ranges::ValCache< I >::c [protected] |
template<class I>
int Gecode::Iter::Ranges::ValCache< I >::n [protected] |
template<class I>
int Gecode::Iter::Ranges::ValCache< I >::s [protected] |
The documentation for this class was generated from the following file:
- gecode/iter/ranges-cache.icc (Revision: 5262)


ACME Garden Planner
Home
Plan Garden
View Gardens
My Garden
Create New Garden
View My Gardens
Planting Calendar


RessourceConsuming
public protocol RessourceConsuming: Conditionable
an adopting object may consume specific amounts of one or more ressources
-
list of ressources consumed
Declaration
Swift
var ressources: RessourceContainer { get }
-
consumes(ressource:)
Default implementationchecks wether the given RessourceType is consumed, ignoring the value
Default Implementation
checks wether the given RessourceType is consumed, ignoring the value
Declaration
Swift
func consumes(ressource ressource: RessourceType) -> Bool
Parameters
ressource
the RessourceType to search for
Return Value
Bool


|
|
|
BaseGoGridAsyncClientTest
|
|
BaseGoGridClientLiveTest
|
|
BaseGoGridRestClientExpectTest
|
|
GridImageAsyncClientTest
|
|
GridImageClientLiveTest
|
|
GridIpAsyncClientTest
|
|
GridJobAsyncClientTest
|
|
GridJobClientLiveTest
|
|
GridLoadBalancerAsyncClientTest
|
|
GridServerAsyncClientTest
|
|
GridServerClientExpectTest
|
|
TestGoGridRestClientModule
|


Provides a simple interface to VIDDEC2 (XDM 1.2) based algorithms. For typical usage see the video_decode_io2 app. More...
Typedefs | |
| typedef struct Vdec2_Object * | Vdec2_Handle |
| Handle through which to reference a Video Decode algorithm. | |
Functions | |
| Vdec2_Handle | Vdec2_create (Engine_Handle hEngine, Char *codecName, VIDDEC2_Params *params, VIDDEC2_DynamicParams *dynParams) |
| Creates a Video Decode (XDM 1.2) algorithm instance. | |
| Int | Vdec2_flush (Vdec2_Handle hVd) |
| Flushes the codec. Call Vdec2_process (hInBuf is ignored) after this call and then Vdec2_getDisplayBuf to obtain display buffers display, and Vdec2_getFreeBuf to obtain buffers to free. | |
| Int | Vdec2_process (Vdec2_Handle hVd, Buffer_Handle hInBuf, Buffer_Handle hDstBuf) |
| Decodes a video buffer. Call Vdec2_getDisplayBuf after this call to obtain buffers to display, and Vdec2_getFreeBuf to obtain buffers to free. | |
| Int | Vdec2_delete (Vdec2_Handle hVd) |
| Deletes a Video Decode algorithm instance. | |
| Int32 | Vdec2_getMinOutBufs (Vdec2_Handle hVd) |
| Figures out the actual output buffer requirements of the codec after the first Vdec2_process call. Also updates the buffer requirements for subsequent Vdec2_getInBufSize and Vdec2_getOutBufSize calls. | |
| Void | Vdec2_setBufTab (Vdec2_Handle hVd, BufTab_Handle hBufTab) |
| After a Vdec2_create call is made, this function should be called to hand a BufTab_Handle to the video decoder instance. Because of B-frames, the destination buffer given may not be the same as the output buffer returned, so the Vdec2 class needs a full array of buffers to work with. | |
| BufTab_Handle | Vdec2_getBufTab (Vdec2_Handle hVd) |
| Get the BufTab previously set using Vdec2_setBufTab. | |
| VIDDEC2_Handle | Vdec2_getVisaHandle (Vdec2_Handle hVd) |
| Get the VIDDEC2 handle from the Vdec2 module instance. | |
| Int32 | Vdec2_getInBufSize (Vdec2_Handle hVd) |
| Get the input buffer size required by the codec. | |
| Int32 | Vdec2_getOutBufSize (Vdec2_Handle hVd) |
| Get the output buffer size required by the codec. | |
| Buffer_Handle | Vdec2_getDisplayBuf (Vdec2_Handle hVd) |
| After a Vdec2_process call is made, this function should be called to obtain buffers to display. This function should be called consecutively until no more buffers are returned. | |
| Buffer_Handle | Vdec2_getFreeBuf (Vdec2_Handle hVd) |
| After a Vdec2_process call is made, this function should be called to obtain buffers to free. This function should be called consecutively until no more buffers are returned. | |
Variables | |
| const VIDDEC2_Params | Vdec2_Params_DEFAULT |
| Default XDM parameters for a Video Decode (XDM 1.2) algorithm. | |
| const VIDDEC2_DynamicParams | Vdec2_DynamicParams_DEFAULT |
| Default XDM dynamic parameters for a Video Decode (XDM 1.2) algorithm. |
Provides a simple interface to VIDDEC2 (XDM 1.2) based algorithms. For typical usage see the video_decode_io2 app.
| typedef struct Vdec2_Object* Vdec2_Handle |
Handle through which to reference a Video Decode algorithm.
| Vdec2_Handle Vdec2_create | ( | Engine_Handle | hEngine, | |
| Char * | codecName, | |||
| VIDDEC2_Params * | params, | |||
| VIDDEC2_DynamicParams * | dynParams | |||
| ) |
Creates a Video Decode (XDM 1.2) algorithm instance.
| [in] | hEngine | An opened engine containing the algorithm to create. |
| [in] | codecName | The name of the algorithm to open. Corresponds to the string name given in the .cfg file. |
| [in] | params | XDM parameters to use while creating the codec. |
| [in] | dynParams | XDM dynamic parameters to use while creating the codec. |
| Handle | for use in subsequent operations (see Vdec2_Handle). | |
| NULL | for failure. |
| Int Vdec2_flush | ( | Vdec2_Handle | hVd | ) |
Flushes the codec. Call Vdec2_process (hInBuf is ignored) after this call and then Vdec2_getDisplayBuf to obtain display buffers display, and Vdec2_getFreeBuf to obtain buffers to free.
| [in] | hVd | The Vdec2_Handle to of the decoder to flush. |
| Dmai_EOK | for success. | |
| Negative value | for failure, see Dmai.h. |
| Int Vdec2_process | ( | Vdec2_Handle | hVd, | |
| Buffer_Handle | hInBuf, | |||
| Buffer_Handle | hDstBuf | |||
| ) |
Decodes a video buffer. Call Vdec2_getDisplayBuf after this call to obtain buffers to display, and Vdec2_getFreeBuf to obtain buffers to free.
| [in] | hVd | The Vdec2_Handle to use for decoding. |
| [in] | hInBuf | The Buffer_Handle of the buffer containing the encoded data. |
| [in] | hDstBuf | The Buffer_Handle of the buffer passed to the decoder to be filled with data. |
| Dmai_EOK | for success. | |
| Negative value | for failure, see Dmai.h. |
| Int Vdec2_delete | ( | Vdec2_Handle | hVd | ) |
Deletes a Video Decode algorithm instance.
| [in] | hVd | The Vdec2_Handle to delete. |
| Dmai_EOK | for success. | |
| Negative value | for failure, see Dmai.h. |
| Int32 Vdec2_getMinOutBufs | ( | Vdec2_Handle | hVd | ) |
Figures out the actual output buffer requirements of the codec after the first Vdec2_process call. Also updates the buffer requirements for subsequent Vdec2_getInBufSize and Vdec2_getOutBufSize calls.
| [in] | hVd | The Vdec2_Handle to use for decoding. |
| Number | of required output buffers on success. | |
| Negative value | for failure, see Dmai.h. |
| Void Vdec2_setBufTab | ( | Vdec2_Handle | hVd, | |
| BufTab_Handle | hBufTab | |||
| ) |
After a Vdec2_create call is made, this function should be called to hand a BufTab_Handle to the video decoder instance. Because of B-frames, the destination buffer given may not be the same as the output buffer returned, so the Vdec2 class needs a full array of buffers to work with.
| [in] | hVd | The Vdec2_Handle to set the BufTab for. |
| [in] | hBufTab | The BufTab_Handle to give to the video decoder. |
| BufTab_Handle Vdec2_getBufTab | ( | Vdec2_Handle | hVd | ) |
Get the BufTab previously set using Vdec2_setBufTab.
| [in] | hVd | The Vdec2_Handle for which to get the BufTab. |
| Handle | to the BufTab managing the codec buffers (see BufTab_Handle). |
| VIDDEC2_Handle Vdec2_getVisaHandle | ( | Vdec2_Handle | hVd | ) |
Get the VIDDEC2 handle from the Vdec2 module instance.
| [in] | hVd | The Vdec2_Handle for which to get the VIDDEC2 handle. |
| Handle | to the audio decode algorithm, see the XDM documentation for VIDDEC2. |
| Int32 Vdec2_getInBufSize | ( | Vdec2_Handle | hVd | ) |
Get the input buffer size required by the codec.
| [in] | hVd | The Vdec2_Handle for which to get the buffer size. |
| Size | in bytes of the input buffer required. |
| Int32 Vdec2_getOutBufSize | ( | Vdec2_Handle | hVd | ) |
Get the output buffer size required by the codec.
| [in] | hVd | The Vdec2_Handle for which to get the buffer size. |
| Size | in bytes of the output buffer required. |
| Buffer_Handle Vdec2_getDisplayBuf | ( | Vdec2_Handle | hVd | ) |
After a Vdec2_process call is made, this function should be called to obtain buffers to display. This function should be called consecutively until no more buffers are returned.
| [in] | hVd | The Vdec2_Handle to obtain display buffers from. |
| Handle | to a Buffer to display (see Buffer_Handle). | |
| NULL | if no more Buffers are available. |
| Buffer_Handle Vdec2_getFreeBuf | ( | Vdec2_Handle | hVd | ) |
After a Vdec2_process call is made, this function should be called to obtain buffers to free. This function should be called consecutively until no more buffers are returned.
| [in] | hVd | The Vdec2_Handle to obtain free buffers from. |
| Handle | to a Buffer to free (see Buffer_Handle). | |
| NULL | if no more Buffers are available. |
| const VIDDEC2_Params Vdec2_Params_DEFAULT |
Default XDM parameters for a Video Decode (XDM 1.2) algorithm.
size = sizeof(VIDDEC2_Params),
maxHeight = 576,
maxWidth = 720,
maxFrameRate = 30000,
maxBitRate = 6000000,
dataEndianness = XDM_BYTE,
forceChromaFormat = XDM_YUV_420P
| const VIDDEC2_DynamicParams Vdec2_DynamicParams_DEFAULT |
Default XDM dynamic parameters for a Video Decode (XDM 1.2) algorithm.
size = sizeof(VIDDEC2_DynamicParams),
decodeHeader = XDM_DECODE_AU,
displayWidth = 0,
frameSkipMode = IVIDEO_NO_SKIP,
frameOrder = IVIDDEC2_DISPLAY_ORDER,
newFrameFlag = 0,
mbDataFlag = 0


1. Title Selected Components.
Once removed component in adaptation process, user can add those individually to the web page, in case of requirement. For that, user should have a name to identify component for addition. So, titles of each component should be provided. Title should be in between 2-5 words that describes the function of component. As an example ;
| component functionality | title |
|---|---|
| view the things that to be done. | to-do list |
| show the news of the day | news feed |
| show notifications from the management | notification tab |
Create unique and descriptive titles for all elements in component list and edit header tag of each component by adding title to it as ;
2. Create Array and Paste on WebPage.
Now create a javascript array of element ID as follows and paste it just before body tag closer.


---
layout: post
title: Bits of Platform11
categories:
- KDE
- Software Libre
tags: []
status: publish
type: post
published: true
meta:
_edit_last: '2'
dsq_thread_id: '2244602180'
author:
login: afiestas
email<EMAIL_ADDRESS>display_name: afiestas
first_name: Àlex
last_name: Fiestas
---
Tomorrow we will be all leaving towards our respective homes and platform11 will be formally done, though the work is far to be finished. In this blogspot I'm not going to talk about that though :p
I'm going to talk about how important these events are beyond the technical expects and what I'm going to say applies to my experience in this sprint.
- You can "Put faces" to people, you're no longer talking to "dfaure" or "apachelloger" or... you're talking to a person, you know how they're and more or less how they think, and that makes the communication much more efficient.
- Brotherhood is enhanced, after don't let anyone sleep because there are 3 people in a "snoring championship" you get some confidence with the group :p this improve the way we work.
- Knowledge is transfered: Do you know the reason why KToolInvocation is using KLaunch to execute apps and at the same time KLaunch is using kdeinit ? I didn't know before a dinosaur told me the reason :p
- Unify positions: During this sprint I've seen people saying NO! to something end up by saying yes, the amount of things that can be discussed in person are way bigger than via email or irc.
- Fast integration feel for newcomers: People that have been contributing into KDE for month's or even years started the sprint saying: You have to... When you... and end up saying: We have to... When we...
So, to sump up:
Sprints are NOT only about core, are also about People and because of that, they're extremely important for the health of KDE.
Thanks you all that make possible to organize such events, and particularly thanks for Joining the game!


SIX DAYS, SEVEN NIGHTS RATING: 7 / 10 --> Good movie
For more reviews and movie trivia, go to http://surf.to/joblo/
>From the man who brought us GHOSTBUSTERS and TWINS, comes a story starring Han Solo, Harrison Ford, and the woman presently dating TV star Ellen DeGeneres, Anne Heche. Director Ivan Reitman straps himself behind the camera for this fuzzy piece of ROMANCING THE STONE (7.5/10)-lite.
PLOT: Loving, romantic man takes his lady of choice to an exotic island for some time alone together. While there, she gets called away on business, and is taken to Tahiti, by a carefree and wayward pilot. During a storm, their plane gets hit by lightning and crashes onto an unknown island. Stuck with one another, the duo attempt to find a way back to civilization, and gradually get to know each other better.
CRITIQUE: Mindless fluff piece does not pass itself off as anything more than a simple 95-minute exercise in mild comedy, overly precise romance, decent chemistry and a non-threatening adventure. I enjoyed this movie on the whole because I was able to rest my brain for a quick little while, and allow myself to follow the misadventures of two charming actors, whose fate never seemed like much of a mystery to me. The film was easy to digest, well enough to enjoy along a round of tasty hot nachos, and perfectly paced as to never allow you to fully grasp the generic nature of its essence.
Kudos go out to both Harrison Ford and Anne Heche, who luckily for the audience, seem to have sparked off a few rays of charm into their characters. The opposite can be said of David Schwimmer, who still cannot seem to play anything but that dolt-headed puppy-eyed love schmuck from his hit TV show "Friends". That aside, I was impressed by his character's real struggle over extra-curricular sexual activities, and the actual conscience that he displayed in its aftermath. Unlike many men in other movies, this character showed us that a man isn't always ready to jump into bed with a chesty knockout at a drop of a dime, but that morals, ethics and one's conscience always play a revolving part in any such decision.
Overall, the film doesn't have many standout scenes to write home about, but does offer some beautiful shots of the island's panoramic possessions, along with some engaging performances by its leads. You'll laugh, you'll sigh, you won't fall asleep and you'll forget about the whole thing in the morning. If these are some of the elements that you are looking for in a short film mixed in with a little adventure, then this one's your bag o' nuts! If not, skip this, and your life will forever be the same for having missed it.
Little Known Facts about this film and its stars: Perhaps the most fateful casting of Harrison Ford's career was for a role that he very nearly passed up. A promising young director named George Lucas offered him a supporting part in his film AMERICAN GRAFFITI (7/10), but Ford walked off the set in disgust when he learned that he would be paid only $485 a week, less than half what he was earning at that time as a carpenter. Luckily, he changed his mind when the studio offered him an extra fifteen dollars a week. He also got the part of Indiana Jones in RAIDERS OF THE LOST ARK (8/10), after Spielberg and Lucas could not schedule filming of the movie around their first choice's TV schedule, as Tom Selleck had a commitment to his hit TV show "Magnum P.I.". Harrison's wife is a screenwriter in her own right, and counts E.T. (8/10) and Martin Scorsese's KUNDUN among her handful of credits. In fact, in 1996, Harrison was listed as one of 50 people barred from entering Tibet, after Disney clashed with Chinese officials over the film KUNDUN, which his wife wrote. Anne Heche's father, Donald Heche, was a choir director in a Baptist church who frequented gay bars at night. Heche found out about her father's double life at the age of twelve, as he lay dying of AIDS. "I watched my dad disintegrate from AIDS because he was ashamed to be what he wanted to be," Heche relates. He died the following year. In 1991, she won a Daytime Emmy for playing Outstanding Younger Actress in a Daytime Drama Series for TV's "Another World". Actress Jacqueline Obradors, who plays the playful Angelica in this film, was discovered by a producer while she was working as a grocery store clerk. Director Ivan Reitman was born in Czechoslovakia, but brought up in Canada. David Schwimmer graduated from Northwestern University. His mother is a lawyer who took care of Roseanne's first divorce.
Review Date: December 27, 1998 Director: Ivan Reitman Writer: Michael Browning Producers: Ivan Reitman, Roger Birnbaum and Wallis Nicita Actors: Harrison Ford as Quinn Harris Anne Heche as Robin Monroe David Schwimmer as Frank Martin Jacqueline Obradors as Angelica Genre: Comedy Year of Release: 1998
Visit JoBlo's Movie Emporium http://surf.to/joblo
(c) 1998 Berge Garabedian
The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).
The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.
Please direct comments/criticisms of the review to relevant newsgroups.
Broken URLs inthe reviews are the responsibility of the author.
The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.
Related links: index of all rec.arts.movies.reviews reviews