public NNBayesHeuristic(IRepresentation representationSolve, IRepresentation representationUncert, int numHiddenSolve, int numOutputSolve, int?numHiddenUncert, float dropout, bool l2Loss) : base() { this.l2Loss = l2Loss; this.beta = 0.05F; float minBeta = 0.00001F; this.q = 0.95; this.representationSolve = representationSolve; this.representationUncert = representationUncert; nnSolve = new MyNN(new int[] { representationSolve.NumInputs, numHiddenSolve, numOutputSolve }, memoryBufferMaxRecords, l2Loss, dropout); nnUncert = null; if (numHiddenUncert != null) { nnUncert = new NNBayes(new int[] { representationUncert.NumInputs, (int)numHiddenUncert, 1 }); } this.confLevel = null; this.updateBeta = true; this.betaDiscountFactor = (float)Math.Pow(minBeta / beta, 1F / Global.NITER); this.reduceUncertFactor = 0.8; }
public NNPreTrainedHeuristic(MyNN nnSolve, IRepresentation representationSolve, double?confLevel, bool l2Loss) { this.nnSolve = nnSolve; this.representationSolve = representationSolve; this.confLevel = confLevel; this.l2Loss = l2Loss; }
public static Output For(IRepresentation representation) { ResponseContext context = new ResponseContext(); representation.UpdateContext(context); return For(context); }
private Response(StatusCode statusCode, IRepresentation representation) { Log.DebugFormat("Returning {0}.", statusCode); this.statusCode = statusCode; this.representation = representation; }
public IResponse CreateResponse(IRepresentation representation) { HeaderQuery query = new HeaderQuery(eTag); if (query.Matches(representation)) { Log.DebugFormat("If-None-Match precondition failed."); return Response.NotModified(eTag); } Log.DebugFormat("If-None-Match precondition OK."); return Response.OK(representation); }
/// <summary> /// Initializes a new instance of the <see cref="RepresentationMutableCore"/> class. /// </summary> /// <param name="representation"> /// The representation. /// </param> public RepresentationMutableCore(IRepresentation representation) : base(representation) { if (representation.TextFormat != null) { this.textFormat = new TextFormatMutableCore(representation.TextFormat); } if (representation.Representation != null) { this.representationRef = representation.Representation.CreateMutableInstance(); } }
/////////////////////////////////////////////////////////////////////////////////////////////////// ////////////BUILD FROM MUTABLE OBJECT ////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// #region Constructors and Destructors /// <summary> /// Initializes a new instance of the <see cref="ConceptCore"/> class. /// </summary> /// <param name="parent"> /// The parent. /// </param> /// <param name="itemMutableObject"> /// The sdmxObject. /// </param> public ConceptCore(IConceptSchemeObject parent, IConceptMutableObject itemMutableObject) : base(itemMutableObject, parent) { if(itemMutableObject.CoreRepresentation != null && (itemMutableObject.CoreRepresentation.TextFormat != null || itemMutableObject.CoreRepresentation.Representation != null)) { this.coreRepresentation = new RepresentationCore(itemMutableObject.CoreRepresentation, this); } if (itemMutableObject.IsoConceptReference != null) { this.isoConceptReference = new CrossReferenceImpl(this, itemMutableObject.IsoConceptReference); } this.parentConcept = itemMutableObject.ParentConcept; this.parentAgency = itemMutableObject.ParentAgency; }
public static ActionResultRepresentation Create(IOidStrategy oidStrategy, HttpRequest req, ActionResultContextFacade actionResult, RestControlFlags flags) { if (!actionResult.HasResult) { return(new ActionResultRepresentation(oidStrategy, req, actionResult, flags)); } IRepresentation result = actionResult switch { _ when actionResult.Result == null => null, _ when actionResult.Specification.IsParseable => ScalarRepresentation.Create(oidStrategy, actionResult.Result, req, flags), _ when actionResult.Specification.IsObject => ObjectRepresentation.Create(oidStrategy, actionResult.Result, req, flags), _ => PagedListRepresentation.Create(oidStrategy, actionResult, req, flags) }; return(CreateWithOptionals <ActionResultRepresentation>(new object[] { oidStrategy, req, actionResult, flags }, new[] { new OptionalProperty(JsonPropertyNames.Result, result) })); } }
public Concept(IConceptObject concept) { this._id = concept.Id; this._names = new List<TextTypeWrapper>(); this._descriptions = new List<TextTypeWrapper>(); foreach (var text in concept.Names) this._names.Add(new TextTypeWrapper(text.Locale, text.Value)); foreach (var text in concept.Descriptions) this._descriptions.Add(new TextTypeWrapper(text.Locale, text.Value)); this._coreRepresentation = concept.CoreRepresentation; this._isoConceptReference = concept.IsoConceptReference; this._parentAgency = concept.ParentAgency; this._parentConcept = concept.ParentConcept; this._uri = concept.Uri; this._urn = concept.Urn; }
public LinkWithParent(Link link, IRepresentation parent) { Link = link; Parent = parent; }
/////////////////////////////////////////////////////////////////////////////////////////////////// ////////////BUILD FROM V2 SCHEMA ////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Initializes a new instance of the <see cref="ConceptCore"/> class. /// </summary> /// <param name="parent"> /// The parent. /// </param> /// <param name="concept"> /// The sdmxObject. /// </param> public ConceptCore( IConceptSchemeObject parent, Org.Sdmx.Resources.SdmxMl.Schemas.V20.structure.ConceptType concept) : base( concept, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Concept), concept.id, concept.uri, concept.Name, concept.Description, concept.Annotations, parent) { if (!string.IsNullOrWhiteSpace(concept.coreRepresentation)) { string representationAgency = concept.coreRepresentationAgency; if (representationAgency == null) { representationAgency = parent.AgencyId; } string representationVersion = concept.CoreRepresentationVersionEstat ?? MaintainableObject.DefaultVersion; this.coreRepresentation = new RepresentationCore( concept.TextFormat, representationAgency, concept.coreRepresentation, representationVersion, this); } else if (concept.TextFormat != null) { this.coreRepresentation = new RepresentationCore(concept.TextFormat, null, null, null, this); } this.parentConcept = concept.parent; this.parentAgency = concept.parentAgency; }
public static Uri Identify(this IRepresentation representation, IRepository repository, Stream content) { return(representation.Identify(repository, content, null)); }
static void Main(string[] args) { Control.UseNativeMKL(); Console.WriteLine("start1"); //PancakePuzzle.BuildPDBs.BuildPDBs24(); //GenTest(null, 50,Global.MAXSTEPS); multHeuristic = null; representationSolve = new SlidingPuzzle.Representations.TwoDim(new Func <double, double>(x => x / 10), new Func <double, double>(x => x * 10)); representationUncert = new SlidingPuzzle.Representations.TwoDim(null, null); for (int r = 1; r <= 5; r++) { { List <Tuple <int, bool, int> > paramaters = new List <Tuple <int, bool, int> >(); paramaters.Add(new Tuple <int, bool, int>(1, true, 1)); foreach (var p in paramaters) { Train(r, Global.NITER, p.Item1, p.Item2, p.Item3, false); } } { int nnIndex = Global.NITER - 1; List <Tuple <string, int, double?> > paramaters = new List <Tuple <string, int, double?> >(); paramaters.Add(new Tuple <string, int, double?>("1", nnIndex, null)); foreach (var p in paramaters) { TestAdmissibility(r, p.Item1, p.Item2, p.Item3); } } { List <Tuple <int, bool, int> > paramaters = new List <Tuple <int, bool, int> >(); paramaters.Add(new Tuple <int, bool, int>(2, true, 1)); foreach (var p in paramaters) { Train(r, Global.NITER, p.Item1, p.Item2, p.Item3, false); } } { int nnIndex = Global.NITER - 1; List <Tuple <string, int, double?> > paramaters = new List <Tuple <string, int, double?> >(); paramaters.Add(new Tuple <string, int, double?>("2", nnIndex, 0.5)); paramaters.Add(new Tuple <string, int, double?>("2", nnIndex, 0.95)); paramaters.Add(new Tuple <string, int, double?>("2", nnIndex, 0.9)); paramaters.Add(new Tuple <string, int, double?>("2", nnIndex, 0.75)); paramaters.Add(new Tuple <string, int, double?>("2", nnIndex, 0.25)); paramaters.Add(new Tuple <string, int, double?>("2", nnIndex, 0.1)); paramaters.Add(new Tuple <string, int, double?>("2", nnIndex, 0.05)); foreach (var p in paramaters) { TestAdmissibility(r, p.Item1, p.Item2, p.Item3); } } { List <Tuple <int, bool, int> > paramaters = new List <Tuple <int, bool, int> >(); paramaters.Add(new Tuple <int, bool, int>(1, true, 1)); paramaters.Add(new Tuple <int, bool, int>(1, false, 1)); paramaters.Add(new Tuple <int, bool, int>(1, false, 2)); paramaters.Add(new Tuple <int, bool, int>(1, false, 4)); paramaters.Add(new Tuple <int, bool, int>(1, false, 6)); paramaters.Add(new Tuple <int, bool, int>(1, false, 8)); paramaters.Add(new Tuple <int, bool, int>(1, false, 10)); foreach (var p in paramaters) { Train(r, Global.NITER, p.Item1, p.Item2, p.Item3, true); } } { int numTasks = 1000; int numIter = 5; int nnIndex = Global.NITER - 1; TestDomainData[][] testData = new TestDomainData[numIter][]; for (int i = 0; i < numIter; i++) { TestDomainData[] data = new TestDomainData[numTasks]; for (int j = 0; j < numTasks; j++) { data[j] = GenTest(null, 1, j + 1, false, false)[0]; } testData[i] = data; } List <Tuple <string, int> > paramaters = new List <Tuple <string, int> >(); paramaters.Add(new Tuple <string, int>("1e", nnIndex)); paramaters.Add(new Tuple <string, int>("k1", nnIndex)); paramaters.Add(new Tuple <string, int>("k2", nnIndex)); paramaters.Add(new Tuple <string, int>("k4", nnIndex)); paramaters.Add(new Tuple <string, int>("k6", nnIndex)); paramaters.Add(new Tuple <string, int>("k8", nnIndex)); paramaters.Add(new Tuple <string, int>("k10", nnIndex)); foreach (var p in paramaters) { TestEfficiency(r, p.Item1, p.Item2, testData); } } } Console.ReadLine(); }
/////////////////////////////////////////////////////////////////////////////////////////////////// ////////////BUILD FROM V2.1 SCHEMA ////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Initializes a new instance of the <see cref="ConceptCore"/> class. /// </summary> /// <param name="parent"> /// The parent. /// </param> /// <param name="concept"> /// The sdmxObject. /// </param> public ConceptCore(IConceptSchemeObject parent, ConceptType concept) : base(concept, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Concept), parent) { if (concept.CoreRepresentation != null) { this.coreRepresentation = new RepresentationCore(concept.CoreRepresentation, this); } if (concept.ISOConceptReference != null) { this.isoConceptReference = new CrossReferenceImpl( this, concept.ISOConceptReference.ConceptAgency, concept.ISOConceptReference.ConceptSchemeID, null, SdmxStructureEnumType.Concept, concept.ISOConceptReference.ConceptID); } var localItemReferenceType = concept.GetTypedParent<LocalConceptReferenceType>(); if (localItemReferenceType != null) { if (ObjectUtil.ValidCollection(localItemReferenceType.URN)) { IStructureReference structureReference = new StructureReferenceImpl(localItemReferenceType.URN[0]); this.parentConcept = structureReference.ChildReference.Id; this.parentAgency = structureReference.MaintainableReference.AgencyId; } else { this.parentConcept = localItemReferenceType.GetTypedRef<LocalConceptRefType>().id; this.parentAgency = this.MaintainableParent.AgencyId; } } }
public NegotiatedResult NegotiatedResult(IRepresentation value) { return(new NegotiatedResult(value)); }
public FeedOfRecentEvents(IRepresentation innerRepresentation) { this.innerRepresentation = innerRepresentation; }
public NegotiatedResult(IRepresentation value) { Value = value; }
public ArchiveFeed(IRepresentation innerRepresentation) { this.innerRepresentation = innerRepresentation; }
public static IResponse OK(IRepresentation representation) { return new Response(StatusCode.OK, representation); }
public IResponse CreateResponse(IRepresentation representation) { return Response.OK(representation); }
public bool Matches(IRepresentation representation) { IResponseContext context = new ResponseContext(); representation.UpdateContext(context); return context.ContainsHeader(header); }