代码之家  ›  专栏  ›  技术社区  ›  Velociraptors

通过使用读取/写入XML进行数据处理。网

  •  1
  • Velociraptors  · 技术社区  · 17 年前

    MML ,JSim的数学建模语言,自JSim被研究人员广泛使用以来。基本上,模型包含变量(具有公式、初始值和可选单位)和常量参数(具有值和可选单元)。变量和参数在内部由相同的数据类型表示,因为两者之间的唯一区别是它是否有公式。

    我目前的解决方案是将模型保存为XML,而不是MML文本文件:

    <model xmlns="http://tempuri.org/model_schema.xsd">
        <name>sample_model</name>
        <description>String</description>
        <variable type="realDomain" constant="false">
            <name>ID_1</name>
            <formula>G_p/VG</formula>
            <value>0.75</value>
            <units>s^-1</units>
            <description>String</description>
            <anatomical_structure FMAID="62970">
                <name>Kidney</name>
            </anatomical_structure>
        </variable>
        <variable type="real" constant="true">
            <name>ID_2</name>
            <formula />
            <value>1000</value>
            <units>mg</units>
        </variable>
    </model>
    

    <xs:schema id="model_schema" targetNamespace="http://tempuri.org/model_schema.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/model_schema.xsd" xmlns:mstns="http://tempuri.org/model_schema.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xs:element name="model">
            <xs:complexType>
                <xs:sequence>
                    <xs:element name="name" type="xs:string" />
                    <xs:element name="description" type="xs:string" minOccurs="0" />
                    <xs:element name="variable" maxOccurs="unbounded">
                        <xs:complexType>
                            <xs:sequence>
                                <xs:element name="name" type="xs:ID" />
                                <xs:element name="formula" type="xs:string" />
                                <xs:element name="value" type="xs:float" />
                                <xs:element name="units" type="xs:string" minOccurs="0" />
                                <xs:element name="description" type="xs:string" minOccurs="0" />
                                <xs:element name="anatomical_structure" minOccurs="0">
                                    <xs:complexType>
                                        <xs:sequence>
                                            <xs:element name="name" type="xs:string" />
                                        </xs:sequence>
                                        <xs:attribute name="FMAID" type="xs:int" use="required" />
                                    </xs:complexType>
                                </xs:element>
                            </xs:sequence>
                            <xs:attribute name="constant" type="xs:boolean" use="required" />
                            <xs:attribute name="type" type="var_type" />
                        </xs:complexType>
                    </xs:element>
                </xs:sequence>
            </xs:complexType>
        </xs:element>
        <xs:simpleType name="var_type">
            <xs:restriction base="xs:string">
                <xs:enumeration value="realDomain" />
                <xs:enumeration value="real" />
                <xs:enumeration value="int" />
            </xs:restriction>
        </xs:simpleType>
    </xs:schema>
    

    1 回复  |  直到 17 年前
        1
  •  1
  •   John Saunders    17 年前


    看起来它声称可以生成C++代码。

    /language:
        The language to use for the generated code. Choose from 'CS', 'VB', 'JS',
        'VJS', 'CPP' or provide a fully-qualified name for a class implementing
        System.CodeDom.Compiler.CodeDomProvider. The default language
        is 'CS' (CSharp). Short form is '/l:'.