/// <summary>
 /// Construct a grouped output field.
 /// </summary>
 /// <param name="group">The group that this field belongs to.</param>
 /// <param name="sourceField">The source field for this output field.</param>
 public OutputFieldGrouped(IOutputFieldGroup group,
          IInputField sourceField)
 {
     this.group = group;
     this.sourceField = sourceField;
     this.group.GroupedFields.Add(this);
 }
 /// <summary>
 /// Construct a range mapped output field.
 /// </summary>
 /// <param name="field">The input field to base this on.</param>
 /// <param name="low">The low value.</param>
 /// <param name="high">The high value.</param>
 public OutputFieldRangeMapped(IInputField field, double low,
          double high)
 {
     this.field = field;
     this.low = low;
     this.high = high;
 }
 /// <summary>
 /// Construct a grouped output field.
 /// </summary>
 /// <param name="group">The group that this field belongs to.</param>
 /// <param name="sourceField">The source field for this output field.</param>
 protected OutputFieldGrouped(IOutputFieldGroup group,
                           IInputField sourceField)
 {
     _group = group;
     _sourceField = sourceField;
     _group.GroupedFields.Add(this);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Create a nominal item.
 /// </summary>
 /// <param name="inputField">The field that this item is based on.</param>
 /// <param name="high">The high value.</param>
 /// <param name="low">The low value.</param>
 public NominalItem(IInputField inputField, double low,
                    double high)
 {
     _high = high;
     _low = low;
     _inputField = inputField;
 }
 /// <summary>
 /// Construct a range mapped output field.
 /// </summary>
 /// <param name="field">The input field to base this on.</param>
 /// <param name="low">The low value.</param>
 /// <param name="high">The high value.</param>
 public OutputFieldRangeMapped(IInputField field, double low,
                               double high)
 {
     _field = field;
     _low = low;
     _high = high;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Create a nominal item.
 /// </summary>
 /// <param name="inputField">The field that this item is based on.</param>
 /// <param name="high">The high value.</param>
 /// <param name="low">The low value.</param>
 public NominalItem(IInputField inputField, double high,
          double low)
 {
     this.high = high;
     this.low = low;
     this.inputField = inputField;
 }
Exemplo n.º 7
0
 public OutputFieldMultiplicative(IOutputFieldGroup group, IInputField field)
     : base(group, field)
 {
     while (!(group is MultiplicativeGroup))
     {
         throw new NormalizationError("Must use MultiplicativeGroup with OutputFieldMultiplicative.");
     }
 }
Exemplo n.º 8
0
 public OutputFieldZAxis(IOutputFieldGroup group, IInputField field)
     : base(group, field)
 {
     while (!(group is ZAxisGroup))
     {
         throw new NormalizationError("Must use ZAxisGroup with OutputFieldZAxis.");
     }
 }
Exemplo n.º 9
0
 public void BuildOutputOneOf(DataNormalization norm, IInputField coverType)
 {
     var outType = new OutputOneOf();
     outType.AddItem(coverType, 1);
     outType.AddItem(coverType, 2);
     outType.AddItem(coverType, 3);
     outType.AddItem(coverType, 4);
     outType.AddItem(coverType, 5);
     outType.AddItem(coverType, 6);
     outType.AddItem(coverType, 7);
     norm.AddOutputField(outType, true);
 }
        public void Copy(FileInfo source, FileInfo target, int start, int stop, int size)
        {
            var inputField = new IInputField[55];

            var norm = new DataNormalization {Report = this, Storage = new NormalizationStorageCSV(target.ToString())};
            for (int i = 0; i < 55; i++)
            {
                inputField[i] = new InputFieldCSV(true, source.ToString(), i);
                norm.AddInputField(inputField[i]);
                IOutputField outputField = new OutputFieldDirect(inputField[i]);
                norm.AddOutputField(outputField);
            }

            // load only the part we actually want, i.e. training or eval
            var segregator2 = new IndexSampleSegregator(start, stop, size);
            norm.AddSegregator(segregator2);

            norm.Process();
        }
Exemplo n.º 11
0
        public void Narrow(FileInfo source, FileInfo target, int field, int count)
        {
            var inputField = new IInputField[55];

            var norm = new DataNormalization {Report = this, Storage = new NormalizationStorageCSV(target.ToString())};
            for (int i = 0; i < 55; i++)
            {
                inputField[i] = new InputFieldCSV(true, source.ToString(), i);
                norm.AddInputField(inputField[i]);
                IOutputField outputField = new OutputFieldDirect(inputField[i]);
                norm.AddOutputField(outputField);
            }

            var segregator = new IntegerBalanceSegregator(inputField[field], count);
            norm.AddSegregator(segregator);

            norm.Process();
            Console.WriteLine(@"Samples per tree type:");
            Console.WriteLine(segregator.DumpCounts());
        }
 /// <summary>
 /// Construct the output field with -1 for low and +1 for high.
 /// </summary>
 /// <param name="f">The input field.</param>
 public OutputFieldRangeMapped(IInputField f)
     : this(f,-1,1)
 {
 }
 /// <summary>
 /// Construct an encoded field.
 /// </summary>
 /// <param name="sourceField">The field that this is based on.</param>
 public OutputFieldEncode(IInputField sourceField)
 {
     this.sourceField = sourceField;
 }
 /// <summary>
 /// Construct a balanced segregator.
 /// </summary>
 /// <param name="target">The input field to base this on, should 
 /// be an integer value.</param>
 /// <param name="count">The number of rows to accept from each 
 /// unique value for the input.</param>
 public IntegerBalanceSegregator(IInputField target, int count)
 {
     this.target = target;
     this.count = count;
 }
Exemplo n.º 15
0
 /// <summary>
 /// Construct a balanced segregator.
 /// </summary>
 /// <param name="target">The input field to base this on, should
 /// be an integer value.</param>
 /// <param name="count">The number of rows to accept from each
 /// unique value for the input.</param>
 public IntegerBalanceSegregator(IInputField target, int count)
 {
     _target = target;
     _count  = count;
 }
Exemplo n.º 16
0
        public DataNormalization Step3(bool useOneOf)
        {
            Console.WriteLine(@"Step 3: Normalize training data");
            IInputField inputElevation;
            IInputField inputAspect;
            IInputField inputSlope;
            IInputField hWater;
            IInputField vWater;
            IInputField roadway;
            IInputField shade9;
            IInputField shade12;
            IInputField shade3;
            IInputField firepoint;
            var         wilderness = new IInputField[4];
            var         soilType   = new IInputField[40];
            IInputField coverType;

            var norm = new DataNormalization
            {
                Report  = this,
                Storage = new NormalizationStorageCSV(_config.NormalizedDataFile.ToString())
            };

            norm.AddInputField(inputElevation = new InputFieldCSV(true, _config.BalanceFile.ToString(), 0));
            norm.AddInputField(inputAspect    = new InputFieldCSV(true, _config.BalanceFile.ToString(), 1));
            norm.AddInputField(inputSlope     = new InputFieldCSV(true, _config.BalanceFile.ToString(), 2));
            norm.AddInputField(hWater         = new InputFieldCSV(true, _config.BalanceFile.ToString(), 3));
            norm.AddInputField(vWater         = new InputFieldCSV(true, _config.BalanceFile.ToString(), 4));
            norm.AddInputField(roadway        = new InputFieldCSV(true, _config.BalanceFile.ToString(), 5));
            norm.AddInputField(shade9         = new InputFieldCSV(true, _config.BalanceFile.ToString(), 6));
            norm.AddInputField(shade12        = new InputFieldCSV(true, _config.BalanceFile.ToString(), 7));
            norm.AddInputField(shade3         = new InputFieldCSV(true, _config.BalanceFile.ToString(), 8));
            norm.AddInputField(firepoint      = new InputFieldCSV(true, _config.BalanceFile.ToString(), 9));

            for (int i = 0; i < 4; i++)
            {
                norm.AddInputField(wilderness[i] = new InputFieldCSV(true, _config.BalanceFile.ToString(), 10 + i));
            }

            for (int i = 0; i < 40; i++)
            {
                norm.AddInputField(soilType[i] = new InputFieldCSV(true, _config.BalanceFile.ToString(), 14 + i));
            }

            norm.AddInputField(coverType = new InputFieldCSV(false, _config.BalanceFile.ToString(), 54));

            norm.AddOutputField(new OutputFieldRangeMapped(inputElevation));
            norm.AddOutputField(new OutputFieldRangeMapped(inputAspect));
            norm.AddOutputField(new OutputFieldRangeMapped(inputSlope));
            norm.AddOutputField(new OutputFieldRangeMapped(hWater));
            norm.AddOutputField(new OutputFieldRangeMapped(vWater));
            norm.AddOutputField(new OutputFieldRangeMapped(roadway));
            norm.AddOutputField(new OutputFieldRangeMapped(shade9));
            norm.AddOutputField(new OutputFieldRangeMapped(shade12));
            norm.AddOutputField(new OutputFieldRangeMapped(shade3));
            norm.AddOutputField(new OutputFieldRangeMapped(firepoint));

            for (int i = 0; i < 40; i++)
            {
                norm.AddOutputField(new OutputFieldDirect(soilType[i]));
            }

            if (useOneOf)
            {
                BuildOutputOneOf(norm, coverType);
            }
            else
            {
                BuildOutputEquilateral(norm, coverType);
            }

            norm.Process();
            return(norm);
        }
 /// <summary>
 /// Construct a balanced segregator.
 /// </summary>
 /// <param name="target">The input field to base this on, should
 /// be an integer value.</param>
 /// <param name="count">The number of rows to accept from each
 /// unique value for the input.</param>
 public IntegerBalanceSegregator(IInputField target, int count)
 {
     this.target = target;
     this.count  = count;
 }
Exemplo n.º 18
0
 public RebuildChecker(IInputField inputfield)
 {
     this.inputfield = inputfield;
 }
Exemplo n.º 19
0
        /// <summary>
        /// Creates a field column in a table.
        /// </summary>
        /// <param name="field">A field object</param>
        /// <param name="tableName">Name of the table.</param>
        public void CreateTableColumn(IInputField field, string tableName)
        {
            if (!dbDriver.ColumnExists(tableName, ((Epi.INamedObject)field).Name))
            {
                string fieldLength = string.Empty;
                string fieldType = field.GetDbSpecificColumnType();
                Query query;

                switch (fieldType)
                {
                    case "nvarchar":
                    case "nchar":
                        fieldLength = "(4000)";
                        break;
                    case "text":
                        fieldLength = "(255)";
                        break;
                    case "double":
                        break;
                    default:
                        break;
                }

                query = dbDriver.CreateQuery("alter table [" + tableName + "] add [" + ((Epi.INamedObject)field).Name + "] " + fieldType + fieldLength);

                dbDriver.ExecuteNonQuery(query);
            }
        }
Exemplo n.º 20
0
 public override IEnumerable <ResolvedValidator> GetValidators(IMiddlewareContext context, IInputField argument)
 => argument.RuntimeType == typeof(FooInputDto)
         ? (new ResolvedValidator[] { new ResolvedValidator(new CustomValidator()) })
         : base.GetValidators(context, argument);
 private static bool IsRequiredArgument(IInputField argument)
 {
     return(argument.Type.IsNonNullType() &&
            argument.DefaultValue is NullValueNode);
 }
Exemplo n.º 22
0
 private static ISchemaErrorBuilder SetImplementedArgument(
     this ISchemaErrorBuilder errorBuilder,
     IInputField field) =>
 errorBuilder.SetField(field, "implementedArgument");
 /// <summary>
 /// Construct the output field with -1 for low and +1 for high.
 /// </summary>
 /// <param name="f">The input field.</param>
 public OutputFieldRangeMapped(IInputField f) : this(f, -1, 1)
 {
 }
Exemplo n.º 24
0
        //Vector2 anchoredPosition;

        public RebuildChecker(IInputField input)
        {
            this.input = input;
        }
Exemplo n.º 25
0
        public override FieldMiddleware CreateExecutor <TEntityType>(NameString argumentName)
        {
            return(next => context => ExecuteAsync(next, context));

            async ValueTask ExecuteAsync(
                FieldDelegate next,
                IMiddlewareContext context)
            {
                // first we let the pipeline run and produce a result.
                await next(context).ConfigureAwait(false);

                // next we get the filter argument. If the filter argument is already on the context
                // we use this. This enabled overriding the context with LocalContextData
                IInputField argument = context.Field.Arguments[argumentName];
                IValueNode  filter   = context.LocalContextData.ContainsKey(ContextValueNodeKey) &&
                                       context.LocalContextData[ContextValueNodeKey] is IValueNode node
                        ? node
                        : context.ArgumentLiteral <IValueNode>(argumentName);

                // if no filter is defined we can stop here and yield back control.
                if (filter.IsNull() ||
                    (context.LocalContextData.TryGetValue(
                         SkipFilteringKey,
                         out object?skipObject) &&
                     skipObject is bool skip &&
                     skip))
                {
                    return;
                }

                IQueryable <TEntityType>?source = null;

                if (context.Result is IQueryable <TEntityType> q)
                {
                    source = q;
                }
                else if (context.Result is IEnumerable <TEntityType> e)
                {
                    source = e.AsQueryable();
                }

                if (source != null &&
                    argument.Type is IFilterInputType filterInput &&
                    context.Field.ContextData.TryGetValue(
                        ContextVisitFilterArgumentKey,
                        out object?executorObj) &&
                    executorObj is VisitFilterArgument executor)
                {
                    QueryableFilterContext visitorContext = executor(
                        filter,
                        filterInput,
                        source is EnumerableQuery);

                    // compile expression tree
                    if (visitorContext.TryCreateLambda(
                            out Expression <Func <TEntityType, bool> >?where))
                    {
                        context.Result = source.Where(where);
                    }
                    else
                    {
                        if (visitorContext.Errors.Count > 0)
                        {
                            context.Result = Array.Empty <TEntityType>();
                            foreach (IError error in visitorContext.Errors)
                            {
                                context.ReportError(error.WithPath(context.Path));
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 26
0
 public NominalItem(IInputField inputField, double low, double high)
 {
     this._high = high;
     this._low = low;
     this._inputField = inputField;
 }
Exemplo n.º 27
0
 public void AddItem(IInputField inputField, double value)
 {
     this.AddItem(inputField, value - 0.5, value + 0.5);
 }
Exemplo n.º 28
0
 /// <summary>
 /// Add a nominal value based on a single value.  This creates a 0.1 range
 /// around this value.
 /// </summary>
 /// <param name="inputField">The input field this is based on.</param>
 /// <param name="value">The value.</param>
 public void AddItem(IInputField inputField, double value)
 {
     AddItem(inputField, value - 0.1, value + 0.1);
 }
Exemplo n.º 29
0
 public RangeSegregator(IInputField sourceField, bool include)
 {
     this._ranges = new List<SegregationRange>();
     this._sourceField = sourceField;
     this._include = include;
 }
Exemplo n.º 30
0
        /// <summary>
        /// Called internally to obtain the current value for an input field.
        /// </summary>
        /// <param name="field">The input field to determine.</param>
        /// <param name="index">The current index.</param>
        /// <returns>The value for this input field.</returns>
        private void DetermineInputFieldValue(IInputField field, int index)
        {
            double result;

            if (field is InputFieldCSV)
            {
                var fieldCSV = (InputFieldCSV)field;
                ReadCSV csv = _csvMap[field];
                result = csv.GetDouble(fieldCSV.Offset);

            }
            else if (field is InputFieldMLDataSet)
            {
                var mlField = (InputFieldMLDataSet)field;
                MLDataFieldHolder holder = _dataSetFieldMap
                    [field];
                IMLDataPair pair = holder.Pair;
                int offset = mlField.Offset;
                if (offset < pair.Input.Count)
                {
                    result = pair.Input[offset];
                }
                else
                {
                    offset -= pair.Input.Count;
                    result = pair.Ideal[offset];
                }
            }
            else
            {
                result = field.GetValue(index);
            }

            field.CurrentValue = result;
            return;
        }
Exemplo n.º 31
0
 /// <summary>
 /// Construct a range segregator.
 /// </summary>
 /// <param name="sourceField">The source field.</param>
 /// <param name="include">Default action, if the data is not in any of the ranges,
 /// should it be included.</param>
 public RangeSegregator(IInputField sourceField, bool include)
 {
     _sourceField = sourceField;
     _include     = include;
 }
 /// <summary>
 /// Add a nominal value based on a single value.  This creates a 0.1 range
 /// around this value.
 /// </summary>
 /// <param name="inputField">The input field this is based on.</param>
 /// <param name="value">The value.</param>
 public void AddItem(IInputField inputField, double value)
 {
     AddItem(inputField, value - 0.1, value + 0.1);
 }
Exemplo n.º 33
0
        public override bool OnStart(IScriptEngine se)
        {
            context.State = "Configuring...";

            Game.Sync(() =>
            {
                var screenSize = Game.ScreenSize;

                primaryPanel = Factories.CreateGuiPanel();
                GuiScene.Add(primaryPanel);
                primaryPanel.SetSize(300, 320);
                primaryPanel.SetPosition(155, (screenSize.Y / 2), 0);
                primaryPanel.SetAnchor(new Vector2f(0.0f, 0.0f), new Vector2f(0.0f, 0.0f));
                primaryPanel.SetPivot(new Vector2f(0.5f, 0.5f));

                tierLabel = Factories.CreateGuiLabel();
                primaryPanel.Add(tierLabel);
                tierLabel.SetPosition(-60, 145, 0);
                tierLabel.SetSize(100, 25);
                tierLabel.SetText("Tier");

                harvestWoodInput = Factories.CreateGuiInputField();
                primaryPanel.Add(harvestWoodInput);
                harvestWoodInput.SetPosition(-70, 125, 0);
                harvestWoodInput.SetSize(120, 25);

                harvestWoodCheckBox = Factories.CreateGuiCheckBox();
                primaryPanel.Add(harvestWoodCheckBox);
                harvestWoodCheckBox.SetPosition(60, 125, 0);
                harvestWoodCheckBox.SetSize(100, 25);
                harvestWoodCheckBox.SetText("Harvest Wood");
                harvestWoodCheckBox.SetSelected(true);

                harvestOreInput = Factories.CreateGuiInputField();
                primaryPanel.Add(harvestOreInput);
                harvestOreInput.SetPosition(-70, 100, 0);
                harvestOreInput.SetSize(120, 25);

                harvestOreCheckBox = Factories.CreateGuiCheckBox();
                primaryPanel.Add(harvestOreCheckBox);
                harvestOreCheckBox.SetPosition(60, 100, 0);
                harvestOreCheckBox.SetSize(100, 25);
                harvestOreCheckBox.SetText("Harvest Ore");
                harvestOreCheckBox.SetSelected(true);

                harvestFiberInput = Factories.CreateGuiInputField();
                primaryPanel.Add(harvestFiberInput);
                harvestFiberInput.SetPosition(-70, 75, 0);
                harvestFiberInput.SetSize(120, 25);

                harvestFiberCheckBox = Factories.CreateGuiCheckBox();
                primaryPanel.Add(harvestFiberCheckBox);
                harvestFiberCheckBox.SetPosition(60, 75, 0);
                harvestFiberCheckBox.SetSize(100, 25);
                harvestFiberCheckBox.SetText("Harvest Fiber");
                harvestFiberCheckBox.SetSelected(true);

                harvestHideInput = Factories.CreateGuiInputField();
                primaryPanel.Add(harvestHideInput);
                harvestHideInput.SetPosition(-70, 50, 0);
                harvestHideInput.SetSize(120, 25);

                harvestHideCheckBox = Factories.CreateGuiCheckBox();
                primaryPanel.Add(harvestHideCheckBox);
                harvestHideCheckBox.SetPosition(60, 50, 0);
                harvestHideCheckBox.SetSize(100, 25);
                harvestHideCheckBox.SetText("Harvest Hide");
                harvestHideCheckBox.SetSelected(true);

                harvestStoneInput = Factories.CreateGuiInputField();
                primaryPanel.Add(harvestStoneInput);
                harvestStoneInput.SetPosition(-70, 25, 0);
                harvestStoneInput.SetSize(120, 25);

                harvestStoneCheckBox = Factories.CreateGuiCheckBox();
                primaryPanel.Add(harvestStoneCheckBox);
                harvestStoneCheckBox.SetPosition(60, 25, 0);
                harvestStoneCheckBox.SetSize(100, 25);
                harvestStoneCheckBox.SetText("Harvest Stone");
                harvestStoneCheckBox.SetSelected(true);

                killMobsCheckBox = Factories.CreateGuiCheckBox();
                primaryPanel.Add(killMobsCheckBox);
                killMobsCheckBox.SetPosition(-70, -5, 0);
                killMobsCheckBox.SetSize(125, 25);
                killMobsCheckBox.SetText("Kill Mobs");
                killMobsCheckBox.SetSelected(true);

                autoLoginCheckbox = Factories.CreateGuiCheckBox();
                primaryPanel.Add(autoLoginCheckbox);
                autoLoginCheckbox.SetPosition(60, -5, 0);
                autoLoginCheckbox.SetSize(125, 25);
                autoLoginCheckbox.SetText("Auto Relogin");
                autoLoginCheckbox.SetSelected(true);

                characterNameLabel = Factories.CreateGuiLabel();
                primaryPanel.Add(characterNameLabel);
                characterNameLabel.SetPosition(70, -35, 0);
                characterNameLabel.SetSize(125, 25);
                characterNameLabel.SetText("Character Name");

                characterNameInput = Factories.CreateGuiInputField();
                primaryPanel.Add(characterNameInput);
                characterNameInput.SetPosition(70, -55, 0);
                characterNameInput.SetSize(125, 25);

                setVaultAreaButton = Factories.CreateGuiButton();
                primaryPanel.Add(setVaultAreaButton);
                setVaultAreaButton.SetPosition(-70, -35, 0);
                setVaultAreaButton.SetSize(125, 25);
                setVaultAreaButton.SetText("Set Vault Loc.");
                setVaultAreaButton.AddActionListener((e) =>
                {
                    var local = Players.LocalPlayer;
                    if (local != null)
                    {
                        var loc  = local.ThreadSafeLocation;
                        var area = loc.Expand(4, 2, 4);
                        Logging.Log("Set vault loc to " + loc.X + " " + loc.Y + " " + loc.Z);
                        config.VaultClusterName = Game.ClusterName;
                        config.VaultDest        = new SafeVector3(new Vector3f(loc.X, loc.Y, loc.Z));
                        config.VaultArea        = new SafeMapArea(Game.Cluster.Name, new Area(area.Start, area.End));
                    }
                });

                setRepairAreaButton = Factories.CreateGuiButton();
                primaryPanel.Add(setRepairAreaButton);
                setRepairAreaButton.SetPosition(-70, -65, 0);
                setRepairAreaButton.SetSize(125, 25);
                setRepairAreaButton.SetText("Set Repair Loc.");
                setRepairAreaButton.AddActionListener((e) =>
                {
                    var local = Players.LocalPlayer;
                    if (local != null)
                    {
                        var loc  = local.ThreadSafeLocation;
                        var area = loc.Expand(4, 2, 4);
                        Logging.Log("Set repair loc to " + loc.X + " " + loc.Y + " " + loc.Z);
                        config.RepairClusterName = Game.ClusterName;
                        config.RepairDest        = new SafeVector3(new Vector3f(loc.X, loc.Y, loc.Z));
                        config.RepairArea        = new SafeMapArea(Game.ClusterName, new Area(area.Start, area.End));
                    }
                });

                addRoamPointButton = Factories.CreateGuiButton();
                primaryPanel.Add(addRoamPointButton);
                addRoamPointButton.SetPosition(-70, -95, 0);
                addRoamPointButton.SetSize(125, 25);
                addRoamPointButton.SetText("Add Roam Point");
                addRoamPointButton.AddActionListener((e) =>
                {
                    var local = Players.LocalPlayer;
                    if (local != null)
                    {
                        var loc = local.ThreadSafeLocation;
                        Logging.Log("Add roam point " + loc.X + " " + loc.Y + " " + loc.Z);
                        config.ResourceClusterName = Game.ClusterName;
                        config.RoamPoints.Add(new SafeVector3(new Vector3f(loc.X, loc.Y, loc.Z)));
                    }
                });

                removeRoamPointButton = Factories.CreateGuiButton();
                primaryPanel.Add(removeRoamPointButton);
                removeRoamPointButton.SetPosition(60, -95, 0);
                removeRoamPointButton.SetSize(125, 25);
                removeRoamPointButton.SetText("Del Roam Point");
                removeRoamPointButton.AddActionListener((e) =>
                {
                    var local = Players.LocalPlayer;
                    if (local != null)
                    {
                        var loc = local.ThreadSafeLocation;
                        Logging.Log("Delete roam point " + loc.X + " " + loc.Y + " " + loc.Z);
                        for (var i = 0; i < config.RoamPoints.Count; i++)
                        {
                            if (config.RoamPoints[i].RealVector3().Expand(3, 3, 3).Contains(loc))
                            {
                                config.RoamPoints.RemoveAt(i);
                                i -= 1;
                            }
                        }
                    }
                });

                runButton = Factories.CreateGuiButton();
                primaryPanel.Add(runButton);
                runButton.SetPosition(0, -140, 0);
                runButton.SetSize(125, 25);
                runButton.SetText("Run");
                runButton.AddActionListener((e) =>
                {
                    if (config.VaultDest == null)
                    {
                        context.State = "No vault area set!";
                        return;
                    }

                    if (config.RoamPoints.Count == 0)
                    {
                        context.State = "No roam points added!";
                        return;
                    }

                    SelectedStart();
                });

                UpdateForConfig();
            });

            return(true);
        }
 /// <summary>
 /// Construct a direct output field.
 /// </summary>
 /// <param name="sourceField">The source field to pass directly on.</param>
 public OutputFieldDirect(IInputField sourceField)
 {
     _sourceField = sourceField;
 }
Exemplo n.º 35
0
        public DataNormalization Step3(bool useOneOf)
        {
            Console.WriteLine(@"Step 3: Normalize training data");
            IInputField inputElevation;
            IInputField inputAspect;
            IInputField inputSlope;
            IInputField hWater;
            IInputField vWater;
            IInputField roadway;
            IInputField shade9;
            IInputField shade12;
            IInputField shade3;
            IInputField firepoint;
            var wilderness = new IInputField[4];
            var soilType = new IInputField[40];
            IInputField coverType;

            var norm = new DataNormalization
                           {
                               Report = this,
                               Storage = new NormalizationStorageCSV(_config.NormalizedDataFile.ToString())
                           };
            norm.AddInputField(inputElevation = new InputFieldCSV(true, _config.BalanceFile.ToString(), 0));
            norm.AddInputField(inputAspect = new InputFieldCSV(true, _config.BalanceFile.ToString(), 1));
            norm.AddInputField(inputSlope = new InputFieldCSV(true, _config.BalanceFile.ToString(), 2));
            norm.AddInputField(hWater = new InputFieldCSV(true, _config.BalanceFile.ToString(), 3));
            norm.AddInputField(vWater = new InputFieldCSV(true, _config.BalanceFile.ToString(), 4));
            norm.AddInputField(roadway = new InputFieldCSV(true, _config.BalanceFile.ToString(), 5));
            norm.AddInputField(shade9 = new InputFieldCSV(true, _config.BalanceFile.ToString(), 6));
            norm.AddInputField(shade12 = new InputFieldCSV(true, _config.BalanceFile.ToString(), 7));
            norm.AddInputField(shade3 = new InputFieldCSV(true, _config.BalanceFile.ToString(), 8));
            norm.AddInputField(firepoint = new InputFieldCSV(true, _config.BalanceFile.ToString(), 9));

            for (int i = 0; i < 4; i++)
            {
                norm.AddInputField(wilderness[i] = new InputFieldCSV(true, _config.BalanceFile.ToString(), 10 + i));
            }

            for (int i = 0; i < 40; i++)
            {
                norm.AddInputField(soilType[i] = new InputFieldCSV(true, _config.BalanceFile.ToString(), 14 + i));
            }

            norm.AddInputField(coverType = new InputFieldCSV(false, _config.BalanceFile.ToString(), 54));

            norm.AddOutputField(new OutputFieldRangeMapped(inputElevation));
            norm.AddOutputField(new OutputFieldRangeMapped(inputAspect));
            norm.AddOutputField(new OutputFieldRangeMapped(inputSlope));
            norm.AddOutputField(new OutputFieldRangeMapped(hWater));
            norm.AddOutputField(new OutputFieldRangeMapped(vWater));
            norm.AddOutputField(new OutputFieldRangeMapped(roadway));
            norm.AddOutputField(new OutputFieldRangeMapped(shade9));
            norm.AddOutputField(new OutputFieldRangeMapped(shade12));
            norm.AddOutputField(new OutputFieldRangeMapped(shade3));
            norm.AddOutputField(new OutputFieldRangeMapped(firepoint));

            for (int i = 0; i < 40; i++)
            {
                norm.AddOutputField(new OutputFieldDirect(soilType[i]));
            }

            if (useOneOf)
                BuildOutputOneOf(norm, coverType);
            else
                BuildOutputEquilateral(norm, coverType);

            norm.Process();
            return norm;
        }
Exemplo n.º 36
0
            public static object?DefaultValue(IPureResolverContext context)
            {
                IInputField field = context.Parent <IInputField>();

                return(field.DefaultValue.IsNull() ? null : field.DefaultValue !.Print());
            }
 /// <summary>
 /// Construct an encoded field.
 /// </summary>
 /// <param name="sourceField">The field that this is based on.</param>
 public OutputFieldEncode(IInputField sourceField)
 {
     _sourceField = sourceField;
 }
Exemplo n.º 38
0
 /// <summary>
 /// Construct a direct output field.
 /// </summary>
 /// <param name="sourceField">The source field to pass directly on.</param>
 public OutputFieldDirect(IInputField sourceField)
 {
     _sourceField = sourceField;
 }
Exemplo n.º 39
0
 /// <summary>
 /// Construct a range segregator.
 /// </summary>
 /// <param name="sourceField">The source field.</param>
 /// <param name="include">Default action, if the data is not in any of the ranges,
 /// should it be included.</param>
 public RangeSegregator(IInputField sourceField, bool include)
 {
     _sourceField = sourceField;
     _include = include;
 }
Exemplo n.º 40
0
        public override FieldMiddleware CreateExecutor <TEntityType>(NameString argumentName)
        {
            return(next => context => ExecuteAsync(next, context));

            async ValueTask ExecuteAsync(
                FieldDelegate next,
                IMiddlewareContext context)
            {
                // first we let the pipeline run and produce a result.
                await next(context).ConfigureAwait(false);

                // next we get the sort argument.
                IInputField argument = context.Field.Arguments[argumentName];
                IValueNode  sort     = context.ArgumentLiteral <IValueNode>(argumentName);

                // if no sort is defined we can stop here and yield back control.
                if (sort.IsNull() ||
                    (context.LocalContextData.TryGetValue(
                         SkipSortingKey,
                         out object?skipObject) &&
                     skipObject is bool skip &&
                     skip))
                {
                    return;
                }

                if (argument.Type is ListType lt &&
                    lt.ElementType is NonNullType nn &&
                    nn.NamedType() is ISortInputType sortInput &&
                    context.Field.ContextData.TryGetValue(
                        ContextVisitSortArgumentKey,
                        out object?executorObj) &&
                    executorObj is VisitSortArgument executor)
                {
                    var inMemory =
                        context.Result is QueryableExecutable <TEntityType> executable &&
                        executable.InMemory ||
                        context.Result is not IQueryable ||
                        context.Result is EnumerableQuery;

                    QueryableSortContext visitorContext = executor(
                        sort,
                        sortInput,
                        inMemory);

                    // compile expression tree
                    if (visitorContext.Errors.Count > 0)
                    {
                        context.Result = Array.Empty <TEntityType>();
                        foreach (IError error in visitorContext.Errors)
                        {
                            context.ReportError(error.WithPath(context.Path));
                        }
                    }
                    else
                    {
                        context.Result = context.Result switch
                        {
                            IQueryable <TEntityType> q => visitorContext.Sort(q),
                            IEnumerable <TEntityType> e => visitorContext.Sort(e.AsQueryable()),
                            QueryableExecutable <TEntityType> ex =>
                            ex.WithSource(visitorContext.Sort(ex.Source)),
                            _ => context.Result
                        };
                    }
                }
            }
        }
Exemplo n.º 41
0
 /// <summary>
 /// Add an input field.
 /// </summary>
 /// <param name="f">The input field to add.</param>
 public void AddInputField(IInputField f)
 {
     _inputFields.Add(f);
 }
 /// <summary>
 /// Add an input field.
 /// </summary>
 /// <param name="f">The input field to add.</param>
 public void AddInputField(IInputField f)
 {
     _inputFields.Add(f);
 }
 /// <summary>
 /// Construct a balanced segregator.
 /// </summary>
 /// <param name="target">The input field to base this on, should 
 /// be an integer value.</param>
 /// <param name="count">The number of rows to accept from each 
 /// unique value for the input.</param>
 public IntegerBalanceSegregator(IInputField target, int count)
 {
     _target = target;
     _count = count;
 }
Exemplo n.º 44
0
 private void DetermineInputFieldValue(IInputField field, int index)
 {
     double num;
     InputFieldCSV dcsv;
     if (field is InputFieldCSV)
     {
         goto Label_00F5;
     }
     if (field is InputFieldMLDataSet)
     {
         InputFieldMLDataSet set = (InputFieldMLDataSet) field;
         MLDataFieldHolder holder = this._dataSetFieldMap[field];
         IMLDataPair pair = holder.Pair;
         int offset = set.Offset;
         if ((((uint) index) >= 0) && (offset >= pair.Input.Count))
         {
             offset -= pair.Input.Count;
             num = pair.Ideal[offset];
             if ((((uint) index) + ((uint) num)) > uint.MaxValue)
             {
                 return;
             }
             if (((uint) offset) >= 0)
             {
                 if (0 != 0)
                 {
                     return;
                 }
                 goto Label_0022;
             }
             goto Label_00F5;
         }
         num = pair.Input[offset];
     }
     else
     {
         num = field.GetValue(index);
     }
     Label_0022:
     field.CurrentValue = num;
     return;
     Label_00F5:
     dcsv = (InputFieldCSV) field;
     num = this._csvMap[field].GetDouble(dcsv.Offset);
     goto Label_0022;
 }
 /// <summary>
 /// Add a nominal item based on a range.
 /// </summary>
 /// <param name="inputField">The input field to use.</param>
 /// <param name="low">The low value of the range.</param>
 /// <param name="high">The high value of the range.</param>
 public void AddItem(IInputField inputField, double low,
                     double high)
 {
     var item = new NominalItem(inputField, low, high);
     _items.Add(item);
 }
Exemplo n.º 46
0
 /// <summary>
 /// Add an input field.
 /// </summary>
 /// <param name="f">The input field to add.</param>
 public void AddInputField(IInputField f)
 {
     this.inputFields.Add(f);
 }
Exemplo n.º 47
0
 /// <summary>
 /// Construct a range segregator.
 /// </summary>
 /// <param name="sourceField">The source field.</param>
 /// <param name="include">Default action, if the data is not in any of the ranges,
 /// should it be included.</param>
 public RangeSegregator(IInputField sourceField, bool include)
 {
     this.sourceField = sourceField;
     this.include = include;
 }
Exemplo n.º 48
0
        /// <summary>
        /// Called internally to obtain the current value for an input field.
        /// </summary>
        /// <param name="field">The input field to determine.</param>
        /// <param name="index">The current index.</param>
        /// <returns>The value for this input field.</returns>
        private double DetermineInputFieldValue(IInputField field,
                 int index)
        {
            double result = 0;

            if (field is InputFieldCSV)
            {
                InputFieldCSV fieldCSV = (InputFieldCSV)field;
                ReadCSV csv = this.csvMap[field];
                result = csv.GetDouble(fieldCSV.Offset);
            }
            else if (field is InputFieldNeuralDataSet)
            {
                InputFieldNeuralDataSet neuralField = (InputFieldNeuralDataSet)field;
                NeuralDataFieldHolder holder = this.dataSetFieldMap
                       [field];
                INeuralDataPair pair = holder.Pair;
                int offset = neuralField.Offset;
                if (offset < pair.Input.Count)
                {
                    result = pair.Input[offset];
                }
                else
                {
                    offset -= pair.Input.Count;
                    result = pair.Ideal[offset];
                }
            }
            else
            {
                result = field.GetValue(index);
            }

            field.CurrentValue = result;
            return result;
        }