This repository was archived by the owner on Jan 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Example Model
Austin Drenski edited this page Feb 6, 2017
·
34 revisions
This example looks at the effect of a 1.0% price shock on one supplier in a sector where four suppliers initially have equal market shares.
| Parameter | Value |
|---|---|
| Elasticity of substitution | 4.00 |
| Elasticity of supply | 5.00 |
| Elasticity of demand | -1.00 |
| Initial price | 1.00 |
| Current price | 1.00 |
| Market share | 0.25 |
| Shock (only Supplier3 | 0.01 |
using System;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using AD.IO;
using AD.PartialEquilibriumApi.Optimization;
namespace AD.PartialEquilibriumApi.Example
{
public static class Program
{
public static void Main()
{
XmlFilePath structureFile = CreateTempXmlFile();
DelimitedFilePath dataFile = CreateTempCsvFile();
XElement model = XElement.Load(structureFile)
.DefineAttributeData(dataFile)
Console.WriteLine("-------------------------");
foreach (XElement item in model.DescendantsAndSelf().Reverse())
{
Console.WriteLine();
Console.WriteLine($"Name: {item.Name}");
foreach (XAttribute attribute in item.Attributes())
{
Console.WriteLine(attribute);
}
}
Console.WriteLine();
Console.WriteLine(model);
Console.WriteLine("-------------------------");
Console.ReadLine();
}
private static XmlFilePath CreateTempXmlFile()
{
string xml = Path.ChangeExtension(Path.GetTempFileName(), ".xml");
using (StreamWriter writer = new StreamWriter(xml))
{
writer.WriteLine(
@"<Retail>
<Supplier1 />
<Supplier2 />
<Supplier3 />
<Supplier4 />
</Retail>");
}
return new XmlFilePath(xml);
}
private static DelimitedFilePath CreateTempCsvFile()
{
string csv = Path.ChangeExtension(Path.GetTempFileName(), ".csv");
using (StreamWriter writer = new StreamWriter(csv))
{
writer.WriteLine("ElasticityOfSubstitution,ElasticityOfSupply,ElasticityOfDemand,InitialPrice,CurrentPrice,MarketShare,Shock");
writer.WriteLine("4,5,-1,1.0,1.0,1.00,0.00");
writer.WriteLine("4,5,-1,1.0,1.0,0.25,0.05");
writer.WriteLine("4,5,-1,1.0,1.0,0.25,0.00");
writer.WriteLine("4,5,-1,1.0,1.0,0.25,0.00");
writer.WriteLine("4,5,-1,1.0,1.0,0.25,0.00");
}
return new DelimitedFilePath(csv, ',');
}
}
}