Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I am programing a solarcell tracker with the use of Wago PFC100 and Ecockpit software.
I have a principle problem regarding converting some counter values in a 16-bit WORD to a pulsetrain in form of BOOL.
The 16-bit word register counts up/down from 0 to 12621. I need to convert this to BOOL pulses.
when word counter goes from 0 to 1 I need a BOOL pulse 0->1->0, and on next count from 1 to 2 I need a new BOOL pulse of 0->1->0.
I also need pulses in the case that the word register counts down:
2 to 1 needs to also generate a BOOL pulse 0->1->0.
I am programing this with structured text (ST), and I don't know how I could get this part running.
There are a couple of ways to accomplish this.
If you are not expecting the counter to increment more than once per program scan, you can simply look at bit 0 of the counter. Every time it changes, pulse the output.
If it might count more than one per program scan, then on each program scan you need to look at the current counter value and compare it to the counter value on the last scan. The difference between the current value and the last value is how many times you need to pulse the output.
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed last year.
Improve this question
Edit: The solution was that the serviceRate was too high for the amount of arriving trucks.
In my Anylogic model, I have a population of terminals (5) and a population of trucks (100). The trucks visit the terminals, which are a queueing model for them. The terminals have a number of gates (e.g., 7) that can all service 1 truck at a time (service time is based on a uniform distribution). If all the gates are busy, the other trucks have to wait in a (FIFO) queue in front of the terminal.
I want to measure the time trucks are standing within the queues before the terminals (without the service time). How can I create these terminal processes best within my Anylogic model?
I tried using a service block (the first processes in the picture), but I think that gives all the time and not only the time within the queue. I also tried a queue and delay block (below), to be able to measure the queue time. However, the distribution of the time measurement is not working as I get no distribution but just 1 (very small) number, as can be seen in the lowest picture. Same if I measure the time within the service or delay block... Does any body know how to let this work? Thanks!
You delay capacity is numberOfGates. It means if that value is 5, then 5 trucks will move into delay block at the same time. Other arrived trucks will wait in the queue if delay.size()=5. There is nothing wrong in this, you should check if your model really works as intended.
The agents would move into delay block immediately if you selected the maximum capacity option in the delay block.
Also instead of timeMeasureStart/End, use your own assignments. That is, inside the delay, on enter type agent.waitStart = time(); and upon leaving type yourHistogramData.add(time()-agent.waitStart);
It turns out that the service rate was too high for the amount of trucks I send to the terminal.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am looking for a solution to split my data to Test and Train sets but I want to have all the levels of my categorical variable in both test and train.
My variable has 200 levels and the data is 18 million records. I tried sampleBy function with fractions (0.8) and could get the training set but had difficulties getting the test set since there is no index in Spark and even with creating a key, using left join or subtract is very slow to get the test set!
I want to do a groupBy based on my categorical variable and randomly sample each category and if there is only one observation for that category, put that in the train set.
Is there a default function or library to help with this operation?
A pretty hard problem.
I don't know of an in-built function which will help you get this. Using sampleBy and then so subtraction subtraction would work but as you said - would be pretty slow.
Alternatively, wonder if you can try this*:
Use window functions, add row num and remove everything with rownum=1 into a separate dataframe which you will add into your training in the end.
On the remaining data, using randomSplit (a dataframe function) to divide into training and test
Add the separated data from Step 1 to training.
This should work faster.
*(I haven't tried it before! Would be great if you can share what worked in the end!)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I want to save result to to_file block in model matlab
just I want to know what is difference between array and timeseries in save format field.
Lets start from array - it's easiest thing. If you use To File or To Workspace block with array options it writes to file just column of values of your variable.
If you use Timeseries it writes values in timeseries format. This structure consist of several fields. Main of them are Time and Data. So you get not only values but times corresponded to this data! Furthermore it contain some additional information like interpolation method and other (see it in help).
When I have to use Array and when Timeseries?
It's clear that if time moments important to you you need to use Timeseries. For example if your simulation uses variable time step then data will not be uniformly distributed.So it's helpful to get times too.
Using an array is useful if times of data is not important. For example if I save from Enabled subsystem only 1 value of my variable.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I need to generate a pulse which steps from 0 to 1 after an initial predetermined time has elapsed. When the new predetermined time is available, the pulse should again step from 1 to 0. It should step from 0 to 1 after that time has elapsed. This model has to be implemented in Simulink.
Thanks.
I'm assuming that the times at which the on/off behaviours are to be performed are available before the model simulation begins. Let's say that it's 2 seconds of value 0 and then 3 seconds of value 1.
Use the Pulse Generator block in the Sources library of Simulink. The trick is starting with a zero. To do this, set the Amplitude to 1 second, the Period to 5s, the Pulse Width to 60% and the Phase Delay to 2s.
The output will look as below.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
It is said, "If a negative edge cycle is reachable from the source than the algorithm returns false".
What does this "reachable from source indicates"?
Look at the following image:
Can you give me some example in which this algorithm will return false if there exist a negative edge cycle reachable from source.
Note: I am new to algorithms.
What that means is that if there exists a cycle that has a total weight that is negative, then the algorithm cannot give an answer because repeatedly following the cycle "reduces" the weight of the path. I don't see any negative weight cycles (by inspection) in the graph you show, so the stated limitation shouldn't be a concern in your case.
Edit: "reachable from source" means that the negative weight cycle is only a concern if it is reachable - meaning that a path from the specified source to some node in the negative weight cycle exists - from the start or source node. Bellman Ford finds the shortest path from a distinguished node to all nodes reachable from that node. Does that make sense?
When the algorithm is used to find shortest paths, the existence of negative cycles is a problem, preventing the algorithm from finding a correct answer. However, since it terminates upon finding a negative cycle, the Bellman-Ford algorithm can be used for applications in which this is the target to be sought - for example in cycle-cancelling techniques in network flow analysis.
Please refer this link:- http://evlm.stuba.sk/~partner2/DBfiles/Optimization/Dynamical%20optimization/Optimization_EN_Ford-Belman_algorithm.pdf