P.S. This Question has been edited to answer questions made by #Felipe
I have an Agent-Based model simulation for churn behavior modeling. On each iteration(based on time--month) each user reconsiders her choice of operator(our or other) based on model metrics (Cost/SocialNetwork/...). In runtime even when I change parameters to affect Agents' decision, no one changes his/her operator. here is my state chart image on the below:
I should note that internal transition of (our user) has below details:
the first two lines are something for display. Advocate() refers to the action of sending messages which affects social influence.
But Switch() is where decision happens based on new parameters' value. In short, d defines a normalized range between -1 and 1 : signum(d) predicts which provider is the preferred one and abs(d) shows how preferred the selected provider will be.
//Definition for Switch()
double d = (this.Social_impact()/20)+this.Monthly_Charge_Impact();
if (d>0)
SwitchToUs();
else
SwitchToOther();
the two SwitchToUs and SwitchToOther functions simply change the operator (as if creating arrows between OUR_USER and OTHER_USER states)
I'm using OpenModelica 1.19.2 on Ubuntu 20.04, and I was wondering how I can create a custom periodic voltage source, with values read from an external file.
I noticed that there's the option of a TableVoltage, which takes a two-column table as input, and uses linear interpolation/extrapolation. I was hoping that this might have similar possibilities as CombiTable1D, in that you can specify a file name and extrapolation options, but that doesn't work.
Is there some way to achieve this behaviour? For example, would it be possible to generate a table using CombiTable1D and use this as an input for TableVoltage? And if so, how would I go about that? As a first guess, I tried
Modelica.Blocks.Tables.CombiTable1D myTable(fileName = "inputFile.txt", extrapolation = 3);
Modelica.Electrical.Analog.Sources.TableVoltage myVoltage(table = myTable);
but apparently that's not the right way:
Translation Error: Dimension 1 of ‘table‘ could not be deduced from the component's binding equation myTable[<myVoltage, myVoltage>]).
Using the CombiTable is a good idea as it provides a lot of functionality related to inter-/extrapolation. But you cannot pass the table object (myTable) to TableVoltage. Instead, usually connections are created between the objects. This sets the output myTable.y to the desired value(*).
This is done in the following example, which you should be able to directly copy into your Modelica code editor:
model SignalSource
Modelica.Blocks.Sources.CombiTimeTable combiTimeTable(
tableOnFile=true,
tableName="voltage",
fileName="inputFile.txt",
extrapolation=Modelica.Blocks.Types.Extrapolation.Periodic)
annotation (Placement(transformation(extent={{-60,-10},{-40,10}})));
Modelica.Electrical.Analog.Sources.SignalVoltage signalVoltage
annotation (Placement(transformation(extent={{10,-10},{-10,10}}, rotation=90)));
Modelica.Electrical.Analog.Basic.Ground ground annotation (Placement(transformation(extent={{30,-40},{50,-20}})));
Modelica.Electrical.Analog.Basic.Resistor resistor(R=10)
annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={80,0})));
equation
connect(resistor.p, signalVoltage.p) annotation (Line(points={{80,10},{80,20},{0,20},{0,10}}, color={0,0,255}));
connect(signalVoltage.n, ground.p) annotation (Line(points={{0,-10},{0,-20},{40,-20}}, color={0,0,255}));
connect(ground.p, resistor.n) annotation (Line(points={{40,-20},{80,-20},{80,-10}}, color={0,0,255}));
connect(combiTimeTable.y[1], signalVoltage.v)
annotation (Line(points={{-39,0},{-25.5,0},{-25.5,6.66134e-16},{-12,6.66134e-16}}, color={0,0,127}));
annotation (uses(Modelica(version="4.0.0")), experiment(StopTime=10));
end SignalSource;
If you then add a file inputFile.txt with the following content:
#1
double voltage(6,2)
0 0
1 0
1 1
2 4
3 9
4 16
to the working directory(**), the model should provide the following result:
(*): An alternative to having connect statements, for this example would be adding the equation signalVoltage.v = combiTimeTable.y[1];, but usually the graphical variant is preferred.
(**): As an alternative you can use any local path, but you need to specify it in the parameters of the combiTable.
I'm having a problem when I use the "Split model" option. What I want to do is basically hide these 10 water volumes:.
I select the tanks then I click on button for splitting with these options:
Final result is just what I want:
When I check the entire model to verify if everything is ok, these errors come out:
I've tried several things such as modifying the text part of the splitted model with no positive results, here's the original NOT modified
Can you please explain to me what kind of error it is? How can I resolve it? Thank you.
Edit: I'm using TIL library
Edit after Markus' answer: in the split model is it necessary to declare the type of liquid and change the portArray definition. I copied these lines of code and everything worked!
parameter TILMedia.LiquidTypes.BaseLiquid liquidType = sim.liquidType1
"Liquid type" annotation (Dialog(tab="SIM",group="SIM"),choices(
choice=sim.liquidType1 "Liquid 1 as defined in SIM",
choice=sim.liquidType2 "Liquid 2 as defined in SIM",
choice=sim.liquidType3 "Liquid 3 as defined in SIM"));
replaceable package MediaConfiguration =
TIL.Utilities.MediaConfiguration
constrainedby TIL.Utilities.Internals.PartialMediaConfiguration
"Media and State Type Configuration" annotation (choicesAllMatching, Dialog(
tab="SIM", group="Media Configuration"));
protected
outer TIL.SystemInformationManager sim "System information manager";
and
public
TIL.Connectors.LiquidPort portArray(
final liquidType=liquidType) ;
TIL.Connectors.LiquidPort portArray1(
final liquidType=liquidType) ;
The issue seems to result from the vectorization of the connectors, that seems to get lost when using "split model". A bit difficult without the actual model, but:
Have you tried to modify the last two connect statements in str3000 to:
connect(portArray, colume.portArray[1])
connect(portArray1, colume.portArray[2])
Additionally on the top level of the model, it seems you have connections to vectors of str3000.portArray. Try to remove them as they seem to be wrong, as you have two non-vector ports.
There should be something like connect(str3000.portArray[1], ...) and connect(str3000.portArray1[2], ...), which should likely be changed to connect(str3000.portArray, ...) and connect(str3000.portArray1, ...).
I'm working on automated model building. In some cases I have do convert a bus into another bus (the structure is the same, but there can be variants in the names). It works for a static model where I can change the datatype of the inputs and outputs, but I didn't find any way to do this from the command line or directly in an embedded MATLAB function.
Does anybody know a way to do this?
mfb = find(sfroot, '-isa', 'Stateflow.EMChart', 'Name', 'test');
out = get(mfb, 'Outputs');
out.set('DataType', ['Bus: ' component_source.test]);
I'm a beginner to Weka and I'm trying to use it for text classification. I have seen how to StringToWordVector filter for classification. My question is, is there any way to add more features to the text I'm classifying? For example, if I wanted to add POS tags and named entity tags to the text, how would I use these features in a classifier?
It depends of the format of your dataset and the preprocessing steps you perform. For instance, let us suppose that you have pre-POS-tagged your texts, looking like:
The_det dog_n barks_v ._p
So you can build an specific tokenizer (see weka.core.tokenizers) to generate two tokens per word, one would be "The" and the other one would be "The_det" so you keep the tag information.
If you want only tagged words, then you can just ensure that "_" is not a delimiter in the weka.core.tokenizers.WordTokenizer.
My advice is to have both the words and tagged words, so a simpler way would be to write an script that joins the texts and the tagged texts. From a file containing "The dog barks" and another one cointaining "The_det dog_n barks_v ._p", it would generate a file with "The The_det dog dog_n barks barks_v . ._p". You may even forget about the order unless you are going to make use of n-grams.