Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/04/16 16:38:21 (9 years ago)
Author:
jlodewyc
Message:

#2582 Parameterizing arrays start

Location:
branches/WebJobManager
Files:
3 added
10 edited

Legend:

Unmodified
Added
Removed
  • branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Hubs/ProgressHub.cs

    r13827 r13834  
    88using HeuristicLab.Data;
    99using System.Reflection;
     10using HeuristicLab.Core;
    1011
    1112namespace HeuristicLab.Clients.Hive.WebJobManager
     
    257258
    258259                //BUGGERS
    259                 if (name == "ReevaluateElites")
    260                     name = "ReevaluteElites";
    261                 if (name == "DominateOnEqualQualities" || name == "PlusSelection" || name == "ReevaluteElites")
    262                     val = ((BoolValue)val).Value;
    263                
    264                // if (name == "ReduceToPopulationSize")
    265                     //name += "Parameter";
    266 
    267                 try
    268                 {
    269                     Algorithm alg = (Algorithm)curr.ItemTask.Item;
    270                     if (prob)
    271                         alg.Problem.GetType().GetProperty(name).SetValue(alg, val);
    272                     else
    273                         alg.GetType().GetProperty(name).SetValue(alg, val);
    274                 }
    275                 catch (NullReferenceException e)
    276                 {
    277                     Console.WriteLine("NullRefException: " + name + " - " + type);
    278                 }
    279                 catch(TargetException e)
    280                 {
    281                     Console.WriteLine("TargetException: " + name + " - " + type);
    282                 }
     260                // if (name == "DominateOnEqualQualities" || name == "PlusSelection" || name == "ReevaluteElites")
     261                //   val = ((BoolValue)val).Value;
     262
     263                // if (name == "ReduceToPopulationSize")
     264                //name += "Parameter";
     265                if (val != null)
     266                {
     267                    try
     268                    {
     269                        IAlgorithm alg = (IAlgorithm)curr.ItemTask.Item;
     270                        if (prob)
     271                            alg.Problem.Parameters[name].ActualValue = (IItem)val;
     272                        else
     273                        {
     274                            alg.Parameters[name].ActualValue = (IItem)val;
     275                        }
     276                    }
     277                    catch (NullReferenceException e)
     278                    {
     279                        Console.WriteLine("NullRefException: " + name + " - " + type);
     280                    }
     281                    catch (TargetException e)
     282                    {
     283                        Console.WriteLine("TargetException: " + name + " - " + type);
     284                    }
     285                    catch (NotSupportedException e)
     286                    {
     287                        Clients.Caller.dataNotSupported(name);
     288                    }
     289                }
     290                else
     291                    Clients.Caller.formatWrong(name, type);
     292
     293
    283294            }
    284295
  • branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Scripts/Hubs/ProgressHubber.js

    r13827 r13834  
    2222        }
    2323    };
     24    hubber.client.dataNotSupported = function (name) {
     25        window.alert("Parameter " + name + " could not be changed for it is a fixed parameter. All changes done in this view are not saved to Hive.");
     26    }
     27    hubber.client.formatWrong = function (name, type) {
     28        window.alert("Parameter " + name + " could not be changed, the format for "+type+ " was wrong. Make sure you follow the example exactly. No changes made on Hive");
     29    }
    2430});
    2531//Adds the current loaded job to Hive.
  • branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Views/Job/OpenFile.cshtml

    r13827 r13834  
    219219               
    220220            }
    221             <li><a href="#finish"><i class="fa fa-flag-checkered"></i> Job info and upload</a></li>
     221            <li><a href="#finish"><i class="fa fa-flag-checkered"></i> Add to Hive or save to file</a></li>
    222222        </ul>
    223223    </nav>
  • branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Views/Job/OpenFilePartials/DataPartials/DataMaster.cshtml

    r13827 r13834  
    44<tr>
    55    <td>@Model.Data.Name</td>
    6     @if (Model.Data.ActualValue is BoolValue)
    7     {
    8         @Html.Partial("OpenFilePartials/DataPartials/Bool", Model);
    9     }
    10     else if (Model.Data.ActualValue is StringValue) {
    11         @Html.Partial("OpenFilePartials/DataPartials/String", Model);
    12     }
    13     else if (Model.Data.ActualValue is IntValue)
    14     {
    15         @Html.Partial("OpenFilePartials/DataPartials/Int", Model);
    16     }
    17     else if (Model.Data.ActualValue is PercentValue)
    18     {
    19         @Html.Partial("OpenFilePartials/DataPartials/Percent", Model);
    20     }
    21     else if(Model.Data.ActualValue is DoubleValue)
    22     {
    23         @Html.Partial("OpenFilePartials/DataPartials/Double", Model);
    24     }
    25     else if (Model.Data.ActualValue is IItem)
    26     {
    27         @Html.Partial("OpenFilePartials/DataPartials/Others", Model);
     6    @{
     7        try
     8        {
     9            Model.Data.ActualValue = Model.Data.ActualValue;
     10            @if (Model.Data.ActualValue is BoolValue)
     11            {
     12                @Html.Partial("OpenFilePartials/DataPartials/Bool", Model);
     13            }
     14            else if (Model.Data.ActualValue is StringValue)
     15            {
     16                @Html.Partial("OpenFilePartials/DataPartials/String", Model);
     17            }
     18            else if (Model.Data.ActualValue is IntValue)
     19            {
     20                @Html.Partial("OpenFilePartials/DataPartials/Int", Model);
     21            }
     22            else if (Model.Data.ActualValue is PercentValue)
     23            {
     24                @Html.Partial("OpenFilePartials/DataPartials/Percent", Model);
     25            }
     26            else if (Model.Data.ActualValue is DoubleValue)
     27            {
     28                @Html.Partial("OpenFilePartials/DataPartials/Double", Model);
     29            }
     30            else if (Model.Data.ActualValue is IntArray)
     31            {
     32                @Html.Partial("OpenFilePartials/DataPartials/IntArray", Model);
     33            }
     34            else if (Model.Data.ActualValue is DoubleArray)
     35            {
     36                @Html.Partial("OpenFilePartials/DataPartials/DoubleArray", Model);
     37            }
     38            else if (Model.Data.ActualValue is DoubleMatrix)
     39            {
     40                @Html.Partial("OpenFilePartials/DataPartials/DoubleMatrix", Model);
     41            }
     42            else if (Model.Data.ActualValue is IItem)
     43            {
     44                @Html.Partial("OpenFilePartials/DataPartials/Others", Model);
     45                }
     46        }
     47        catch(NotSupportedException e)
     48        {
     49            @Html.Partial("OpenFilePartials/DataPartials/Others", Model)
     50
     51        }
    2852    }
    2953</tr>
  • branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Views/Job/OpenFilePartials/DataPartials/Double.cshtml

    r13827 r13834  
    44
    55<td>
    6     <input type="number"
     6    <input style="width:50%;"
     7           type="number"
    78           value="@Model.Data.ActualValue"
    89           onchange="paraEdit(@Model.Position,'@Model.Problem.ToString()',
  • branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Views/Job/OpenFilePartials/DataPartials/Int.cshtml

    r13827 r13834  
    44
    55<td>
    6     <input type="number"
     6    <input style="width:50%;"
     7            type="number"
    78           value="@Model.Data.ActualValue"
    89           onchange="paraEdit(@Model.Position,'@Model.Problem.ToString()',
  • branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Views/Job/OpenFilePartials/DataPartials/Percent.cshtml

    r13827 r13834  
    77           min="0"
    88           max="100"
     9           style="width:50%;"
    910           value="@(int.Parse(new String(Model.Data.ActualValue.ToString().Where(Char.IsDigit).ToArray())))"
    1011           onchange="paraEdit(@Model.Position,'@Model.Problem.ToString()',
  • branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Views/Job/OpenFilePartials/DataPartials/String.cshtml

    r13827 r13834  
    55<td>
    66    <input type="text"
     7           style="width:100%;"
    78           value="@Model.Data.ActualValue"
    89           onchange="paraEdit(@Model.Position,'@Model.Problem.ToString()',
  • branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/wwwroot/js/hubs/progresshubber.js

    r13827 r13834  
    1 function addtoHive(){var a=document.getElementById("jname").value,b=document.getElementById("jresource").value;a&&""!=a&&null!=a?(hubber.server.changeNameResource(a,b),document.getElementById("fakehiveadd").style.display="none",document.getElementById("progdiv").style.display="",document.getElementById("result").style.display="",document.getElementById("realhiveadd").click()):alert("Job name not set!")}function toggleChild(a,b){console.log(a+" toggled"),hubber.server.toggleChild(a),"none"==$("#childs"+b).css("display")?$("#childs"+b).css("display",""):$("#childs"+b).css("display","none"),$("body").click()}function changePriority(a,b,c){switch(console.log(a+" to priority "+b),hubber.server.changePriority(a,b),resetPrior(c),b){case 0:document.getElementById("prior"+c).className+="btn-default",document.getElementById("prior"+c).innerHTML="Low";break;case 1:document.getElementById("prior"+c).className+="btn-info",document.getElementById("prior"+c).innerHTML="Normal";break;case 2:document.getElementById("prior"+c).className+="btn-warning",document.getElementById("prior"+c).innerHTML="Urgent";break;case 3:document.getElementById("prior"+c).className+="btn-danger",document.getElementById("prior"+c).innerHTML="Critical"}document.getElementById("prior"+c).innerHTML+="<span class='caret'></span>"}function resetPrior(a){document.getElementById("prior"+a).className="btn dropdown-toggle "}function paraEdit(a,b,c,d,e){hubber.server.paraEdit(a,b,c,d,e)}var hubber=$.connection.progressHub;$(function(){var a=document.getElementById("userId").innerHTML;console.log(a),$.connection.hub.qs={userid:a},$.connection.hub.start().done(function(){$("#progress").css("width","0%"),$("#progress").attr("aria-valuenow",0),hubber.server.handleMessage("Looking for connection...")}),hubber.client.processMessage=function(a,b){b>$("#progress").attr("aria-valuenow")&&($("#progress").css("width",b+"%"),$("#progress").attr("aria-valuenow",b),$("#progress").html(b+"%"),$("#result").html(a))}});
     1function addtoHive(){var a=document.getElementById("jname").value,b=document.getElementById("jresource").value;a&&""!=a&&null!=a?(hubber.server.changeNameResource(a,b),document.getElementById("fakehiveadd").style.display="none",document.getElementById("progdiv").style.display="",document.getElementById("result").style.display="",document.getElementById("realhiveadd").click()):alert("Job name not set!")}function toggleChild(a,b){console.log(a+" toggled"),hubber.server.toggleChild(a),"none"==$("#childs"+b).css("display")?$("#childs"+b).css("display",""):$("#childs"+b).css("display","none"),$("body").click()}function changePriority(a,b,c){switch(console.log(a+" to priority "+b),hubber.server.changePriority(a,b),resetPrior(c),b){case 0:document.getElementById("prior"+c).className+="btn-default",document.getElementById("prior"+c).innerHTML="Low";break;case 1:document.getElementById("prior"+c).className+="btn-info",document.getElementById("prior"+c).innerHTML="Normal";break;case 2:document.getElementById("prior"+c).className+="btn-warning",document.getElementById("prior"+c).innerHTML="Urgent";break;case 3:document.getElementById("prior"+c).className+="btn-danger",document.getElementById("prior"+c).innerHTML="Critical"}document.getElementById("prior"+c).innerHTML+="<span class='caret'></span>"}function resetPrior(a){document.getElementById("prior"+a).className="btn dropdown-toggle "}function paraEdit(a,b,c,d,e){hubber.server.paraEdit(a,b,c,d,e)}var hubber=$.connection.progressHub;$(function(){var a=document.getElementById("userId").innerHTML;console.log(a),$.connection.hub.qs={userid:a},$.connection.hub.start().done(function(){$("#progress").css("width","0%"),$("#progress").attr("aria-valuenow",0),hubber.server.handleMessage("Looking for connection...")}),hubber.client.processMessage=function(a,b){b>$("#progress").attr("aria-valuenow")&&($("#progress").css("width",b+"%"),$("#progress").attr("aria-valuenow",b),$("#progress").html(b+"%"),$("#result").html(a))},hubber.client.dataNotSupported=function(a){window.alert("Parameter "+a+" could not be changed for it is a fixed parameter. All changes done in this view are not saved to the server.")},hubber.client.formatWrong=function(a,b){window.alert("Parameter "+a+" could not be changed, the format for "+b+" was wrong. Make sure you follow the example exactly. No changes made on the server")}});
  • branches/WebJobManager/HeuristicLab.Data/3.3/IntArray.cs

    r12012 r13834  
    2424using HeuristicLab.Core;
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     26using System.Linq;
     27using System;
    2628
    2729namespace HeuristicLab.Data {
     
    5557      return valid;
    5658    }
     59        public static IntArray Parse(string val)
     60        {
     61            try {
     62            string[] arr = Array.ConvertAll(val.Trim().Split(';'), p => p.Trim());
     63            int[] a = arr.Where(s => s != "").ToList().ConvertAll(s => int.Parse(s)).ToArray();
     64            return new IntArray(a);
     65            }
     66            catch(FormatException e)
     67            {
     68                 return null;
     69            }
     70        }
    5771    protected virtual string GetValue(int index) {
    5872      return this[index].ToString();
Note: See TracChangeset for help on using the changeset viewer.